In my journey to better understand communication via sound over a medium such as a cell phone, there are many parts to the overall project. Today I wanted to find a viable way to test if the connection was active and properly transmitting and receiving, before I actually set up the connection. E.g., once I make a connection, how do I know if it works?
So I decided to use netcat for my early tests. Netcat is called the “Swiss army knife of networking” and it really does shine with the light of versatility and usefulness. There are two main types of traffic that I want to utilize for regular internet connections over the soundmodem, and those two types are UDP and TCP. TCP traffic is the main traffic used for web browsing, but UDP is popular with traffic such as streaming sound or video, so it is likely to encounter both in our target scenario, and thus we need a way to specifically test each one.
Starting with the UDP traffic, I opened two terminal windows on my Debian laptop and started typing the following. As you can see, I am not transmitting out, but simply using the loopback interface to ensure that I properly understand how to utilize netcat.
In the transmitting window:
~$ sudo netcat -u 127.0.0.1 5555
hi
hello
how are you?
^C
~$
In the receiving window:
~$ sudo netcat -u -l -v -n -p 5555
listening on [any] 5555 …
connect to [127.0.0.1] from (UNKNOWN) [127.0.0.1] 54011
hi
hello
how are you?
^C
~$
As I typed in the phrases, “hi, hello, how are you?” and pressed enter for each line, they were transmitted over the loopback interface to the port I chose (5555), and displayed in the receiving window. Now for a test of tcp traffic:
In the receiving window:
~$ sudo netcat -l -v -n -p 5555
listening on [any] 5555 …
connect to [127.0.0.1] from (UNKNOWN) [127.0.0.1] 32968
this is a tcp test
working.
~$
In the transmitting window:
~$ sudo netcat 127.0.0.1 5555
this is a tcp test
working.
^C
~$
Now we have a viable means to test our soundmodem system when we finally iron out all of the bugs in the setup.
Linux – keep it simple.