In the book "TCP/IP Illustrated, Volume 1" by Kevin Fall and Richard Stevens, many examples are using a utility program called "sock" that can do various TCP/IP related things, for example it can act as a UDP server or it can send UDP datagrams to such a server. I would like to test some basic things in the same way they describe in the book, for example to start a UDP server on one computer and send a UDP datagram to it from another computer.

To give an idea of the kind of utility I'm looking for, according to the book the sock program can be used like this to start an IPv4 UDP server on port 7777:

sock -u -s 7777

and like this to send some UDP datagrams with a given destination IP address:

sock -v -u -i discard

The source code for that "sock" program is available at https://www.icir.org/christian/sock.html which is great, but I am still wondering: are there some Ubuntu packages that I could install (or that are already available by default) that would provide similar simple utilities for UDP and TCP?

Edit: in addition to the nc (netcat) tool suggested in the answer below, I just learned that sending a UDP datagram can be done very easily using bash, like this:

echo "hello" > /dev/udp/example.com/8000

See for example https://unix.stackexchange.com/questions/191655/using-bashs-dev-udp-how-would-i-know-if-the-port-was-open

| improve this question | | | | |
  • 1
    hping and hping3 are also very useful for this stuff. – Doug Smythies Mar 30 at 15:09

Netcat is a great linux tool for network debudding and raw data transmission across your LAN/WAN.

It also allows you to send a whole file and even combine higher level protocols.

Here are two good guides with some netcat basics: How To Use Netcat to Establish and Test TCP and UDP Connections on a VPS , Netcat (nc) Command with Examples.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.