TTCP.C - Test TCP connection and network transfering / Dec 2007
Command Manual
Usage: ttcp -t [-options] host [ < in ]
       ttcp -r [-options] [multicast-group][ > out]
Common options:
        -4      use IPv4
        -6      use IPv6
        -l ##   length of bufs read from or written to network (default 8192)
        -u      use UDP instead of TCP
        -p ##   port number to send to or listen at (default 5001)
        -s      -t: source a pattern to network
                -r: sink (discard) all data from network
        -A ##   align the start of buffers to this modulus (default 16384)
        -O ##   start buffers at this offset from the modulus (default 0)
        -v      verbose: print more statistics
        -d      set SO_DEBUG socket option
        -b ##   set socket buffer size (if supported)
        -f X    format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga
Options specific to -t:
        -n ##   number of source bufs written to network (default 2048)
        -D      don't buffer TCP writes (sets TCP_NODELAY socket option)
        -w ##   number of microseconds to wait between each write
Options specific to -r:
        -B      for -s, only output full blocks as specified by -l (for TAR)
        -T      "touch": access each byte as it's read
        -I if   Specify the network interface (e.g. eth0) to use
% make
% gcc -O3 ttcp.c -o ttcp
Example(How to use)
1. Run ttcp at reciever PC to wait data.
# ./ttcp -v -r -f g > /dev/null
ttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001  tcp
ttcp-r: socket
2. Run ttcp at sender PC and send data to reciever PC.
# ./ttcp -v -t [reciever PC] < /dev/zero
ttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001  tcp  -> [reciever PC]
ttcp-t: socket
ttcp-t: connect
3. Stop ttcp at sender PC with Ctrl-C key, and then results show at reciever PC.
ttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001  tcp
ttcp-r: socket
ttcp-r: accept from [sender PC]
ttcp-r: 20529432056 bytes in 89.58 real seconds = 1.71 Gbit/sec +++
ttcp-r: 20529432056 bytes in 54.41 CPU seconds = 2.81 Gbit/cpu sec
ttcp-r: 2755866 I/O calls, msec/call = 0.03, calls/sec = 30763.32
ttcp-r: 0.8user 53.5sys 1:29real 60% 0i+0d 440maxrss 0+2pf 684792+7493csw
ttcp-r: buffer address 0xf20000