CMPE 344 Computer Networks
Spring 2024
End-to-End Protocols
Reading: Peterson and Davie, §5.1, 5.2.1, 5.2.2,
5.2.10, 5.4
Sources of slides:
Peterson and Davie, Computer Networks: A Systems Approach, 6th ed., Morgan Kaufmann, 2021.
Tanenbaum, Feamster, and Wetherall, Computer Networks, 6th ed., Pearson, 2021.
Kurose and Ross, Computer Networking, 8th ed., Pearson, 2021.
23/02/2024 1
The transport layer
• Recall that IP provides host-to-host packet
delivery service
• In general, one requires process-to-process
communication channels
• Transport layer deals with process-to-process
communication channels through end-to-end
protocols (between “end” applications)
2
Transport protocols are expected to
provide…
• Guaranteed message delivery
• In-order message delivery
• Delivery of at most one copy of the message
• Support for arbitrarily large messages
• Support for synchronization between sender and
receiver
• Flow control
• Support for multiple application processes on
each host
3
Best-effort networks
• Note that network layer below the transport layer
may
– Drop messages
– Reorder messages
– Deliver duplicate copies of a given message
– Limit messages to some finite size
– Delay messages for a long time
• Such networks (e.g., IP) are said to provide a
best-effort service
4
UDP and TCP
• We will study the Internet’s UDP and TCP
protocols:
– UDP: User Datagram Protocol
– TCP: Transmission Control Protocol
• UDP provides a simple asynchronous
demultiplexing service
• TCP provides a reliable byte-stream service
5
User Datagram Protocol
• UDP as a simple demultiplexer
– Extends the host-to-host delivery service of IP
into a process-to-process communication
service
• There are usually many processes running on a
host so the protocol needs to add a level of
demultiplexing to allow multiple application
processes on each host to share the network
6
Ports
• Processes running on a host are identified by
ports or mailboxes
• Source process sends a message to a port and
the destination process receives the message
from that port
• The header of a UDP packet contains port
numbers for both the sender (source) and the
receiver (destination) process
7
More on ports
• Ports are interpreted only on a single host
• That is, a process is identified by a port on a
particular host using
<port, host> pair
• This pair is the demultiplexing key for the UDP
8
Implementation by message
queues
Application Application Application
process process process
Ports
Queues
Packets
demultiplexed
UDP
Packets arrive
Note that UDP does not implement flow control to tell the sender to slow down.
If a queue becomes full because the messages are arriving too fast,
9
they will be discarded.
UDP header format
0 16 31
SrcPort DstPort
Length Checksum
Data
SrcPort and DstPort: Source and destination port numbers
Length: Length of UDP packet in bytes
Checksum: See next slide
10
UDP error checking
• UDP is not reliable, no guarantee for in-order delivery
• However, it can ensure the correctness of the message
by the use of a checksum over the following:
– The UDP header +
– The message body +
– The pseudo header: 3 fields from IP header (protocol
no, src IP addr, dst IP addr) plus UDP length field
• Contrast UDP’s checksumming with IP checksumming
and ATM HEC!
11
UDP client and servers
• How does a client learn a server’s port number?
– Servers accept messages at well-known ports
(port numbers < 1024)
– e.g., Echo: Port 7, Time: Port 37,
DNS: Port 53
• The server already knows the client’s port
number from client’s contact to the server
12
Transmission Control Protocol
• TCP provides a reliable, connection-oriented
byte-stream service
• TCP is a full-duplex protocol
– Each TCP connection supports a pair of byte
streams, one for each direction
• TCP provides flow control
– Receiver can limit how much data the sender
can transmit at a given time
– This mechanism prevents sender from
overruning receiver
13
More on TCP
• Like UDP, TCP supports a demultiplexing mechanism
– Multiple application processes on a host
simultaneously communicate with their peers
• TCP provides congestion control
– Throttle how fast TCP sends data to prevent sender
from overloading network elements (switches and
routers)
– Note that TCP flow control is an end-to-end issue
whereas congestion control is concerned with
interaction of hosts and network elements
14
Flow vs. congestion control
(a) A fast network feeding a low capacity receiver
(b) A slow network feeding a high-capacity receiver
15
Byte streams and segments
Application process Application process
Write Read
bytes bytes
TCP TCP
Send buffer Receive buffer
■■■
Segment Segment Segment
Transmit segments
TCP “packets” are called segments
16
End-to-end sliding window
• TCP uses the sliding window algorithm to
provide reliable in-order delivery of messages
• However, in TCP, sliding window runs over
logical connection between processes as
opposed to sliding window running over a single
physical link between two nodes (at layer 2)
• Note that in TCP, RTT will be variable!
– TCP has mechanisms to estimate RTT
17
TCP’s sliding window and flow
control
• Flow control: TCP has a mechanism to “learn”
how much resources (e.g., buffer space) the
other side can allocate to the connection
• TCP’s end-to-end approach can be contrasted
to the hop-by-hop approach taken by some
protocols such as ITU’s packet switching
protocol X.25
18
TCP and congestion control
• TCP uses implicit feedback, which depends on packet
losses, to detect congestion
• TCP retransmits each segment if an ACK is not received
in a certain period of time
• TCP sets timeout as a function of the RTT it expects
between the two ends of the connection, but
unfortunately, given the range of possible RTTs between
any pair of hosts in the Internet, as well as the variation
in RTT between the same two hosts over time, choosing
an appropriate timeout value is not that easy: several
algorithms exist for calculating timeouts
19
TCP header format
0 4 10 16 31
SrcPort DstPort
SequenceNum
Acknowledgment
HdrLen 0 Flags AdvertisedWindow
Checksum UrgPtr
Options (variable)
Data
20
TCP header fields
• SrcPort and DstPort: Source and destination port
numbers
• SequenceNum: Position in sender’s byte stream of data
in segment
• AcknowledgementNum: Number of next byte expected
• HdrLen: Number of 32-bit words in TCP header
• Flags: URG, ACK, PSH, RST, SYN, FIN
• AdvertisedWindow: How much data TCP is willing to
accept
• Checksum: Checksum over, header, data, and psueudo
header
• UrgPtr: Pointer to urgent data in segment
21
TCP demultiplexing
• The 4-tuple
<src port, src IP addr, dst port, dst IP addr>
uniquely identify each TCP connection
• This 4-tuple is used as the demultiplexing key
• Because TCP identifies a connection by a 4-
tuple, a given TCP port number can be shared
by multiple connections on the same host
– Multiple connections can exist simultaneously
on one local port
22
Passive and active open in TCP
• TCP is connection-oriented; both ends of the
connection must agree that a connection is
desired
• Application program on one end (server)
performs a passive open indicating to the OS
that it will accept an incoming connection
• Application program on the other end (client)
must then contact its OS with an active open
request to establish a connection
23
TCP three-way handshake for
connection establishment
Active participant
(client) (server)
Assume server executed a passive open.
SYN bit is used to establish a connection.
24
Some well-known TCP ports
• Mail service: Port 25
• FTP: Port 21
• Telnet: Port 23
• Web service: Port 80
• etc.
• For example,
<18.26.3.36, 1069, 128.10.2.3, 21>
might correspond to an FTP connection
25
TCP client/server
communications
26
Alternatives: SCTP
• Stream Control Transmission Protocol (SCTP) combines features of
UDP and TCP services provided to the application layer protocols
• SCTP provides connection-oriented, process-to-process, full-duplex
reliable message stream service (contrast this to TCP’s byte stream
service and its suitability for request/reply protocols)
• SCTP implements a partially ordered delivery service rather than the
strictly ordered service of TCP: important for applications that are
capable of processing data out of order (e.g., consider processing
Web pages with multiple objects)
• SCTP allows multiple streams in each connection: important when
sending real-time data such as audio/video; if one stream is blocked,
the other can still deliver data
• SCTP supports multi-homing (a physical host with multiple IP
addresses): useful for fault tolerance and improved performance
• SCTP has received more attention lately due to its use in control
plane in 4G/5G cellular networks 27
Alternatives: QUIC
• Quick UDP Internet Connections (QUIC) (Google 2012)
• Still undergoing standardization
• Rise of HTTP: HTTP over TCP may not be optimal
– High-latency wireless networks
– Availability of multiple network interfaces on a single wireless
device
– Increasing use of encrypted, authenticated connections on the
Web
• Web page requests: many objects need to be fetched, but page
rendering could begin before all objects have arrived
• QUIC is actually “over UDP”: Transport protocol over transport
protocol (to pass through firewalls)
• Multiplexes several streams onto a single transport connection to
avoid head-of-line blocking when a single packet is dropped while
other useful data continues to arrive
• Preserves the congestion avoidance properties of TCP 28
Interactive multimedia
applications
• Voice over IP (VOIP)
– Phone calls over IP
– Computer to computer
– Analog phone to/from computer
– Analog phone to analog phone
• Enabling protocols:
– RTP: Real-time Transport Protocol
– RTCP: Real-time Transport Control Protocol
– SIP: Session Initiation Protocol
29
RTP
• An end-to-end protocol used by multimedia
applications that have real-time constraints
• Transport over transport!
• More on interactive versus streaming
applications in Chapter 9
30