Run the Test
We are going to test the local area connection. You could also run this same test between to FreeBSD hosts over a WAN or internet so long as they each have a route. If you are running this test over a slow data connection you may want to reduce the number of bytes used to perform the test.
Choose which host to use as the Server (it doesn't matter which one it is). Find the host's IP address and note it. SSH into the host using your favorite SSH client if the host is remote. Type in the following, then press enter:
nc -l 12345 | wc -c
There will be no output and the terminal will just sit there waiting. That's what we want.
Your other FreeBSD host will act as the client machine. Open up a terminal (or SSH into it if it's remote). Run the command below, replacing X.X.X.X with the IP address of the host acting as the server. Then press enter.
dd if=/dev/zero bs=1048576 count=1024 | nc -N X.X.X.X 12345
There will be a slight pause, the length of which depends on your connection speed and the number of used for count (and bs if it's a really slow connection). When the test is complete both your client and server will exit to the prompt.
The client will display the results of the speed test. The server will display the number of bytes received. Something similar to:
Client:
1024+0 records in
1024+0 records out
1073741824 bytes transferred in 9.240792 secs (116195869 bytes/sec)
Server:
1073741824
For this test or transfer speed was 116195869 bytes/sec or 934.362552 mbits/s (116195869 / 125000). If you need help converting bytes to other units, Google is your friend.
Run the test a few times to get an average and maybe swap between the client and server if desired.
Details
We are using 3 utilities together with the magic of UNIX pipes. They are netcat (nc), wc, and dd. All of which are part of any basic FreeBSD OS installation.
dd
The dd utility is being used to generate test data by reading from /dev/zero. As the device name suggests, it's just a stream of 0's. We generate a block size of 1,048,576 bytes as indicated by 'bs=1048576'. That's about 1 MB (or exactly 1 MiB), take a look at Google's unit conversion tool for more insight. We create one thousand two hundred twenty four (1,024) of those blocks according to 'count=1024'. This will give us about a 1 GB (1 GiB) because 1,024 MB ~= 1 GB. The data stream is 'piped' (redirected) to the next command using the "|" operator.
dd if=/dev/zero bs=1048576 count=1024
nc
Netcat (nc) is a single tool that is used at both the client and server ends. When given the '-l' flag it listens on the provided port number (12345 in this case) for incoming connections. Usually when something is listening, it's a server.
Client-side, netcat only needs to be given the address and port number to connect to. The address can be an IP address like 'X.X.X.X' which was used in our test. Or it can be a fully qualified host name that resolves to an IP address. When a netcat client is connected to a netcat server, any data received on the client over stdin (standard input) is transmitted to the server. The pipe tool is used to redirect the data stream from dd to netcat over stdin.
Adding the '-N' option will cause netcat to automatically quit once the data stream ends so we don't have to do it manually. The dd tool conveniently adds the EOF marker to the end of the stream.
nc -N X.X.X.X 12345
wc
On the server side we are piping the received data stream to a utility called wc. It's known as the 'word counter' but can also count lines (-l flag) and bytes when given the "-c" flag. It's not necessary to have this, but it's helpful in letting us know how much was data transmitted. The number printed should match the result of the block size multiplied by the number of blocks generated on the client (bs X count).
wc -c
Learn More
The process above is specific to FreeBSD. Other operating systems may or may not have the tools available in a default install and the input options might also be different between platforms.
Use the 'man' command on your OS to lookup the exact usage patterns.