CSEN 404
Introduction to Networks
Hisham Othman
Basma Mohamed Afifi
Nadeen Hamza
** Slides are attributed to J. F. Kurose
Lecture Outline
Transport-layer services Connection-oriented
Multiplexing and
transport: TCP
demultiplexing of segment structure
applications traffic on a reliable data transfer
machine flow control
Connectionless transport: connection management
UDP Principles of congestion
Principles of reliable data control
transfer
Transport services and protocols
application
provide logical communication transport
network
between app processes running on data link
physical
different hosts
transport protocols run in end
systems
send side: breaks app
messages into segments, passes
to network layer
receive side: reassembles application
transport
segments into messages, passes network
data link
to app layer physical
more than one transport protocol
available to apps
Internet: TCP and UDP
Internet transport-layer protocols
reliable, in-order delivery application
transport
(TCP) network
data link
physical
connection setup network
data link
network
physical
congestion control data link
physical
flow control
unreliable, unordered network
data link
physicalnetwork
delivery: UDP data link
physical
no-frills extension of “best- network
data link
application
effort” IP physical network transport
data link network
services not available: physical data link
physical
delay guarantees
bandwidth guarantees
Best Effort vs. Reliable
Both TCP and UDP use the IP protocol for data delivery
IP is a best-effort delivery protocol
No guarantees for segment delivery
No guarantees for ordered delivery
No guarantees for data integrity
Both TCP & UDP extend host-to-host delivery to process-to-
process delivery through multiplexing & demultiplexing
Both TCP and UDP provide data integrity through checksums
TCP extends IP delivery service and makes it reliable
Uses flow control, handshaking (acknowledgement), sequencing, and
timing for reliable and ordered segment delivery
Also uses congestion control for balanced use of network resources
UDP doesn’t care about reliable delivery
Multiplexing/demultiplexing
Examples of Transport-layer Protocols
used by Applications
Application Application-Layer Protocol Underlying Transport
Protocol
E-mail SMTP TCP
Remote terminal access Telnet TCP
Web HTTP TCP
File transfer FTP TCP
Streaming multimedia Typically proprietary UDP or TCP
Internet telephony Typically proprietary UDP or TCP
Network management SNMP Typically UDP
Routing protocol RIP Typically UDP
Name translation DNS Typically UDP
UDP: User Datagram Protocol
UDP: User Datagram Protocol [RFC 768]
“no frills,” “bare bones” Internet
transport protocol Why is there a UDP?
“best effort” service, UDP no connection establishment
segments may be: (which means less delay)
lost simple: no connection state at
delivered out of order to
sender, receiver
app small segment header
connectionless: no congestion control: UDP can
no handshaking between blast away as fast as desired
UDP sender, receiver
each UDP segment handled
independently of others
UDP: more
often used for streaming 32 bits
multimedia apps source port # dest port #
Length, in
loss tolerant
bytes of UDP length checksum
rate sensitive segment,
other UDP uses including
header
DNS
SNMP (Simple Network
Application
Management Protocol)
data
How to achieve reliable transfer (message)
over UDP: add reliability at
application layer
application-specific error
recovery! UDP segment format
TCP: Transmission Control Protocol
Reliable Data Transfer
Application
Layer
rdt_send() deliver_data()
Transport
Layer
Reliable Channel
udt_send() rdt_rcv()
Network
Layer
Unreliable Channel
Provided Service Service Implementation
TCP: Overview
TCP: Features
point-to-point: Receiver feedback
one sender, one receiver acknowledgements
reliable, in-order byte full duplex data:
stream: bi-directional data flow in
no “message boundaries” same connection
connection-oriented: MSS: maximum segment size
handshaking (exchange of flow controlled:
control msgs) initializes sender sender will not overwhelm
& receiver state before data receiver
exchange
pipelined:
application application
socket
door
writes data reads data
socket TCP congestion and flow
door
TCP
send buffer
TCP
receive buffer
control set window size
send & receive buffers
segment
TCP Connection Management
Three-way handshake:
Step 1: client host sends TCP SYN
segment to server
specifies initial seq. #
no data
Step 2: server host receives SYN,
replies with SYNACK segment
server allocates buffers
specifies server initial seq. #
Step 3: client receives SYNACK,
replies with ACK segment, which
may contain data
TCP Connection Management (cont.)
Closing a connection: client server
client closes socket: close
clientSocket.close();
Step 1: client end system sends TCP
FIN control segment to server close
Step 2: server receives FIN, replies
with ACK. Closes connection,
timed wait
sends FIN
closed
TCP Connection Management (cont.)
Step 3: client receives FIN, replies client server
with ACK. closing
Enters “timed wait” - will
respond with ACK to
received FINs
closing
Step 4: server, receives ACK.
Connection closed
timed wait closed
closed
TCP segment structure
32 bits
URG: urgent data
source port # dest port # counting
(generally not used)
by bytes
sequence number of data
ACK: ACK # (not segments!)
valid acknowledgement number
head not Receive window
PSH: push data now UA P R S F
len used
(generally not used) # bytes
checksum Urg data pointer rcvr willing
to accept
RST, SYN, FIN: Options (variable length)
connection estab
(setup, teardown
commands)
application
data
Internet (variable length)
checksum
(as in UDP)
Receiver Feedback – ACKs
Pipelined protocols
Pipelining: sender allows multiple, “in-flight”, yet-to-be-
acknowledged pkts
range of sequence numbers must be used
buffering at sender and/or receiver
TCP is a pipelined protocol
Pipelining: Increased Utilization
Ex: L = 8000 bits, R = 1 Gbps, RTT = 30 ms. Find the sender utilization of the link, Usender.
3 ∗ 𝐿/𝑅 𝐿/𝑅
𝑈𝑠𝑒𝑛𝑑𝑒𝑟 = 𝑈𝑠𝑒𝑛𝑑𝑒𝑟 =
𝑅𝑇𝑇 + 𝐿/𝑅 𝑅𝑇𝑇 + 𝐿/𝑅
𝑈𝑠𝑒𝑛𝑑𝑒𝑟 = 0.00081 𝑈𝑠𝑒𝑛𝑑𝑒𝑟 = 0.00027
TCP sender events:
data rcvd from app: timeout:
create segment with seq # retransmit segment that
seq # is byte-stream caused timeout
number of first data byte restart timer
in segment ACK rcvd:
start timer if not already if acknowledges previously
running (timer is set in unACK’ed segments
terms of oldest unACK’ed update what bytes known to
segment) be ACK’ed
start timer if there are
outstanding segments
TCP: Cumulative ACK scenario
Host A Host B
timeout
X
loss
time
Cumulative ACK scenario
TCP: retransmission scenarios
Host A Host B Host A Host B
Seq=92 timeout
timeout
X
loss
Seq=92 timeout
premature timeout
time time
lost ACK scenario
TCP sender events:
Segment 1 Segment 2 Segment 3 Segment 4 Segment 5
… 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 …
Host A Host B
Cumulative ACK
timeout
X buffer
loss
Cumulative ACK
Restart timer do not buffer
timeout
Cumulative ACK
X
timeout
Duplicate ACK
time
TCP Round Trip Time, Timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value? SampleRTT: measured
longer than RTT time from segment
but RTT varies transmission until ACK receipt
too short: premature ignore retransmissions
timeout, unnecessary SampleRTT will vary, want
retransmissions estimated RTT “smoother”
too long: slow average several recent
reaction to segment measurements, not just
loss current SampleRTT
Summary
1-27
Transport-layer services
Multiplexing and demultiplexing
Connectionless transport: UDP
Best-effort data transfer
Segment structure
Connection-oriented transport: TCP
Segment structure
Reliable data transfer
Any Question?
1-28