Skip to content

Protocols and shared rules

Module
How Network Communication Is Organized
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, curl 8.5.0
On this page

A browser and a server can be written by different people, at different times, who never meet. Yet the browser can ask for a file and understand the answer. What lets those independent programs agree? Compare a request that works with one the same server rejects.

By the end, you can point to the shared rules in a recorded exchange and distinguish those rules from the programs following them.

Finish Practice: Devices, Links, and Connections. Read these recordings; you do not need a terminal or a learner lab yet. All commands ran on laptop in the course’s isolated lab. The answering program on web is the lab’s own netlab-web/1.0 server.

curl is a program that requests data. Here it takes the browser’s client role. The -v option shows the messages as well as the returned file. The address belongs to the lab, where names are not enabled yet.

A request the server accepts
learner@laptop:~$ curl -v http://10.77.20.80/hello.txt*   Trying 10.77.20.80:80...
* Connected to 10.77.20.80 (10.77.20.80) port 80
> GET /hello.txt HTTP/1.1
> Host: 10.77.20.80
> User-Agent: curl/8.5.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: netlab-web/1.0
< Date: Thu, 19 Nov 2026 06:53:13 GMT
< Content-type: text/plain
< Content-Length: 16
< Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT
< 
Hello from web.
* Closing connectionlearner@laptop:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. curl shows the outgoing request, the server's response, and the returned file contents.
Steps (3)
  1. Type curl -v http://10.77.20.80/hello.txt — Show the request and the response
  2. Press Enter
  3. Output: * Trying 10.77.20.80:80... * Connected to 10.77.20.80 (10.77.20.80) port 80 > GET /hello.txt HTTP/1.1 > Host: 10.77.20.80 > User-Agent: curl/8.5.0 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Server: netlab-web/1.0 < Date: Thu, 19 Nov 2026 06:53:13 GMT < Content-type: text/plain < Content-Length: 16 < Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT < Hello from web. * Closing connection

Read the lines with > first: curl uses that marker for what it sends. Lines with < show what it receives. Lines with * describe curl’s own activity. These markers help you read the recording; they are not characters sent as part of the messages.

The request names a file. The response reports success and then supplies that file’s text. Both sides know which part is the request and which part describes the answer.

A protocol is a set of rules for exchanging messages: what to send, in what order, and in what form. The protocol here is HTTP. The client, curl, follows its client rules; the lab server follows its server rules.

A message format specifies how the parts of a message are arranged. A field is a named or positioned part that carries one piece of information. You can read a field because the format tells you where it begins and ends.

The first outgoing line has three space-separated parts: the action, the requested path, and the protocol version. The first response line has a version, a result number, and a description. The named lines underneath use a colon to separate a field’s name from its value. Their individual meanings can wait; their recognizable structure is the point.

Fixed places do not mean every line has a fixed character count. A path can be longer, and named fields can appear in different orders where the protocol allows it. The written format says which arrangements are allowed.

The following command deliberately inserts an extra word into the outgoing action. -X tells curl what action text to send; the single quotes keep the space inside that text.

Predict: will the server return the file, ignore the extra word, or reject the request?

Run it, then compare with your guess
A request the server rejects
learner@laptop:~$ curl -v -X 'GET BAD' http://10.77.20.80/hello.txt*   Trying 10.77.20.80:80...
* Connected to 10.77.20.80 (10.77.20.80) port 80
> GET BAD /hello.txt HTTP/1.1
> Host: 10.77.20.80
> User-Agent: curl/8.5.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad request syntax ('GET BAD /hello.txt HTTP/1.1')
< Server: netlab-web/1.0
< Date: Thu, 19 Nov 2026 06:53:13 GMT
< Connection: close
< Content-Type: text/html;charset=utf-8
< Content-Length: 382
< 
<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 400</p>
        <p>Message: Bad request syntax ('GET BAD /hello.txt HTTP/1.1').</p>
        <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p>
    </body>
</html>
* Closing connectionlearner@laptop:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. The request reaches web, which rejects the malformed request line instead of returning the file.
Steps (3)
  1. Type curl -v -X 'GET BAD' http://10.77.20.80/hello.txt — Put an extra word into the request line
  2. Press Enter
  3. Output: * Trying 10.77.20.80:80... * Connected to 10.77.20.80 (10.77.20.80) port 80 > GET BAD /hello.txt HTTP/1.1 > Host: 10.77.20.80 > User-Agent: curl/8.5.0 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 400 Bad request syntax ('GET BAD /hello.txt HTTP/1.1') < Server: netlab-web/1.0 < Date: Thu, 19 Nov 2026 06:53:13 GMT < Connection: close < Content-Type: text/html;charset=utf-8 < Content-Length: 382 < <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="utf-8"> <title>Error response</title> </head> <body> <h1>Error response</h1> <p>Error code: 400</p> <p>Message: Bad request syntax ('GET BAD /hello.txt HTTP/1.1').</p> <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p> </body> </html> * Closing connection

The server reports HTTP/1.0 400 Bad request syntax ('GET BAD /hello.txt HTTP/1.1'). The path works, but the request format does not.

Both exchanges reach the same server. The disagreement is in the request line’s arrangement, before the server can treat it as an ordinary request for the file.

The extra word breaks the request line The accepted request GET /hello.txt HTTP/1.1 receives HTTP/1.0 200 OK. In the malformed request GET BAD /hello.txt HTTP/1.1 the extra word BAD is outlined and labeled; the server answers HTTP/1.0 400 Bad request syntax. Valid exchange GET /hello.txt HTTP/1.1 HTTP/1.0 200 OK Malformed exchange GET BAD /hello.txt HTTP/1.1 HTTP/1.0 400 Bad request syntax extra word
The extra word BAD breaks the request line, so web answers 400 Bad request syntax instead of 200 OK.

A standard is an agreed, published specification. HTTP’s public standards let separate teams implement compatible clients and servers without arranging every exchange themselves. The Further reading links are examples of those documents.

Knowing the rules does not guarantee a program implements all of them correctly. This recording establishes what the named lab server does with these requests. Another implementation can word an error differently.

“A protocol is a program.” The client, curl, and the lab server are programs. HTTP is the set of rules they implement.

“Protocols are optional conventions.” A program can send arbitrary text, but the receiving program needs an agreed format to interpret it. The rejected request demonstrates that limit.

Goal: Mark the same kinds of fields in another recorded exchange.

The -I option asks for the response’s descriptive lines without the file contents. Find the action, requested path, request version, response version, result number, and one colon-separated field.

Find the fields in another exchange
learner@laptop:~$ curl -v -I http://10.77.20.80/hello.txt*   Trying 10.77.20.80:80...
* Connected to 10.77.20.80 (10.77.20.80) port 80
> HEAD /hello.txt HTTP/1.1
> Host: 10.77.20.80
> User-Agent: curl/8.5.0
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
HTTP/1.0 200 OK
< Server: netlab-web/1.0
Server: netlab-web/1.0
< Date: Thu, 19 Nov 2026 06:53:14 GMT
Date: Thu, 19 Nov 2026 06:53:14 GMT
< Content-type: text/plain
Content-type: text/plain
< Content-Length: 16
Content-Length: 16
< Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT
Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT

< 
* Closing connectionlearner@laptop:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. A second exchange supplies the fields to annotate; curl also prints the received descriptive lines without its direction markers.
Steps (3)
  1. Type curl -v -I http://10.77.20.80/hello.txt — Ask for the response headers without the file contents
  2. Press Enter
  3. Output: * Trying 10.77.20.80:80... * Connected to 10.77.20.80 (10.77.20.80) port 80 > HEAD /hello.txt HTTP/1.1 > Host: 10.77.20.80 > User-Agent: curl/8.5.0 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 200 OK HTTP/1.0 200 OK < Server: netlab-web/1.0 Server: netlab-web/1.0 < Date: Thu, 19 Nov 2026 06:53:14 GMT Date: Thu, 19 Nov 2026 06:53:14 GMT < Content-type: text/plain Content-type: text/plain < Content-Length: 16 Content-Length: 16 < Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT < * Closing connection

Expected: Six labels attached to parts of the recording.

Hint

Use the outgoing first line and the first incoming line. The unmarked response lines repeat information curl also shows with its verbose markers.

Solution
Part Captured value
Action HEAD
Requested path /hello.txt
Request version HTTP/1.1
Response version HTTP/1.0
Result number 200
Named field Server: netlab-web/1.0

Everyday Application Traffic explains the HTTP lines in detail, including the actions and result numbers.

  • A protocol supplies shared rules; programs implement those rules.
  • A message format makes fields recognizable.
  • Reaching a server does not make a malformed request valid.

Next, TCP/IP and OSI models sorts the different questions behind the exchange.