Netcat - A simple port of 'netcat' (nc) for DOS 2009-04-26 Version Michael Brutman (mbbrutman@yahoo.com) Hardware requirements: 8088 processor or better Somewhere between 96KB and 128KB available RAM Display: doesn't matter, whatever you have Supported Ethernet card Software requirements: DOS 2.0 or newer (DOS 3.3 or newer recommended) Packet driver for your Ethernet card Introduction Netcat (nc) is a utility that can send and receive data using a TCP/IP socket. It has the ability to open a connection to another machine or to listen for incoming connections. Input can be entered interactively through the keyboard or redirected in from a file. Output can appear on the screen or redirected to a file. Nc can be used to send large files or short messages, and it can be called from within batch files too. Any output that nc creates that is not part of the normal data flow is sent to stderr so that your incoming data does not get polluted with status messages. Requirements Nc is built using the mTCP library. The setup instructions for mTCP can be found in SETUP.TXT. Using Nc Nc uses the following syntax: nc -target nc -listen Options are: -help Show basic help text -srcport Use as the source port when connecting -st SpeedTest (see section below) -echo Turn on local echoing (off by default) If you are sending keyboard input to the other machine you signal EOF (End of File) by pressing Ctrl-Z. When you do this the TCP/IP socket will be shut down in an orderly way and the program will terminate. Nc is not a replacement for telnet - it will not negotiate 'telnet' parameters. It is good for raw data transfer only. Your best usage of nc is probably with another copy of nc on a DOS or Linux system, or as a utility to check if particular ports are open and accepting communications. When used with another nc on a different platform you can use it to send arbitrary data between the two systems, kind of like a network version of the copy (or Unix 'cat') command. Examples nc -target 192.168.2.1 2000 Opens a TCP/IP socket to 192.168.2.1 port 2000 and sends your keyboard input to the other machine. Output from the other machine will appear on your screen. nc -target 192.168.2.5 1234 < input.txt Opens a TCP/IP socket to 192.168.2.5 port 1234 and sends the file 'input.txt' to the other machine instead of sending your keyboard input. The program automatically ends after input.txt has been transferred. nc -listen 2000 > newfile.txt Listens on port 2000 for a connection from a remote machine. When the connection is established any incoming data is sent to newfile.txt. The 'SpeedTest' Option I use this option for benchmarking. Basically it says that if you are receiving data that you should not write it to disk, and that if you are sending data you should send 4MB of random data and stop. The idea is to eliminate all disk I/O so that I can see how fast the TCP/IP code is running under perfect conditions. If you are interested in seeing how fast your machine can transfer data use nc like this: nc -target -st < bogus.bin This is the send test. Bogus.bin is not actually read. Nc will send 4MB of data. nc -target -st > bogus.bin This is the receive test. Nc will receive data but not write it to disk. It is up to the other side of the connection to set the amount of data to be received. Be careful and make sure that the filename you use does not already exist, as it will be zeroed out. On an XT class machine with an 8 bit Ethernet card I expect to see between 35KB and 45KB of data being transferred per second. On a 386-40 class machine with a 16 bit Ethernet card the number should be in the mid 500s. Limitations * Does not support UDP. (Most Unix versions do.) Changes: 2008-12-30: Small bug fix - was not checking return codes properly on the recv call inside of netcat! Normally not a problem, but this can cause an interesting crash if the other side terminates the connection uncleanly. 2008-12-17: Major performance improvements! I've measured from 17 to 32% depending on the hardware and whether it was sending or receiving. The performance improvement came from rewriting my code that computes elapsed time. Local echoing has been turned off. You can turn it on using the new '-echo' command line option. (You always had to deal with it before.) Ctrl-Break is now safe to use .. it will shut down cleanly. 2008-09-06: Netcat now has DNS resolution! You can use normal server names instead of IP addresses. Check that the packet driver is loaded before trying to use it. TCP/IP stack improvements (Zero window support) Created July 31st, 2008, Last updated April 26th, 2009 (C)opyright Michael B. Brutman, mbbrutman@yahoo.com