Skip to content

W1·A4 — Speak a protocol by hand

Time: 30 min

Needs: A2 topology

GNS3 project: w01-a2-roles (reuse it)

Info

Times listed are approximate and provided as timing guidelines only. Take as much time as you need to complete the activity.

Question

"protocol" is defined as "a set of rules for communications".

Who defines these rules?

How are these rules enforced?

What happens when you break the rules?


Predict first

If you have a typo in a URL, who notices - the server, your machine, both, or neither?



Do this — invent a protocol

On H2:

nc -l -p 9000

On H1:

nc 192.168.10.12 9000

Type on either side and press enter. Then Ctrl-C both.

What just happened

  • Two processes exchanged bytes over a network with no protocol at all beyond "whatever you typed". It worked because neither end expected anything.
  • The number after the IP is called a port number. It's how the OS knows where to deliver the message.

Info

nc is a Linux utility for manipulating arbitrary connections. It is not a protocol itself.


Do this — speak HTTP correctly

Start the web server on H1 if you stopped it previously:

cd /tmp && python3 -m http.server 8080

On H2, be the browser yourself:

nc 192.168.10.11 8080

Then type these three lines exactly — including the empty line at the end:

GET /index.html HTTP/1.1
Host: 192.168.10.11

What just happened

  • A status line, some headers, a blank line, then a line of plain text. This is what a web browser does.
  • The blank line is a protocol element, not formatting. It means "headers finished, stop reading". Without it the server waits forever, because it has no other way to know you are done.
  • The nice thing about this is that it's all natural text understandable to humans. Protocols don't need to be complex or highly technical, although some are. Many protocols such as HTTP and ARP sound almost like human conversation.

Do this — break it on purpose

Reconnect with nc each time. Try these one at a time and record the exact response:

Attempt What you send Exact server response
1 GET /index.html HTTP/1.1 + blank line, no Host: header
2 GET /nonexistent.html HTTP/1.1 + Host: + blank line
3 GIT /index.html HTTP/1.1 + Host: + blank line
4 GET /index.html + blank line (no version)

What just happened

  • Different failures, each with a specific reason.
  • The client was fine with whatever you typed. It forwarded GIT as willingly as GET. TCP delivered the bytes correctly and the bytes were nonsense — correct delivery of garbage is still correct delivery.

    This is an important insight. None of the layers below the Application layer were aware that anything went wrong. Only HTTP did. Each layer keeps only its own promises.

  • A protocol is therefore not "rules the network enforces". It is an agreement between the two endpoints, enforced by the endpoints, invisible to everything in between.


Record

Worksheet section 4: the exact server response to each of the four attempts, and one sentence naming who detected the error in attempt 3 and who did not.

If it went wrong

Symptom Cause Fix
Server prints a request line then nothing happens you did not send the blank line press enter twice
Connection refused server not running, or wrong port check the python3 -m http.server window is still open
Reply is 501 Unsupported method rather than 400 Python's server classifies it that way record what you actually got — the point is that it refused