Common subdirectories: tcptrace.6.0.1/CVS and tcptrace.6.0.1-new/CVS Common subdirectories: tcptrace.6.0.1/flex_bison and tcptrace.6.0.1-new/flex_bison Common subdirectories: tcptrace.6.0.1/input and tcptrace.6.0.1-new/input diff -u --exclude=Makefile -u tcptrace.6.0.1/ns.c tcptrace.6.0.1-new/ns.c --- tcptrace.6.0.1/ns.c Mon Sep 17 10:51:34 2001 +++ tcptrace.6.0.1-new/ns.c Sun Jul 7 14:25:18 2002 @@ -112,8 +112,10 @@ ++linenum; - /* correct NS output line would have 14 fields: */ - rlen = fscanf(stdin, "%c %lg %d %d %s %d %s %d %d.%hu %d.%hu %d %hu\n", + /* correct NS output line would have 14 fields if show_tcphdr_ is 0: */ + /* For Full TCP this changes to 18 fields when show_tcp is 1*/ + rlen = fscanf(stdin, "%c %lg %d %d %s %d %s %d %d.%hu %d.%hu %d %hu %d 0x%x %d + %d \n", &tt, ×tamp, &junk, @@ -127,15 +129,19 @@ &ipb->ip_dst.s_addr, &tcpb->th_dport, &seq, - &ipb->ip_id); + &ipb->ip_id, + &junk, /*don't care since it is not FullTCP */ + &junk, + &junk, + &junk); - /* if we can't match all 14 fields, we give up on the file */ - if (rlen != 14) { - fprintf(stderr,"Bad ns packet header in line %u\n", linenum); + /* if we reach the End Of File we stop */ + if (rlen == EOF) { return(0); } - - if (rlen == EOF) { + /* if we can't match all 14 fields, we give up on the file */ + if (rlen != 14 && rlen != 18) { + fprintf(stderr,"Bad NS packet header in line %u only [%d] arguments can be matched expected 14 or 18 \n", linenum, rlen); return(0); } @@ -147,10 +153,19 @@ /* if it's not a TCP data segment or ACK, discard and try again */ if (!is_tcp && !is_ack) continue; - + + if ((!ns_hdrs && is_tcp) || (ns_hdrs && packlen ==0)) + *plen = *plen + sizeof(struct ip) + sizeof(struct tcphdr); + if (packlen == 0 && is_tcp) - packlen = *plen - sizeof(struct ip) - sizeof(struct tcphdr); - + packlen = *plen - sizeof(struct ip) - sizeof(struct tcphdr); + + if (ns_hdrs && is_tcp) + packlen = *plen- sizeof(struct ip) - sizeof(struct tcphdr); + + if (is_ack) /* this is explicitly for SACK that creates packets > 40 Bytes*/ + *plen = 40; + ipb->ip_len = htons(*plen); if (is_tcp) { @@ -201,7 +216,7 @@ e = d * 1000000.0; ptime->tv_usec = e; - *ptlen = *plen; + *ptlen = *plen; *ppip = (struct ip *) pip_buf; *pplast = (char *)pip_buf + *plen; @@ -217,6 +232,147 @@ } } +pread_ns_fulltcp( + struct timeval *ptime, + int *plen, + int *ptlen, + void **pphys, + int *pphystype, + struct ip **ppip, + void **pplast) +{ + double c, d, e; + while (1) { + /* read the packet info */ + + char tt; + double timestamp; + int junk; + char type[100]; + char flags[100]; + int iteration; + int seqno; + int ackno; + int hdrlen; + int is_ack; + int is_tcp; + int pflags; + int rlen; + + ++linenum; + + /* correct NS output line would have 14 fields if show_tcphdr_ is 0: */ + /* For Full TCP this changes to 18 fields when show_tcp is 1*/ + rlen = fscanf(stdin, "%c %lg %d %d %s %d %s %d %d.%hu %d.%hu %d %d %d 0x%x %u %hu\n", + &tt, + ×tamp, + &junk, + &junk, + type, + plen, + flags, + &iteration, + &ipb->ip_src.s_addr, + &tcpb->th_sport, + &ipb->ip_dst.s_addr, + &tcpb->th_dport, + &seqno, + &ipb->ip_id, + &ackno, + &pflags, + &hdrlen, + &junk); + + /* if we reach the End of File we stop */ + if (rlen == EOF) { + return(0); + } + /* if we can't match all 18 fields, we give up on the file */ + if (rlen != 18) { + fprintf(stderr,"Bad NS packet header in line %u only [%d] arguments can be matched expected 14 or 18 \n", linenum, rlen); + fprintf(stderr,"Is this a Full Tcp Header?\n"); + return(0); + } + + tcpb->th_sport = tcpb->th_dport = iteration; + is_tcp = strcmp(type, "tcp") == 0; + is_ack = strcmp(type, "ack") == 0; + + /* if it's not a TCP data segment or ACK, discard and try again */ + if (!is_tcp && !is_ack) + continue; + + /* we have biger header than 40 Bytes (SACK?) */ + if (hdrlen > sizeof(struct ip) + sizeof(struct tcphdr)){ + *plen = *plen - (hdrlen - (sizeof(struct ip) - sizeof(struct tcphdr))); + } + + ipb->ip_len = htons(*plen); + + if (is_tcp && (*plen > hdrlen)) { /*for empty tcp packets acting as acks*/ + tcpb->th_seq = htonl(seqno); + tcpb->th_ack = 0; + } else { + tcpb->th_seq = 0; + tcpb->th_ack = htonl(ackno); + } + + /* make up a reasonable IPv4 packet header */ + ipb->ip_hl = 5; /* no options, normal length of 20 */ + ipb->ip_v = 4; /* IPv4 */ + ipb->ip_tos = 0; + ipb->ip_off = 0; + ipb->ip_ttl = 64; /* nice round number */ + ipb->ip_p = 6; /* TCP */ + ipb->ip_sum = 0; /* IP checksum, hope it doesn't get checked! */ + ipb->ip_id = ipb->ip_id; + + /* is the transport "ECN-Capable"? */ + if (strchr(flags, 'N') != NULL) + ipb->ip_tos |= IPTOS_ECT; + + /* was the "Experienced Congestion" bit set? */ + if (strchr(flags, 'E') != NULL) + ipb->ip_tos |= IPTOS_CE; + + /* make up a reasonable TCP segment header */ + tcpb->th_off = 5; /* no options, normal length of 20 */ + tcpb->th_flags = pflags; /* sdo: what about first SYN?? */ + tcpb->th_x2 = 0; + tcpb->th_sum = 0; + tcpb->th_urp = 0; + tcpb->th_win = htons(65535); + + /* x2 *was* reserved, now used for ECN bits */ + + if (strchr(flags, 'C') != NULL) + tcpb->th_x2 |= TH_ECN_ECHO; + if (strchr(flags, 'A') != NULL) + tcpb->th_x2 |= TH_CWR; + + /* convert floating point timestamp to (tv_sec,tv_usec) */ + c = floor(timestamp); + ptime->tv_sec = c; + d = timestamp - (double) ptime->tv_sec; + e = d * 1000000.0; + ptime->tv_usec = e; + + *ptlen = *plen; + + *ppip = (struct ip *) pip_buf; + *pplast = (char *)pip_buf + *plen; + *pphys = pep; + *pphystype = PHYS_ETHER; + + +/* printf("timestamp %g, type %s, plen %d, seq %d, id %d, ack %d, 0x%x %d \n", + timestamp, type, *plen, seqno, ipb->ip_id,ackno,pflags,hdrlen);*/ + + + return(1); + } +return(0); +} /* @@ -224,16 +380,41 @@ */ pread_f *is_ns(void) { - int rlen; + int rlen; + char tt; + int junk; + double junkd; + char junks[20]; + int hdrlen = 0; + int pflags = 0; + /* I check the first character and the flags the flags and hdrlen */ + rlen = fscanf(stdin, + "%c %lg %d %d %s %d %s %d %d.%hu %d.%hu %d %d %d 0x%x %u %hu\n", + &tt, + &junkd, + &junk, + &junks, + &junk, + &junks, + &junk, + &junk, + &junk, + &junk, + &junk, + &junk, + &junk, + &junk, + &junk, + &pflags, + &hdrlen, + &junk); - if ((rlen = getc(stdin)) == EOF) { rewind(stdin); + if ((rlen = getc(stdin)) == EOF) { return(NULL); } - rewind(stdin); - - switch (rlen) { + switch (tt) { case '+': case '-': case 'h': @@ -256,7 +437,13 @@ /* init line count (we might be called several times, must be done here) */ linenum = 0; - - return(pread_ns); + /* Lets check if it is FullTCP or not*/ + if (hdrlen || pflags){ /*it is FullTCP */ +/* printf("Full TCP \n"); */ + return(pread_ns_fulltcp); + } + else{ /*Regular TCP (with or without tcpheaders activated */ + return(pread_ns); + } } #endif /* GROK_NS */ Common subdirectories: tcptrace.6.0.1/output_finger.snoop.gz and tcptrace.6.0.1-new/output_finger.snoop.gz diff -u --exclude=Makefile -u tcptrace.6.0.1/tcptrace.c tcptrace.6.0.1-new/tcptrace.c --- tcptrace.6.0.1/tcptrace.c Mon Dec 3 07:58:49 2001 +++ tcptrace.6.0.1-new/tcptrace.c Sun Jul 7 14:25:26 2002 @@ -137,6 +137,7 @@ Bool run_continuously = FALSE; Bool xplot_all_files = FALSE; Bool conn_num_threshold = FALSE; +Bool ns_hdrs = TRUE; u_long remove_live_conn_interval = REMOVE_LIVE_CONN_INTERVAL; u_long remove_closed_conn_interval = REMOVE_CLOSED_CONN_INTERVAL; u_long update_interval = UPDATE_INTERVAL; @@ -244,7 +245,9 @@ "limit the maximum number of connections kept at a time in real-time mode"}, {"xplot_all_files", &xplot_all_files, TRUE, "display all generated xplot files at the end"}, - + {"ns_hdrs", &ns_hdrs, TRUE, + "assume that ns has the useHeaders_ flag true (uses IP+TCP headers)"}, + }; #define NUM_EXTENDED_BOOLS (sizeof(extended_bools) / sizeof(struct ext_bool_op)) @@ -1997,9 +2000,10 @@ fprintf(stderr,"beginning pnum: %lu\n", beginpnum); fprintf(stderr,"ending pnum: %lu\n", endpnum); fprintf(stderr,"throughput intvl: %d\n", thru_interval); - fprintf(stderr,"number modules: %u\n", (unsigned)NUM_MODULES); + fprintf(stderr,"NS simulator hdrs:%u\n", BOOL2STR(ns_hdrs)); + fprintf(stderr,"number modules: %u\n", (unsigned)NUM_MODULES); fprintf(stderr,"debug: %s\n", BOOL2STR(debug)); - + /* print out the stuff controlled by the extended boolean args */ for (i=0; i < NUM_EXTENDED_BOOLS; ++i) { struct ext_bool_op *pbop = &extended_bools[i]; diff -u --exclude=Makefile -u tcptrace.6.0.1/tcptrace.h tcptrace.6.0.1-new/tcptrace.h --- tcptrace.6.0.1/tcptrace.h Mon Dec 3 07:58:50 2001 +++ tcptrace.6.0.1-new/tcptrace.h Sun Jul 7 14:25:24 2002 @@ -667,6 +667,7 @@ extern Bool run_continuously; extern Bool conn_num_threshold; extern Bool xplot_all_files; +extern Bool ns_hdrs; extern u_long remove_live_conn_interval; extern u_long remove_closed_conn_interval; extern u_long update_interval;