5 #include <sys/socket.h>
8 #include <netinet/in.h>
11 #define PACKET_SIZE 1200
13 static int burst_sizes[] = { 1, 2, 3, 5, 10, 20, 50, 100, 200, 500 };
14 static int num_burst_sizes = sizeof(burst_sizes) / sizeof(burst_sizes[0]);
16 static void send_burst(int sock, const struct sockaddr *addr, socklen_t addr_len, int burst_size)
18 static char buf[PACKET_SIZE] = { 0 };
19 static int pkt_num = 0;
22 for (i = 0; i < burst_size; ++i) {
24 printf("%d ", pkt_num);
25 memcpy(buf, &pkt_num, sizeof(pkt_num));
26 sendto(sock, buf, PACKET_SIZE, 0, addr, addr_len);
31 int main(int argc, char **argv)
33 int sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
34 struct sockaddr_in6 addr;
35 addr.sin6_family = AF_INET6;
36 addr.sin6_port = htons(atoi(argv[2]));
38 inet_pton(AF_INET6, argv[1], &addr.sin6_addr);
43 int burst_size = burst_sizes[rand() % num_burst_sizes];
44 send_burst(sock, (struct sockaddr *)&addr, sizeof(addr), burst_size);