Skip to content

Commit 66aeddd

Browse files
committed
update default ip for test code
1 parent c658042 commit 66aeddd

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

examples/http_server/http_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ int RunServerThread()
245245
return 0;
246246
}
247247
/*----------------------------------------------------------------------------*/
248-
int main(int argc, char *argv[] )
248+
int main(int argc, char *argv[])
249249
{
250250
int core =0;
251251

test/dpdk_udp/dpdk_udp.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3131
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
*/
33-
34-
33+
#define _GNU_SOURCE
3534
#include <stdio.h>
35+
#include <stdlib.h>
36+
#include <sched.h>
37+
#include <unistd.h>
38+
#include <sys/times.h>
3639
#include <stdint.h>
3740
#include <string.h>
38-
#include <stdlib.h>
3941
#include <stdarg.h>
4042
#include <errno.h>
4143
#include <netinet/in.h>
@@ -50,6 +52,9 @@
5052
#endif
5153
#endif
5254

55+
#include <sys/socket.h>
56+
#include <netinet/in.h>
57+
#include <arpa/inet.h>
5358
#include <sys/time.h>
5459

5560
#include "anssock_intf.h"
@@ -58,7 +63,7 @@
5863

5964
struct epoll_event events[20];
6065

61-
int main(void)
66+
int main(int argc, char *argv[])
6267
{
6368
int ret;
6469
int i = 0 ;
@@ -72,6 +77,24 @@ int main(void)
7277
struct epoll_event event;
7378
char recv_buf[2038];
7479
int recv_len;
80+
int core = -1;
81+
82+
if(argc >= 2)
83+
{
84+
core = atoi(argv[1]);
85+
printf("affinity to core %d \n", core);
86+
87+
/*initialize thread bind cpu*/
88+
cpu_set_t cpus;
89+
90+
CPU_ZERO(&cpus);
91+
CPU_SET((unsigned)core, &cpus);
92+
sched_setaffinity(0, sizeof(cpus), &cpus);
93+
}
94+
else
95+
{
96+
printf("no affinity by default \n");
97+
}
7598

7699
ret = anssock_init(NULL);
77100
if(ret != 0)
@@ -97,7 +120,7 @@ int main(void)
97120
memset(&addr_in, 0, sizeof(addr_in));
98121
addr_in.sin_family = AF_INET;
99122
addr_in.sin_port = htons(8888);
100-
addr_in.sin_addr.s_addr = htonl(0x02020202);
123+
addr_in.sin_addr.s_addr = inet_addr("10.0.0.2");
101124

102125
ret = anssock_bind(fd, (struct sockaddr *)&addr_in, sizeof(addr_in) );
103126
if(ret != 0)
@@ -111,7 +134,7 @@ int main(void)
111134
memset(&remote_addr, 0, sizeof(remote_addr));
112135
remote_addr.sin_family = AF_INET;
113136
remote_addr.sin_port = htons(9999);
114-
remote_addr.sin_addr.s_addr = htonl(0x02020205);
137+
remote_addr.sin_addr.s_addr = inet_addr("10.0.0.10");;
115138

116139

117140
event.data.fd = fd;

test/dpdk_udp_stability/dpdk_udp_stability.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int udp_sock_create(int epfd, unsigned port)
9191
memset(&addr_in, 0, sizeof(addr_in));
9292
addr_in.sin_family = AF_INET;
9393
addr_in.sin_port = htons(port);
94-
addr_in.sin_addr.s_addr = htonl(0x02020202);
94+
addr_in.sin_addr.s_addr = inet_addr("10.0.0.2");
9595

9696
ret = anssock_bind(fd, (struct sockaddr *)&addr_in, sizeof(addr_in) );
9797
if(ret != 0)

test/linux_udp/linux_udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void udp_send_thread()
6666
{
6767
remote_addr.sin_family = AF_INET;
6868
remote_addr.sin_port = htons(UDP_REMOTE_PORT_START + i);
69-
remote_addr.sin_addr.s_addr = inet_addr("2.2.2.2");
69+
remote_addr.sin_addr.s_addr = inet_addr("10.0.0.2");
7070

7171
sprintf(sendline, "Hello, dpdk_udp, num:%d !", data_num);
7272
sendline[SEND_MAX_SIZE -1] = 0;

0 commit comments

Comments
 (0)