# 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;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXAyiSbXcSnRDWJw-b%2F-MgXCLIqzOr-yvKJ23UC%2Fimage.png?alt=media\&token=7860a3cc-d2f6-45ef-8a06-d6edf2fb39be)

#### 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;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXAyiSbXcSnRDWJw-b%2F-MgXChvuBoiylngLKzwz%2Fimage.png?alt=media\&token=826f96a5-0363-4fe0-a199-b7d3db276622)

#### Inside each hop&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXAyiSbXcSnRDWJw-b%2F-MgXCtiiu1NbJ1ccHpEr%2Fimage.png?alt=media\&token=cebca909-017f-4785-8364-525ba3ccf3b6)

* "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;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXAyiSbXcSnRDWJw-b%2F-MgXDPE_BLN3nH0XDHWb%2Fimage.png?alt=media\&token=9502d5c4-99c5-4596-8713-818e25649749)

* 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  ](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXDUSe5vrjcmgS9wLB%2F-MgXEm98rPuo79Rspr5n%2Fimage.png?alt=media\&token=4a46dbad-e718-42d0-a160-9131b676d95a)

![traceroute to MIT web server ](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MgXDUSe5vrjcmgS9wLB%2F-MgXF0QKZ2Eun41nwhS4%2Fimage.png?alt=media\&token=64e823f7-2eed-42cd-8f6d-d5e8d6230141)

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