1 of 48

Discussion 2

1

CS 168, Spring 2026 @ UC Berkeley

Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao, Iuniana Oprescu

Packets and Sockets 📦

2 of 48

Logistics

  • Project 1B: Traceroute Error Handling
    • Deadline: Friday, Feb 13

  • Still far ahead: Midterm on Friday, Mar 20 7–9pm (put it in your calendar)!

3 of 48

Delays

  • Transmission Delay
  • Propagation Delay
  • Bandwidth Delay
  • Queueing Delay
  • Burstiness and Queues
  • End-to-End Delay
  • Round Trip Time (RTT)

4 of 48

Delays

  • How long does it take for your packet to travel through the network?
  • It depends on…
    • how much data you’re sending and the link speed�→ transmission delay
    • your distance from the destination�→ propagation delay
    • the traffic pattern�→ queuing delay

5 of 48

Transmission Delay

  • How long it takes for the all bits in the packet to get on the wire
    • The time between when the first and last bits enter the link
  • Limited by the bandwidth
    • Bandwidth: Number of bits you can send through a wire per unit of time

Capacity = Delay × Bandwidth

Bandwidth

Propagation Delay

6 of 48

Transmission Delay: Formula

Usually bits/second

7 of 48

Transmission Delay: Example

Bandwidth = 4Mbps

Propagation Delay

Capacity = Delay × Bandwidth

8 of 48

Propagation Delay (latency)

  • End-to-end transmission time of one bit
  • Depends on the length of the link
  • Limited by the speed of light (propagation speed of link)
  • Does NOT depend on the size of the packet

Capacity = Delay × Bandwidth

Bandwidth

Propagation Delay

9 of 48

Propagation Delay: Formula

10 of 48

Propagation Delay: Example

Capacity = Delay × Bandwidth

Bandwidth

Propagation Delay

speed of light

11 of 48

Measuring Packet Delay with Timing Diagrams

Packet Delay = Transmission Delay + Propagation Delay

Packet Delay = (Packet Size / Bandwidth) + Propagation Delay

B

A

Bandwidth: 1,000,000 bps

Delay: 0.001s

t = 0s

t = 0.000001s

t = 0.001001s

t = 0.000800s

t = 0.001800s

800-bit packet

Transmission Delay

Propagation Delay

12 of 48

Pipe Diagrams

Pipe diagram shows the bits on the link at a frozen moment in time.

  • Height = bandwidth. How many bits we can put in the pipe per unit time.
  • Width = propagation delay. How long it takes for bits to travel through the pipe.
  • Area = bandwidth-delay product. How many bits fit in the pipe at a given instant.

Now that we know the propagation delay, we can tell how many bits are “in flight” (on the link) at any time

B

A

Bandwidth: 5 bps

Delay: 7s

Bandwidth

Propagation Delay

13 of 48

Packets might have to wait before they can be transmitted…

14 of 48

Transient Overload

What happens if two packets arrive at the router simultaneously?

  • Can't process both at the same time! Router must queue one for later.
  • When there are no incoming packets, router can drain the queue.
  • This is called transient overload, and it's fairly common.

Router

B1

A1

A2

A3

A4

B2

B3

Need a queue!

15 of 48

Queuing Delay

  • How long the packet waits to get transmitted on the wire
  • Happens only when arrival rate is greater than transmission rate
    • More packets are arriving than are getting transmitted

Router

B1

A1

A2

A3

A4

B2

B3

Need a queue!

16 of 48

Persistent overload

Persistent overload: Not enough capacity to handle the incoming packets!

  • Queue won't help us. If the queue fills up, the router must drop packets.

How do we solve persistent overload?

  • Operators can detect the overload and (manually) upgrade the link.
  • Routers can tell the senders to slow down.

Router

B1

A1

A2

A3

A4

A5

A6

A7

B2

B3

B4

B5

B6

B7

Uh oh...

17 of 48

Burstiness and Queues

  • How does burstiness affect queuing delays?
    • Bursty flows tend to increase queuing delay

  • What happens when the queue is full?
    • Packets are dropped

18 of 48

Packet Queuing and Life of a Packet

Queues introduce extra delay.

  • Packet delay = Transmission Delay + Propagation Delay + Queuing Delay.

Life of a packet:

  • Sender puts payload in a packet, adding headers.
  • Packet travels along a link.
  • Packet arrives at a router. Router forwards packet to the next hop.
    • Packet might be queued or dropped.
  • Repeat the last step until:
    • Packet reaches destination.
    • Packet is dropped.

19 of 48

Round Trip Time (RTT)

The time it for the packet to reach its destination and receive a response

RTT = 2 * (End-to-End Delay)

20 of 48

Visualizing end-to-end-delay…

  • Two packets, back-to-back

Transmission delay

Propagation delay

Transmission delay

Propagation delay

Queueing Delay

Time

End-to-end delay of brown packet

21 of 48

Statistical Multiplexing

  • Statistical Multiplexing
  • Layers
  • Sockets

22 of 48

Statistical Multiplexing

23 of 48

Statistical Multiplexing

  • Sum of the peaks is always greater than the peak of the sums (peak of the aggregate). Usually much greater.

15

12

9

12

15

9

>=

36

12

9

15

15

24 of 48

Layering in the Open Systems Interconnected (OSI) Model

L7: Application

do the thing

L6: Presentation

(ignored here)

L5: Session

(ignored here)

L4: Transport

beyond delivery: (un)reliability, packet assembly, congestion control, ...

L3: Network

global delivery, best-effort

L2: Data link

local delivery, best-effort

L1: Physical

physical transfer of bits

25 of 48

Layering in practice

HTTP(S)

TCP

IP

Ethernet

802.11 Wi-Fi

CAN bus

UDP

USB

SSH

Email (IMAP/POP)

...

L7: Application

L6: Presentation

L5: Session

L4: Transport

L3: Network

L2: Data link

L1: Physical

L3.5: research!

26 of 48

Sockets

  • Endpoint for sending or receiving data across a network
  • OS abstraction for connections
  • Allow L7 applications to operate on data streams (not packets)
    • Connect, listen, accept, send, receive
  • Open a socket between:
    • Source IP address : port
    • Destination IP address : port

26

Application

Transport

Network

Datalink

Physical

app

OS

(networking stack)

app

app

NIC

Port

(Network Interface Card)

27 of 48

Connection (the basic abstraction)

  • Pipes data between two processes (on different hosts)
  • Data flows both ways!

The Internet

Connection

Process

Process

Process

Process

Process

Process

Process

Process

28 of 48

Connection (the basic abstraction)

  • Data is sent simply as a stream of bits
  • Reconstruction of bits only at the endpoints
  • The Internet knows nothing* about what it’s transmitting!

* (unless you’re implementing security)

The Internet

Connection

Process

Process

29 of 48

Connections

  • Two types of sockets
    • Server and Client
  • Servers listen for clients to connect to them
    • Wait until a connection is attempted
      • Accept and dispatch connection
    • Usually serving many clients at once
  • Clients initiate new connections to servers
  • Example
    • Server: berkeley.edu
    • Client: Your internet browser

Client

Client

Client

Client

Server

30 of 48

Connections

  • Hosts have addresses
    • Unique identifier (just like a street address)
  • Clients (different users) find servers with their addresses
    • Servers send data back with the client address
  • Example addresses ➔

Client

Client

Client

Client

Server

Are addresses enough to make this work?

1.2.3.4

5.6.7.8

10.20.30.40

9.10.11.12

13.14.15.16

31 of 48

Addresses aren’t enough

Server 1 Machine (5.6.7.8)

Server Process 1

Client 1 Machine (1.2.3.4)

Process 1

Process 2

How does the client computer know which process (i.e. web browser) to deliver data to?

32 of 48

Ports

Server Machine

Client Machine (1.2.3.4)

Process 1

(Port 10000)

Process 2

(Port 20000)

  • Sockets are identified by unique IP:port pairs
  • A port is a number that the OS associates with a socket when it is created
    • i.e. sending to address “1.2.3.4:10000” would send data to the socket owned by Process 1

Process 1

(Port 80)

33 of 48

Ports

  • Packets carry port number
  • Servers listen on a port
    • Which one depends on application
    • HTTP: 80
    • SSH: 22
  • Client process connects to

well known port

  • Client also has a port
    • Randomly assigned by OS
    • Used by OS to send data to correct process

Server Machine

Client Machine (1.2.3.4)

Process 1

(Port 10000)

Process 2

(Port 20000)

Process 1

(Port 80)

34 of 48

Worksheet

  • True or False
  • End-to-End Delay
  • Statistical Multi-What?

35 of 48

Question 1: True or False

36 of 48

Worksheet

  • True or False
  • End-to-End Delay
  • Statistical Multi-What?

37 of 48

Question 2: End-to-End Delay

38 of 48

Question 2: End-to-End Delay

39 of 48

Question 2: End-to-End Delay

40 of 48

Question 2: End-to-End Delay

41 of 48

Question 2: End-to-End Delay

42 of 48

Question 2: End-to-End Delay

‼️

43 of 48

Question 2: End-to-End Delay

44 of 48

Worksheet

  • True or False
  • End-to-End Delay
  • Statistical Multi-What?

45 of 48

Question 3: Statistical Multi-What?

46 of 48

Question 3: Statistical Multi-What?

47 of 48

Question 3: Statistical Multi-What?

48 of 48

Questions?

Feedback Form: https://tinyurl.com/cs168-su25-disc-feedback