Changeset 1880

Show
Ignore:
Timestamp:
07/18/07 20:52:55 (16 months ago)
Author:
aturner
Message:

commit work in progress. this doesn't seem to actually work though. :(
Anyways, this just commits my work up to this point, but at some point it's
going to need to be reworked. refs #41

Location:
features/performance/src
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • features/performance/src/common.h

    r1757 r1880  
    1616#include "common/utils.h" 
    1717#include "common/xX.h" 
     18#include "common/rdtsc.h" 
    1819#include "common/tcpdump.h" 
    1920#include "common/timer.h" 
  • features/performance/src/common/Makefile.am

    r1809 r1880  
    1515                      fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c \ 
    1616                      timer.c svn_version.c abort.c sendpacket.c \ 
    17                           dlt_names.c mac.c interface.c 
     17                          dlt_names.c mac.c interface.c rdtsc.c 
    1818 
    1919if ENABLE_TCPDUMP 
     
    2828                 fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \ 
    2929                 tcpdump.h timer.h abort.h pcap_dlt.h sendpacket.h \ 
    30                  dlt_names.h mac.h interface.h 
     30                 dlt_names.h mac.h interface.h rdtsc.h 
    3131 
    3232MOSTLYCLEANFILES = *~ 
  • features/performance/src/common/timer.h

    r1854 r1880  
    122122        } while(0) 
    123123 
    124  
    125 /* device tvp by x.  store in tvp */ 
    126 #define timerdiv2(tvp, x)                                               \ 
    127         do {                                                                    \ 
    128                 (tvp)->tv_sec = (tvp)->tv_sec / x;              \ 
    129                 (tvp)->tv_usec = (tvp)->tv_usec / x;    \ 
    130         } while(0) 
    131  
    132124#endif 
    133  
  • features/performance/src/send_packets.c

    r1874 r1880  
    326326    static u_int32_t send = 0;      /* remember # of packets to send btw calls */ 
    327327    u_int32_t loop; 
     328    u_int64_t loop2; 
    328329 
    329330    /* just return if topspeed */ 
     
    447448    } 
    448449 
    449     if (!accurate) { 
     450 
     451    if (accurate == 2) { 
     452        loop2 = rdtsc_sleep(nap); 
     453        //fprintf(stderr, "rdtsc slept for %llu clicks\n", loop2); 
     454        dbgx(3, "rdtsc slept for  %llu times", loop); 
     455    } else if (accurate == 1) {  
     456        /* gettimeofday() loop */ 
     457        timeradd(&now, &nap, &delta); 
     458        loop = sleep_loop(delta); 
     459        dbgx(3, "sleep_loop looped %u times", loop);     
     460    } else { 
    450461        timeradd(&didsleep, &nap, &didsleep); 
    451462 
     
    465476            } 
    466477        } 
    467     } else { 
    468         timeradd(&now, &nap, &delta); 
    469         loop = sleep_loop(delta); 
    470         dbgx(3, "sleep_loop looped %u times", loop); 
    471478    } 
    472479#ifdef DEBUG 
  • features/performance/src/tcpprep.c

    r1846 r1880  
    421421                      check_dst_port(ip_hdr, (pkthdr.caplen - l2len))); 
    422422            break; 
     423             
     424        default: 
     425            errx(1, "Whops!  What mode are we in anyways? %d", options.mode); 
    423426        } 
    424427#ifdef ENABLE_VERBOSE 
  • features/performance/src/tcpreplay.c

    r1839 r1880  
    286286        warn("not configured with --enable-debug.  Debugging disabled."); 
    287287#endif 
    288      
     288         
    289289    options.loop = OPT_VALUE_LOOP; 
    290290 
     
    328328    if (HAVE_OPT(ACCURATE)) 
    329329        options.accurate = 1; 
    330          
     330     
     331    if (HAVE_OPT(ACCURATE2)) { 
     332        options.accurate = 2; 
     333        rdtsc_calibrate(); 
     334    } 
     335 
    331336    if (HAVE_OPT(PKTLEN)) 
    332337        warn("--pktlen may cause problems.  Use with caution."); 
  • features/performance/src/tcpreplay_opts.def

    r1876 r1880  
    131131    max         = 1; 
    132132    flags-cant  = accurate; 
    133     arg-type    = number; 
    134133    descrip     = "Enable even more accurate packet timing"; 
    135134    doc         = <<- EOText 
    136135Enables the "even more" accurate timing at the cost of higher CPU 
    137 utilization by using a tight loop which increments a counter.   This method 
    138 provides the most accurate timing of any option, but requires you to specify 
    139 a cost for each loop.  This cost value is VERY system dependent, so you will 
    140 need to run --loop-test to get this value. 
     136utilization by using the RDTSC counter available on newer CPU's. 
     137Only works on more recent x86, x86_64 and PPC 
    141138EOText; 
    142139};