ttcpw95

Upload: adam-urassa

Post on 07-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 ttcpw95

    1/9

  • 8/6/2019 ttcpw95

    2/9

    ABSTRACT

    This paper outlines the Windows NT/95 port of TTCP. It includes portingissues, an example session, and instructions on how to compile and install theprogram. Appendix A includes the complete original manual for TTCP.

    TABLE OF CON TENTS

    Abstract...............................................................................................................1

    Table of contents.................................................................................................1

    Introduction.........................................................................................................1

    Porting Issues and solutions................................................................................2

    Sockets................................................................................................................2

    Timing..................................................................................................................3

    ERRATA................................................................................................................3

    Example runs.......................................................................................................3

    Installation...........................................................................................................4

    Compilation.........................................................................................................4

    Appendix A..........................................................................................................5

    Original TTCP documentation..............................................................................5

    Bibliography.........................................................................................................8

    INTRODUCTION

    TTCPW is a port of TTCP, designed to run on the Windows NT/95 platforms. Itis designed to keep the source code as similar to the original program aspossible. As such, I made as few changes as practical. These changes includedadding Win32 specific functions, changing existing calls, and replacing the codethat does the timing. (I decided to strip out the UNIX timing code rather than

    .

  • 8/6/2019 ttcpw95

    3/9

    #ifdef it because it would have required a large number of #ifdef statements tomodify it for Win32 usage.) The positive side of this is code that is much closer toANSIit would be very easy to modify this code to compile and run in UNIX. Onthe negative side, the timing functions do not contain near the levels ofgranularity that was contained in the UNIX code (milliseconds rather thanmicroseconds).

    PORTING ISSUES AND SOLUTIONS

    There were a number of issues involved in porting TTCP to the Windowsenvironment. First and foremost were the issues surrounding differencesbetween BSD sockets (the sockets used in the UNIX environment) and Windowssockets.

    SOCKETS

    Microsoft has implemented several functions specific to their operating

    systems. Two of these functions, WSAStartup() and WSACleanup(), must becalled by any application using sockets. WSAStartup() initializes the Windowssocket dynamic link library. An application calls WSACleanup() when it is finishedusing sockets. These functions were added to TTCP at the top and bottom of themain() function.

    TCP data transfer under Berkeley sockets is performed with the general-purpose I/O functions read() and write(). In Windows Microsoft chose toimplement two socket specific data transfer functions: recv() and send(). Thereason is because of the way Windows sockets are implemented. The call tosocket() under BSD returns an int which can, in many ways, be treated as a filehandle. The same call in Windows returns a socket handle (data type SOCKET).

    This socket handle is not in any way compatible with the file system. Thefollowing table shows the similarity between the Windows functions and the BSDfunctions.

    BSD function Windows function

    int write(socket_handle, buffer, count); int send(socket_handle, buffer, count, flag);

    int read(socket_handle, buffer,buffer_size);

    int recv(socket_handle, buffer, buffer_size,flag);

    As you can see, the only major difference between the two is an extra, rarelyused flag parameter at the end of the Windows calls. BSD sockets closes socketswith the close() function. Again, since Windows sockets are not implemented asfile handles they have implemented a separate function closesocket() to performthis task.

  • 8/6/2019 ttcpw95

    4/9

    TIMING

    UNIX has a variety of timing functions available which provide clock counts allthe way down to the microsecond. In contrast, Windows has but a few. Only oneof these functions provide a resolution below one second: the clock() function.

    This is an ANSI compatible function which returns the number of milliseconds

    since the computer was turned on. All of the UNIX timing function calls werereworked to work with this single function. So while the timing routines are nowANSI compatible, they do not contain the level of accuracy that the original timingfunctions contain.

    ERRATA

    1. The rest of the porting issues were concerned with minor differencesbetween the UNIX and Windows run-time libraries. The read() and write() callsused to read and write to STDIN and STDOUT were replaced with _read() and

    _write(), the Microsoft implementations of the same functions. Also bzero(),was replaced with the ANSI compatible function memset().

    EXAMPLE RUNS

    TTCPW is run exactly as TTCP with two exceptions:

    1. The verbose option (-v) does not work in the Windows implementation. This is simply due to the lack of timing functions available under thatoperating system.

    2. TTCPW has a new option to display ATM packet performance data (-M).

    The figures below show TTCPW being run in various modes against anotherversion of TTCP running on a UNIX machine. Examples are given for TCP (figure1), UDP (figure 2) and interactive (figure 3).

    Figure 1:TCP

    Figure 2: UDP Run

    Windows95:

    A:\>ttcpw -t -s renoir.csc.ncsu.eduttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp -> renoir.csc.ncsu.eduttcp-t: socketttcp-t: connectttcp-t: 16777216 bytes in 216.52 seconds = 75.67 KB/sec +++ttcp-t: 2048 I/O calls, msec/call = 108.26, calls/sec = 9.46ttcp-t:

    UNIX:

    % ttcpatm3 -r -sttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcpttcp-r: socketttcp-r: accept from 152.1.57.94ttcp-r: 16777216 bytes (2048 nbufs) in 252.30 real seconds = 64.94 KB/sec +++ttcp-r: Which is at least 351232.0 ATM cells or 0.59 Mbits/sec at adapter levelttcp-r: 10346 I/O calls, msec/call = 24.97, calls/sec = 41.01ttcp-r: 0.1user 1.2sys 4:12real 0% 1i+7d 152maxrss 0+2pf 10214+0csw

    Windows95:

    A:\>ttcpw -t -s -b256 -n50 -u -M renoir.csc.ncsu.eduttcp-t: buflen=8192, nbuf=50, align=16384/0, port=5001, sockbufsize=256 udp ->renoir.csc.ncsu.edu

    ttcp-t: socket

    ttcp-t: sndbufttcp-t: 409600 bytes in 0.65 seconds = 615.38 KB/sec +++ttcp-t: Which is at least 8532.8 ATM cells or 5.57 Mbits/sec at adapter levelttcp-t: 56 I/O calls, msec/call = 11.89, calls/sec = 86.15ttcp-t:UNIX:

    % ttcpatm3 -r -s -uttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001 udpttcp-r: socketttcp-r: 352256 bytes (2048 nbufs) in 0.67 real seconds = 510.50 KB/sec +++ttcp-r: Which is at least 8533.3 ATM cells or 5.37 Mbits/sec at adapter levelttcp-r: 45 I/O calls, msec/call = 15.33, calls/sec = 66.78

    ttcp-r: 0.0user 0.0sys 0:00real 0% 0i+0d 150maxrss 0+1pf 43+0csw

  • 8/6/2019 ttcpw95

    5/9

    Figure 3:Interactive

    INSTALLATION

    TTCPWrequiresWindowsNT/95 (or later)to run. It willnot run underWindows 3.1includingWindows forWorkGroups.

    There are nospecial

    installationinstructions.

    You may runthe programfrom any diskor directory

    from a DOS window. It was tested using the Microsoft TCP/IP stack provided withWindows95. It has not been tested under NT or any other TCP/IP stack. WindowsNT should not present any problem whatsoever. It should have no problemsrunning with any version of WinSock complying with revision 1.1 or later. (Theonly reason I would shy away WinSocks of revision 1.0 is because many of themwere unstable.)

    COMPILATION

    TTCPW was compiled using Visual C++ version 4.0. To compile the program:

    1. Copy the source files to a hard drive directory. This is necessary becauseVisual C++ will generate several large files during the process of the buildwhich can total 1 megabyte or more.

    2. Start Visual C++.

    3. Select Open from the File menu.

    4. Open the file ttcpw.mdp. This is the project file for ttcpw.

    5. Select Build ttcpw.exe from the Build menu.

    The program file ttcpw.exe will be located in the Release directory off of thedirectory the source files were located in.

    Windows 95:

    A:\>ttcpw -t renoir.csc.ncsu.eduttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp -> renoir.csc.ncsu.eduttcp-t: socketttcp-t: connect

    Test message number one.Test message number two.Any other string.++ttcp-t: 3 I/O calls, msec/call = 6915.41, calls/sec = 0.15ttcp-t:UNIX:

    % ttcpatm3 -rttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcpttcp-r: socketttcp-r: accept from 152.1.57.94Test message number one.

    Test message number two.Any other string.ttcp-r: 68 bytes (2048 nbufs) in 20.31 real seconds = 0.00 KB/sec +++ttcp-r: Which is at least 1708.1 ATM cells or 0.04 Mbits/sec at adapter levelttcp-r: 4 I/O calls, msec/call = 5199.97, calls/sec = 0.20ttcp-r: 0.0user 0.0sys 0:20real 0% 0i+0d 150maxrss 0+1pf 4+0csw

  • 8/6/2019 ttcpw95

    6/9

    APPENDIX A

    ORIGINAL TTCP DOCUMENTATION

    NAME

    ttcp - test TCP and UDP performance

    SYNOPSIS

    ttcp -t [-u] [-s] [-p port] [-l buflen] [-b size] [-n numbufs]

    [-A align] [-O offset] [-f format] [-D] [-v] host [out]

    DESCRIPTION

    Ttcp times the transmission and reception of data between two systems

    using the UDP or TCP protocols. It differs from common ``blast'' tests,

    which tend to measure the remote inetd as much as the network perfor-

    mance, and which usually do not allow measurements at the remote end of

    a UDP transmission.

    For testing, the transmitter should be started with -t and -s after the

    receiver has been started with -r and -s. Tests lasting at least tens

    of seconds should be used to obtain accurate measurements. Graphical

    presentations of throughput versus buffer size for buffers ranging from

    tens of bytes to several ``pages'' can illuminate bottlenecks.

  • 8/6/2019 ttcpw95

    7/9

    Ttcp can also be used as a ``network pipe'' for moving directory hierar-

    chies between systems when routing problems exist or when the use of

    other mechanisms is undesirable. For example, on the destination

    machine, use: ttcp -r -B | tar xvpf -

    and on the source machine: tar cf - directory | ttcp -t dest_machine

    Additional intermediate machines can be included by: ttcp -r | ttcp -t

    next_machine

    OPTIONS

    -t Transmit mode.

    -r Receive mode.

    -u Use UDP instead of TCP.

    -s If transmitting, source a data pattern to network; if receiv-

    ing, sink (discard) the data. Without the -s option, the

    default is to transmit data from stdin or print the received

    data to stdout.

    -l length Length of buffers in bytes (default 8192). For UDP, this

    value is the number of data bytes in each packet. The system

    limits the maximum UDP packet length. This limit can be

  • 8/6/2019 ttcpw95

    8/9

    changed with the -b option.

    -b size Set size of socket buffer. The default varies from system to

    system. This parameter affects the maximum UDP packet length.

    It may not be possible to set this parameter on some systems

    (for example, 4.2BSD).

    -n numbufs

    Number of source buffers transmitted (default 2048).

    -p port Port number to send to or listen on (default 2000). On some

    systems, this port may be allocated to another network daemon.

    -D If transmitting using TCP, do not buffer data when sending

    (sets the TCP_NODELAY socket option). It may not be possible

    to set this parameter on some systems (for example, 4.2BSD).

    -B When receiving data, output only full blocks, using the block

    size specified by -l. This option is useful for programs,

    such as tar(1), that require complete blocks.

    -A align Align the start of buffers to this modulus (default 16384).

    -O offset Align the start of buffers to this offset (default 0). For

    example, ``-A8192 -O1'' causes buffers to start at the second

    byte of an 8192-byte page.

  • 8/6/2019 ttcpw95

    9/9

    -f format Specify, using one of the following characters, the format of

    the throughput rates as kilobits/sec ('k'), kilobytes/sec

    ('K'), megabits/sec ('m'), megabytes/sec ('M'), gigabits/sec

    ('g'), or gigabytes/sec ('G'). The default is 'K'.

    -T ``Touch'' the data as they are read in order to measure cache

    effects.

    -v Verbose: print more statistics.

    -d Debug: set the SO_DEBUG socket option.

    SEE ALSO

    ping(1M), traceroute(1M), netsnoop(1M)

    BIBLIOGRAPHY

    Bonner, Pat. Network Programming with Windows Sockets. Prentice-Hall, Inc.,1996.

    Microsoft, Win32 Programmers Guide, Microsoft Press, 1995.