# 1.4 A Day in the Life of a Packet

* Application: stream of data
* Transport: segments of data&#x20;
* Network: packets of data&#x20;

#### TCP Byte Stream&#x20;

* 3-way handshake&#x20;
  * Client sends a synchronize message to the server ("SYN")
  * Server responds synchronize message that also acknowledges the client's synchronize, or ("SYN/ACK")
  * Client responds by acknowledging the server's synchronize ("ACK")&#x20;
* Network layer: responsible for delivering packets to computers&#x20;
* Transport layer: responsible for delivering data to applications&#x20;
* To open a TCP stream, needs&#x20;
  * IP address: address that network layer uses to deliver packets to the computer&#x20;
  * TCP port: tell the computer's software which application to deliver data to&#x20;
    * Web server: TCP port 80&#x20;

![](/files/-MgXCLIqzOr-yvKJ23UC)

#### Inside the Stream

* Hop: link connecting two routers&#x20;
* A router can have many links connecting it. As packet arrives, a router decides which of its links to send it out on.&#x20;
* Routers have IP addresses&#x20;
  * Can deliver to its own software instead of forwarding it&#x20;

![](/files/-MgXChvuBoiylngLKzwz)

#### Inside each hop&#x20;

![](/files/-MgXCtiiu1NbJ1ccHpEr)

* "Best": most specific match (longest prefix match)&#x20;
* Default: least-specific pattern (matches every IP addresses)&#x20;
  * Useful in edge networks&#x20;
    * E.x. stanford example, if the destination address isn't stanford, then should send it out to larger internet&#x20;

#### Under the Hood&#x20;

![](/files/-MgXDPE_BLN3nH0XDHWb)

* 3-way handshakes&#x20;
* More packets for HTTP requests and response&#x20;
* tracerout:
  * Shows the hop that packet takes&#x20;
  * traceroute -w 1 [www.cs.brown.edu\&#x20](http://www.cs.brown.edu\&#x20);

![traceroute to brown  ](/files/-MgXEm98rPuo79Rspr5n)

![traceroute to MIT web server ](/files/-MgXF0QKZ2Eun41nwhS4)

* 20 hops, less than 90 ms&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sliu583.gitbook.io/blog/networking/index/computer-networking-a-top-down-approach/stanford-cs144/chapter-1/1.4-a-day-in-the-life-of-a-packet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
