Advanced Computer Networks - CoSc-6111-Lecture-4
Advanced Computer Networks - CoSc-6111-Lecture-4
1
Course Title EtCTS Lect. Lab Credit Hr.
Code
Networks
2
Course Delivery Methodology
Theory
N/W Simulation
Programming
3
Chapter-4
Transport Layer
4
Objectives of the Chapter
Introduction
Socket
TCP
UDP
6
Part A: Introduction
● The transport layer is an end-to-end layer – this means
that nodes within the subnet do not participate in
transport layer protocols – only the end hosts.
Transport
Network Identifies the node
Data Link Frames
NA
TCP UDP
IP
Physical Network
(driver)
Socket Families
There are several significant socket
domain families:
⇨Internet Domain Sockets (AF_INET)
- implemented via IP addresses and
port numbers
⇨Unix Domain Sockets (AF_UNIX)
- implemented via filenames (think
“named pipe”)
⇨Novell IPX (AF_IPX)
⇨AppleTalk DDS (AF_APPLETALK)
Type of Socket
close() shutdown
TCP Client
• Sequence of calls
close() Shutdown
Server Side Socket Details
Client Side Socket Details
UDP Clients and Servers Socket
• Connectionless servers do not call listen() or accept(), and usually do not call
connect()
close() Shutdown
UDP Client Socket
• Sequence of calls
close() Shutdown
Socket
Programming
Example:
Internet File Server
6-6-1
30
PART C: TCP
2. Introduction
• connection oriented.
• full duplex.
TCP Services:
• Reliable transport
• Flow control
• Congestion control
🡪TCP numbers each segment and uses an ARQ protocol to recover lost
segments.
🡪 At the data link layer, we viewed an ARQ protocol as being operated between
two nodes (segment / hop by hop) connected by a point-to-point link.
🡪 The round-trip time will change with different connections and connection
establishment is more complicated.
6. TCP Header
• The Sequence number and Acknowledgement number fields perform
their usual functions. Note that the latter specifies the next byte
expected, not the last byte correctly received. Both are 32 bits long
because every byte of data is numbered in a TCP stream.
• The TCP header length tells how many 32-bit words are contained in
the TCP header. This information is needed because the Options field
is of variable length, so the header is, too. Technically, this field really
indicates the start of the data within the segment, measured in 32-bit
words, but that number is just the header length in words, so the effect
is the same.
37
• Next comes a 6-bit field that is not used. The fact that this field has
survived intact for over a quarter of a century is testimony to how well
thought out TCP is. Lesser protocols would have needed it to fix bugs
in the original design.
• Now come six 1-bit flags. URG is set to 1 if the Urgent pointer is in
use. The Urgent pointer is used to indicate a byte offset from the
current sequence number at which urgent data are to be found. This
facility is in lieu of interrupt messages. As we mentioned above, this
facility is a bare-bones way of allowing the sender to signal the
receiver without getting TCP itself involved in the reason for the
interrupt.
38
• The ACK bit is set to 1 to indicate that the Acknowledgement number
is valid. If ACK is 0, the segment does not contain an
acknowledgement so the Acknowledgement number field is ignored.
• The PSH bit indicates PUSHed data. The receiver is hereby kindly
requested to deliver the data to the application upon arrival and not
buffer it until a full buffer has been received (which it might otherwise
do for efficiency).
• The RST bit is used to reset a connection that has become confused
due to a host crash or some other reason. It is also used to reject an
invalid segment or refuse an attempt to open a connection. In general,
if you get a segment with the RST bit on, you have a problem on your
hands.
39
• The PSH bit indicates PUSHed data. The receiver is hereby kindly
requested to deliver the data to the application upon arrival and not
buffer it until a full buffer has been received (which it might otherwise
do for efficiency).
• The RST bit is used to reset a connection that has become confused
due to a host crash or some other reason. It is also used to reject an
invalid segment or refuse an attempt to open a connection. In general,
if you get a segment with the RST bit on, you have a problem on your
hands.
40
• The SYN bit is used to establish connections. The connection request
has SYN = 1 and ACK = 0 to indicate that the piggyback
acknowledgement field is not in use. The connection reply does bear
an acknowledgement, so it has SYN = 1 and ACK = 1. In essence the
SYN bit is used to denote CONNECTION REQUEST and
CONNECTION ACCEPTED, with the ACK bit used to distinguish
between those two possibilities.
• The FIN bit is used to release a connection. It specifies that the sender
has no more data to transmit. However, after closing a connection, the
closing process may continue to receive data indefinitely. Both SYN
and FIN segments have sequence numbers and are thus guaranteed to
be processed in the correct order.
41
7. Sample TCP Packet
8. TCP Connection Establishment
Active Passive
participant
(client participant
(serve
) SYN, r)
Sequ
en ceNu
m =
x
u m =y,
nce N
q u e
A CK , Se ent
YN + d g m
S
ckn owle
A
1
ACK, =x+
Ackno
=y+1 wledg
ment
9. Closing a TCP Connection (1)
client server
• client closes socket:
clientSocket.close(); clo FIN
se
• Step 1: client end system
sends TCP FIN control segment ACK
to server
clo
FIN
se
• Step 2: server receives FIN,
replies with ACK. Closes ACK
timed
wait
connection, sends FIN.
clos
ed
10. Closing a TCP Connection (2)
received FINs ng
• Step 4: server, receives ACK. ACK
Connection closed. closi
FIN
• Note: with small modification, can
ng
handle simultaneous FINs.
ACK
timed
wait
clos
ed
clos
ed
11. TCP Transmission Policy
47
Flow Control and Congestion Control
If this is not done and sources send at too high of a rate, then
buffers within the network will fill-up resulting in long delays and
eventually packets being dropped.
T
T
R
– CW > slow start threshold two segm
ents
• Then switch to congestion
avoidance
• If we detect loss, cut CW in half four segm
ents
• Exponential increase in window size
per RTT
time
25. How are losses recovered?
• Say packet is lost (data or ACK!)
sende receiver
r
• Coarse-grained Timeout:
– Sender does not receive ACK after some Seq=9
2, 8 b
period of time data
ytes
– Event is called a retransmission time-out
(RTO)
timeout
=1 0
– RTO value is based on estimated round- ACK
0
trip time (RTT) X
– RTT is adjusted over time using los
exponential weighted moving average:
Seqs=9
RTT = (1-x)*RTT + (x)*sample 2, 8 b
yt e
data s
(x is typically 0.1)
tim
lost ACK e
scenario
26. Fast Retransmit
• Receiver expects N, gets N+1:
tim
Introduced in TCP Reno e
TCP Connection Management Modeling
• The states used in the TCP connection management
finite state machine.
TCP Connection Management Modeling (2)
PART D: UDP
• UDP (User Datagram Protocol) 🡪 unreliable,
connectionless; No TCP’s flow control;
applications where prompt delivery more
important than accurate delivery (speech,
video, …)
• (Metaphor: postal service)
2. UDP
Datagram protocol 🡪 it does not have to establish a
connection to another machine before sending data.
The length field gives the length of the entire packet including the header.
67
The Application Layer
Example: The World Wide Web
Summary
(1) Architecture
(2) The Client Side
(3) The Server Side
(4) URL
(5) HTTP
(6) HTML
1. Architectural Overview (2)
(b)
• (a) The HTML for a sample Web page. (b) The formatted page.
6. HTML (2)
80