Talking to yourself

Let's jump right in with a simple example of networking on your own computer. [1]

  1. In your terminal, create a simple server

    $ nc -l -p 9999 # If you get an error, try nc -l 9999
    
  2. In another terminal, create a simple client

    $ nc localhost 9999
    < Hello
    

You should be able to talk back and forth over this local connection. What you've down is establish the simplest of TCP connections, which creates a virtual "data pipe". (As we all know, the Internet is a series of tubes)

Becoming the web browser

Going beyond talking to yourself, let's access a real web page!

$ nc example.com 80
< GET /index.html HTTP/1.0
< Host: example.com
<
> HTTP/1.0 200 OK
> Content-Type: text/html; charset=UTF-8

Running the snippet above will make a web request, roughly in the same way your web browser does [2], to example.com and returns the HTML code.

Example Domain

Networking is built on packets

Every message sent over the Internet is broken into packets, which are packaged units of data much like letters in a mail system. In the example above there is a request packet from your computer, and at least one response containing the HTML.

Capturing packets

Now we are going to repeat the previous example with Wireshark to see the packets it contains:

  1. Open Wireshark and select the "Wi-Fi" interface, assuming you are on a Wi-Fi connection.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f82f04d1-edff-490a-abb7-a5fa0b46b49e/Screen_Shot_2020-10-18_at_3.18.21_PM.png

  2. Enter tcp.port == 80 into the filter bar at the top of the screen.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c50331df-cb89-46f2-9589-c64cccf59bd9/Screen_Shot_2020-10-18_at_3.22.27_PM.png

  3. Repeat the previous example, with Wireshark open, and you should see packets start to populate on the screen each time you hit Enter, as shown above ☝️

  4. Each line represents a packet. You can select them in the list and read the contents at the bottom on the page, as shown above ☝️

More tutorials exist on the Internet for how to use Wireshark. I'd encourage you to play around with it, and if you would like more guidance, here is an example tutorial.

How to Use Wireshark to Capture, Filter and Inspect Packets

Components of the web request