diff --git a/tools/tools/mctest/mctest.1 b/tools/tools/mctest/mctest.1 index 17729f2e8748..3ca57eee013e 100644 --- a/tools/tools/mctest/mctest.1 +++ b/tools/tools/mctest/mctest.1 @@ -33,6 +33,8 @@ .Sh SYNOPSIS .Nm .Op Fl i Ar interface +.Op Fl g Ar group +.Op Fl b Ar base port .Op Fl n Ar number .Op Fl s Ar size .Op Fl t Ar inter-packet gap @@ -57,6 +59,10 @@ The options are as follows: .Bl -tag -width ".Fl d Ar argument" .It Fl i Ar interface Network interface, which can be found with ifconfig(1). +.It Fl i Ar group +Multicast group +.It Fl i Ar base port +Port on which to listen .It Fl s Ar size Packet size in bytes. .It Fl n Ar number diff --git a/tools/tools/mctest/mctest.cc b/tools/tools/mctest/mctest.cc index 436efcefd2ea..7140b62cd723 100644 --- a/tools/tools/mctest/mctest.cc +++ b/tools/tools/mctest/mctest.cc @@ -92,7 +92,7 @@ void usage(string message) // @return 0 for 0K, -1 for error, sets errno // int sink(char *interface, struct in_addr *group, int pkt_size, int number, - int clients, int client) { + int clients, int client, short base_port) { int sock, backchan; @@ -181,7 +181,7 @@ int sink(char *interface, struct in_addr *group, int pkt_size, int number, * the sender. */ if (n % clients == client) { - recvd.sin_port = htons(SERVER_PORT + client); + recvd.sin_port = htons(base_port + client); if (sendto(backchan, packet, pkt_size, 0, (struct sockaddr *)&recvd, sizeof(recvd)) < 0) { perror("sendto failed"); @@ -249,7 +249,7 @@ void* server(void *passed) { bzero(&addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; - addr.sin_port = htons(SERVER_PORT + args->client); + addr.sin_port = htons(args->client); addr.sin_len = sizeof(addr); if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { @@ -295,7 +295,7 @@ void* server(void *passed) { // @return 0 for OK, -1 for error, sets errno // int source(char *interface, struct in_addr *group, int pkt_size, - int number, int gap, int clients) { + int number, int gap, int clients, short base_port) { int sock; struct sockaddr_in addr; @@ -367,7 +367,7 @@ int source(char *interface, struct in_addr *group, int pkt_size, args[i].pkt_size = pkt_size; args[i].packets = received[i]; args[i].number = number / clients; - args[i].client = i; + args[i].client = base_port + i; if (pthread_create(&thread[i], NULL, server, &args[i]) < 0) { perror("failed to create server thread"); return -1; @@ -440,11 +440,12 @@ int main(int argc, char**argv) bool server = false; ///< are we on he receiving end of multicast int client = 0; ///< for receivers which client are we int clients = 1; ///< for senders how many clients are there + short base_port = SERVER_PORT; ///< to have multiple copies running at once - if (argc < 2 || argc > 14) + if (argc < 2 || argc > 16) usage(); - while ((ch = getopt(argc, argv, "M:m:g:i:n:s:t:rh")) != -1) { + while ((ch = getopt(argc, argv, "M:m:g:i:n:s:t:b:rh")) != -1) { switch (ch) { case 'g': group = new (struct in_addr ); @@ -482,6 +483,9 @@ int main(int argc, char**argv) case 'M': clients = atoi(optarg); break; + case 'b': + base_port = atoi(optarg); + break; case 'h': usage(string("Help\n")); break; @@ -491,11 +495,13 @@ int main(int argc, char**argv) if (server) { if (clients <= 0 || client < 0) usage("must specify client (-m) and number of clients (-M)"); - sink(interface, group, pkt_size, number, clients, client); + sink(interface, group, pkt_size, number, clients, client, + base_port); } else { if (clients <= 0) usage("must specify number of clients (-M)"); - source(interface, group, pkt_size, number, gap, clients); + source(interface, group, pkt_size, number, gap, clients, + base_port); } } diff --git a/tools/tools/mctest/mctest_run.sh b/tools/tools/mctest/mctest_run.sh index ec41d3767edf..2e4ac02fe7d8 100644 --- a/tools/tools/mctest/mctest_run.sh +++ b/tools/tools/mctest/mctest_run.sh @@ -7,6 +7,7 @@ # Defaults size=1024 number=100 +base="" group="" interface="cxgb0" remote="ssh" @@ -15,7 +16,7 @@ gap=1000 # Arguments are s (size), g (group), n (number), and c (command) followed # by a set of hostnames. -args=`getopt s:g:n:c:i: $*` +args=`getopt s:g:n:c:i:b: $*` if [ $? != 0 ] then echo 'Usage: mctest_run -s size -g group -n number -c remote command host1 host2 hostN' @@ -42,6 +43,9 @@ do -i) interface=$3; shift 2;; + -b) + base=$3; + shift 2;; --) shift; break;; esac @@ -56,7 +60,7 @@ now=`date "+%Y%m%d%H%M"` for host in $* do output=$host\_$interface\_$size\_$number\.$now - $remote $host $command -r -M $# -m $current -n $number -s $size -i $interface > $output & + $remote $host $command -r -M $# -b $base -g $group -m $current -n $number -s $size -i $interface > $output & sleep 1 current=`expr $current + 1 `; done @@ -64,4 +68,4 @@ done # # Start the source/collector on this machine # -$command -M $# -n $number -s $size -i le1 -t $gap > `uname -n`\_$size\_$number\.$now +$command -M $# -b $base -g $group -n $number -s $size -i $interface -t $gap > `uname -n`\_$size\_$number\.$now