#include #include #include #include #include #include #include #include #include #include #include #include #include #include "option.h" #include "dbgprintlib.h" int e0 = -1; int e1 = -1; int t0 = -1; int t1 = -1; int g = -1; int b = -1; int m = -1; int disable_ber = -1; int enable_linkemu = -1; int disable_snoop = -1; int enable_eln = -1; int eln_thresh = -1; int eln_order = -1; int enable_er = -1; int enable_peln = -1; int disable_snooprexmt = -1; int enable_smart = -1; int enable_snoop_smart = -1; int enable_newreno = -1; int no_sack = -1; int enable_large_mss = -1; int te0 = -1; int te1 = -1; int tt0 = -1; int tt1 = -1; int tg = -1; int tb = -1; int tm = -1; int tdisable_ber = -1; int tenable_linkemu = -1; int tdisable_snoop = -1; int tenable_eln = -1; int teln_thresh = -1; int teln_order = -1; int tenable_er = -1; int tenable_peln = -1; int tdisable_snooprexmt = -1; int tenable_smart = -1; int tenable_snoop_smart = -1; int tenable_newreno = -1; int tno_sack = -1; int tenable_large_mss = -1; Option optionArray[] = { {OPT_INT, "m", (char *)&m, "errormodel"}, {OPT_INT, "e0", (char *)&e0, "prob 0"}, {OPT_INT, "e1", (char *)&e1, "prob 1"}, {OPT_INT, "t0", (char *)&t0, "markov transistion prob 0"}, {OPT_INT, "t1", (char *)&t1, "markov transistion prob 1"}, {OPT_INT, "g", (char *)&g, "markov time gran"}, {OPT_INT, "b", (char *)&b, "burstiness"}, {OPT_TRUE, "edis", (char *)&disable_ber, "disable error generation"}, {OPT_FALSE, "eena", (char *)&disable_ber, "enable error generation"}, {OPT_TRUE, "lena", (char *)&enable_linkemu, "enable link-level retx emulation"}, {OPT_FALSE, "ldis", (char *)&enable_linkemu, "disable link-level retx emulation"}, {OPT_TRUE, "sdis", (char *)&disable_snoop, "disable snoop"}, {OPT_FALSE, "sena", (char *)&disable_snoop, "enable snoop"}, {OPT_TRUE, "elnena", (char *)&enable_eln, "enable explicit wireless loss notification"}, {OPT_FALSE, "elndis", (char *)&enable_eln, "disable explicit wireless loss notification"}, {OPT_INT, "elnthresh", (char *)&eln_thresh, "ELN dupack threshold"}, {OPT_INT, "elnorder", (char *)&eln_order, "ELN dupack threshold"}, {OPT_TRUE, "erena", (char *)&enable_er, "enable ER"}, {OPT_FALSE, "erdis", (char *)&enable_er, "disable ER"}, {OPT_TRUE, "pelnena", (char *)&enable_peln, "enable perfect explicit wireless loss notification"}, {OPT_FALSE, "pelndis", (char *)&enable_peln, "disable perfect explicit wireless loss notification"}, {OPT_TRUE, "rdis", (char *)&disable_snooprexmt, "disable snoop/local retransmission"}, {OPT_FALSE, "rena", (char *)&disable_snooprexmt, "enable snoop/local retransmission"}, {OPT_TRUE, "smartena", (char *)&enable_smart, "Enable SMART retransmission"}, {OPT_FALSE, "smartdis", (char *)&enable_smart, "Disable SMART retransmission"}, {OPT_TRUE, "ssena", (char *)&enable_snoop_smart, "Enable Snoop + SMART retransmission"}, {OPT_FALSE, "ssdis", (char *)&enable_snoop_smart, "Disable Snoop + SMART retransmission"}, {OPT_FALSE, "nrdis", (char *)&enable_newreno, "Disable new reno fast recovery"}, {OPT_TRUE, "nrena", (char *)&enable_newreno, "Enable new reno fast recovery"}, {OPT_TRUE, "sackdis", (char *)&no_sack, "Disable SACKs for all connections"}, {OPT_FALSE, "sackena", (char *)&no_sack, "Enable SACKs for all connections"}, {OPT_TRUE, "largemssena", (char *)&enable_large_mss, "Enable advertisement of a large MSS"}, {OPT_FALSE, "largemssdis", (char *)&enable_large_mss, "Disable advertisement of a large MSS"}, }; main(int argc, char *argv[]) { int fd, j; struct protoent *proto; proto = getprotobyname("tcp"); Opt_Parse (argc, argv, optionArray, Opt_Number(optionArray), 0); printf("NOSACK %d\n", no_sack); fd = socket(AF_INET, SOCK_STREAM, proto->p_proto); j = sizeof(int); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB0,(char *)&te0,&j) < 0) perror("e0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB1,(char *)&te1,&j) < 0) perror("e1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS0,(char *)&tt0,&j) < 0) perror("t0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS1,(char *)&tt1,&j) < 0) perror("t1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BER_MODEL,(char *)&tm,&j) < 0) perror("m"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_TIMERGRAN,(char *)&tg,&j) < 0) perror("g"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_BURSTRATE,(char *)&tb,&j) < 0) perror("b"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_BER_DISABLE,(char *)&tdisable_ber,&j) < 0) perror("disable/enable ber"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_LINKEMU_ENABLE,(char *)&tenable_linkemu,&j) < 0) perror("disable/enable linkemu"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_DISABLE, (char *)&tdisable_snoop, &j) < 0) perror("disable/enable snoop"); if (getsockopt(fd, proto->p_proto, TCP_ELN_ENABLE,(char *)&tenable_eln,&j) < 0) perror("disable/enable ELN"); if (getsockopt(fd, proto->p_proto, TCP_ELN_THRESH,(char *)&teln_thresh,&j) < 0) perror("ELN threshold"); if (getsockopt(fd, proto->p_proto, TCP_ELN_ORDER,(char *)&teln_order,&j) < 0) perror("ELN ordering"); if (getsockopt(fd, proto->p_proto, TCP_ER_ALLCONNS,(char *)&tenable_er,&j) < 0) perror("disable/enable ER"); if (getsockopt(fd, proto->p_proto, TCP_PERFECT_ELN_ENABLE,(char *)&tenable_peln,&j) < 0) perror("disable/enable perfect ELN"); if (getsockopt(fd, proto->p_proto, TCP_SNOOP_REXMT_DISABLE,(char *)&tdisable_snooprexmt,&j)<0) perror("disable/enable snoop/local retransmission"); if (getsockopt(fd, proto->p_proto, TCP_SMART_ENABLE,(char *)&tenable_smart,&j) < 0) perror("disable/enable SMART"); if (getsockopt(fd, proto->p_proto, TCP_SMART_SNOOP_ENABLE, (char *)&tenable_snoop_smart,&j)<0) perror("disable/enable Snoop+SMART"); if (getsockopt(fd, proto->p_proto, TCP_NEWRENO_ENABLE, (char *)&tenable_newreno,&j) < 0) perror("disable/enable new reno"); if (getsockopt(fd, proto->p_proto, TCP_DO_SACK, (char *)&tno_sack, &j) < 0) perror("disable/enable SACKs for all connections"); if (getsockopt(fd, proto->p_proto, TCP_ADVT_LARGE_MSS, (char *)&tenable_large_mss,&j) < 0) perror("disable/enable advertisement of large MSS"); printf("INITIAL:\ne0 %d\ne1 %d\nt0 %d\nt1 %d\nm %d\ng %d\nb %d\ndisable_ber %d\nenable_linkemu %d\ndisable_snoop %d\nenable_eln %d\neln thresh %d\neln order %d\nenable_er %d\nenable_peln %d\ndisable_snooprexmt %d\nenable_smart %d\nenable_snoop_smart %d\nenable_newreno %d\nno_sack %d\nenable large mss advt %d\n\n", te0, te1, tt0, tt1, tm, tg, tb, tdisable_ber, tenable_linkemu, tdisable_snoop, tenable_eln, teln_thresh, teln_order, tenable_er, tenable_peln, tdisable_snooprexmt, tenable_smart, tenable_snoop_smart, tenable_newreno, tno_sack, tenable_large_mss); j = sizeof(int); if (e0!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB0,(char *)&e0,j) < 0) perror("e0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB0,(char *)&te0,&j) < 0) perror("e0"); if (e0 != te0) printf("e0 != te0"); } j = sizeof(int); if (e1!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB1,(char *)&e1,j) < 0) perror("e1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB1,(char *)&te1,&j) < 0) perror("e1"); if (e1 != te1) printf("e1 != te1"); } j = sizeof(int); if (t0!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS0,(char *)&t0,j) < 0) perror("t0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS0,(char *)&tt0,&j) < 0) perror("t0"); if (t0 != tt0) printf("t0 != tt0"); } j = sizeof(int); if (t1!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS1,(char *)&t1,j) < 0) perror("t1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS1,(char *)&tt1,&j) < 0) perror("t1"); if (t1 != tt1) printf("t1 != tt1"); } j = sizeof(int); if (m!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_BER_MODEL,(char *)&m,j) < 0) perror("m"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BER_MODEL,(char *)&tm,&j) < 0) perror("m"); if (m != tm) printf("m != tm"); } j = sizeof(int); if (g!=-1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_TIMERGRAN,(char *)&g,j) < 0) perror("g"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TIMERGRAN,(char *)&tg,&j) < 0) perror("g"); if (g != tg) printf("g != tg"); } j = sizeof(int); if (b != -1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_BURSTRATE,(char *)&b,j) < 0) perror("b"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BURSTRATE,(char *)&tb,&j) < 0) perror("g"); if (b != tb) printf("b != tb"); } j = sizeof(int); if (disable_ber != -1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_BER_DISABLE,(char *)&disable_ber,j) < 0) perror("disable/enable ber"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BER_DISABLE,(char *)&tdisable_ber,&j) < 0) perror("disable/enable ber"); if (disable_ber != tdisable_ber) printf("disable_ber != tdisable_ber"); } j = sizeof(int); if (enable_linkemu != -1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_LINKEMU_ENABLE,(char *)&enable_linkemu,j) < 0) perror("disable/enable linkemu"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_LINKEMU_ENABLE,(char *)&tenable_linkemu,&j) < 0) perror("disable/enable linkemu"); if (enable_linkemu != tenable_linkemu) printf("enable_linkemu != tenable_linkemu"); } j = sizeof(int); if (disable_snoop != -1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_DISABLE,(char *)&disable_snoop,j) < 0) perror("disable/enable snoop"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_DISABLE,(char *)&tdisable_snoop,&j) < 0) perror("disable/enable snoop"); if (disable_snoop != tdisable_snoop) printf("disable_snoop != tdisable_snoop"); } j = sizeof(int); if (enable_eln != -1) { if (setsockopt(fd,proto->p_proto, TCP_ELN_ENABLE,(char *)&enable_eln,j) < 0) perror("disable/enable ELN"); if (getsockopt(fd,proto->p_proto, TCP_ELN_ENABLE,(char *)&tenable_eln,&j) < 0) perror("disable/enable ELN"); if (enable_eln != tenable_eln) printf("enable_eln != tenable_eln"); } j = sizeof(int); if (eln_thresh != -1) { if (setsockopt(fd,proto->p_proto, TCP_ELN_THRESH,(char *)&eln_thresh,j) < 0) perror("ELN thresh"); if (getsockopt(fd,proto->p_proto, TCP_ELN_THRESH,(char *)&teln_thresh,&j) < 0) perror("ELN thresh"); if (eln_thresh != teln_thresh) printf("eln_thresh != teln_thresh"); } j = sizeof(int); if (enable_eln != -1) { if (setsockopt(fd,proto->p_proto, TCP_ELN_ORDER,(char *)&eln_order,j) < 0) perror("ELN order"); if (getsockopt(fd,proto->p_proto, TCP_ELN_ORDER,(char *)&teln_order,&j) < 0) perror("disable/enable ELN"); if (eln_order != teln_order) printf("eln_thresh != teln_thresh"); } j = sizeof(int); if (enable_er != -1) { if (setsockopt(fd,proto->p_proto, TCP_ER_ALLCONNS,(char *)&enable_er,j) < 0) perror("disable/enable ER"); if (getsockopt(fd,proto->p_proto, TCP_ER_ALLCONNS,(char *)&tenable_er,&j) < 0) perror("disable/enable ER"); if (enable_er != tenable_er) printf("enable_er != tenable_er"); } j = sizeof(int); if (enable_peln != -1) { if (setsockopt(fd,proto->p_proto, TCP_PERFECT_ELN_ENABLE,(char *)&enable_peln,j) < 0) perror("disable/enable perfect ELN"); if (getsockopt(fd,proto->p_proto, TCP_PERFECT_ELN_ENABLE,(char *)&tenable_peln,&j) < 0) perror("disable/enable perfect ELN"); if (enable_peln != tenable_peln) printf("enable_peln != tenable_peln"); } j = sizeof(int); if (disable_snooprexmt != -1) { if (setsockopt(fd,proto->p_proto, TCP_SNOOP_REXMT_DISABLE,(char *)&disable_snooprexmt,j) < 0) perror("disable/enable snoop/local retransmission"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_REXMT_DISABLE,(char *)&tdisable_snooprexmt,&j) < 0) perror("disable/enable snoop/local retransmission"); if (disable_snooprexmt != tdisable_snooprexmt) printf("disable_snooprexmt != tdisable_snooprexmt"); } j = sizeof(int); if (enable_smart != -1) { if (setsockopt(fd,proto->p_proto, TCP_SMART_ENABLE,(char *)&enable_smart,j) < 0) perror("disable/enable SMART"); if (getsockopt(fd,proto->p_proto, TCP_SMART_ENABLE,(char *)&tenable_smart,&j) < 0) perror("disable/enable SMART"); if (enable_smart != tenable_smart) printf("enable_smart != tenable_smart"); } j = sizeof(int); if (enable_snoop_smart != -1) { if (setsockopt(fd,proto->p_proto, TCP_SMART_SNOOP_ENABLE,(char *)&enable_snoop_smart,j) < 0) perror("disable/enable SMART"); if (getsockopt(fd,proto->p_proto, TCP_SMART_SNOOP_ENABLE,(char *)&tenable_snoop_smart,&j) < 0) perror("disable/enable Snoop+SMART"); if (enable_snoop_smart != tenable_snoop_smart) printf("enable_snoop_smart != tenable_snoop_smart"); } j = sizeof(int); if (enable_newreno != -1) { if (setsockopt(fd, proto->p_proto, TCP_NEWRENO_ENABLE, (char *)&enable_newreno, j) < 0) perror("disable/enable new reno"); if (getsockopt(fd,proto->p_proto, TCP_NEWRENO_ENABLE,(char *)&tenable_newreno,&j) < 0) perror("disable/enable new reno"); if (enable_newreno != tenable_newreno) printf("enable_newreno != tenable_newreno"); } j = sizeof(int); if (no_sack != -1) { if (setsockopt(fd, proto->p_proto, TCP_DO_SACK, (char *)&no_sack, j) < 0) perror("disable/enable SACKs for all connections"); if (getsockopt(fd, proto->p_proto, TCP_DO_SACK, (char *)&tno_sack, &j) < 0) perror("disable/enable SACK for all connections"); if (no_sack != tno_sack) printf("no_sack != tno_sack"); } j = sizeof(int); if (enable_large_mss != -1) { if (setsockopt(fd,proto->p_proto, TCP_ADVT_LARGE_MSS,(char *)&enable_large_mss,j) < 0) perror("disable/enable advertisement of large mss"); if (getsockopt(fd,proto->p_proto, TCP_ADVT_LARGE_MSS,(char *)&tenable_large_mss,&j) < 0) perror("disable/enable advertisement of large mss"); if (enable_large_mss != tenable_large_mss) printf("enable_large_mss != tenable_large_mss"); } if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB0,(char *)&te0,&j) < 0) perror("e0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_ERRPROB1,(char *)&te1,&j) < 0) perror("e1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS0,(char *)&tt0,&j) < 0) perror("t0"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TRANS1,(char *)&tt1,&j) < 0) perror("t1"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BER_MODEL,(char *)&tm,&j) < 0) perror("m"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_TIMERGRAN,(char *)&tg,&j) < 0) perror("g"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BURSTRATE,(char *)&tb,&j) < 0) perror("b"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_BER_DISABLE,(char *)&tdisable_ber,&j) < 0) perror("disable ber"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_LINKEMU_ENABLE,(char *)&tenable_linkemu,&j) < 0) perror("enable linkemu"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_DISABLE,(char *)&tdisable_snoop,&j) < 0) perror("disable snoop"); if (getsockopt(fd,proto->p_proto, TCP_ELN_ENABLE,(char *)&tenable_eln,&j) < 0) perror("enable ELN"); if (getsockopt(fd,proto->p_proto, TCP_PERFECT_ELN_ENABLE,(char *)&tenable_peln,&j) < 0) perror("enable perfect ELN"); if (getsockopt(fd,proto->p_proto, TCP_SNOOP_REXMT_DISABLE,(char *)&tdisable_snooprexmt,&j) < 0) perror("disable snoop/local retransmission"); if (getsockopt(fd,proto->p_proto, TCP_SMART_ENABLE,(char *)&tenable_smart,&j) < 0) perror("enable SMART"); if (getsockopt(fd,proto->p_proto, TCP_ADVT_LARGE_MSS,(char *)&tenable_large_mss,&j) < 0) perror("enable ADVT_LARGE_MSS"); printf("\nFINAL:\ne0 %d\ne1 %d\nt0 %d\nt1 %d\nm %d\ng %d\nb %d\ndisable_ber %d\nenable_linkemu %d\ndisable_snoop %d\nenable_eln %d\neln_thresh %d\neln_order %d\nenable_er %d\nenable_peln %d\ndisable_snooprexmt %d\nenable_smart %d\nenable_snoop_smart %d\nenable_newreno %d\nno_sack %d\nenable_large_mss %d\n", te0, te1, tt0, tt1, tm, tg, tb, tdisable_ber, tenable_linkemu, tdisable_snoop, tenable_eln, teln_thresh, teln_order, tenable_er, tenable_peln, tdisable_snooprexmt, tenable_smart, tenable_snoop_smart, tenable_newreno, tno_sack, tenable_large_mss); }