Title: UDPUser Datagram Protocol
1UDPUser Datagram Protocol
- An unreliable, connectionless transport layer
protocol - UDP format. See picture
- Two additional functions beyond IP
- Demultiplexing deliver to different upper layer
entities such as DNS, RTP, SNMP based on the
destination port in the header. i.e., UDP can
support multiple applications in the same end
systems. - (Optionally) check the integrity of entire UDP.
(recall IP only checks the integrity of IP
header.) - If source does not want to compute checksum, fill
checksum with all 0s. - If compute checksum and the checksum happens to
be 0s, then fill all 1s. - UDP checksum computation is similar to IP
checksum, with two more - Add extra 0s to entire datagram if not multiple
of 16 bits. - Add pseudoheader to the beginning of datagram.
UDP pseudoheader
2Back to UDPUser Datagram Protocol
UDP datagram
0
16
31
Source Port
Destination Port
UDP Length
UDP Checksum
Data
Figure 8.16
3Back to UDPUser Datagram Protocol
UDP pseudoheader
0 8
16
31
Source IP Address
Destination IP Address
0 0 0 0 0 0 0 0 Protocol 17
UDP Length
1.Pseudoheader is to ensure that the datagram has
indeed reached the correct destination host
and port. 2. The padding of 0s and pseudoheader
is only for the computation of checksum and
not be transmitted.
Figure 8.17
4TCPtransmission control protocol
- TCP functionality
- Provides connection-oriented, reliable,
in-sequence, byte-stream service - Provides a logical full-duplex (two way)
connection - Provides flow-control by advertised window.
- Provides congestion control by congestion window.
- Support multiple applications in the same end
systems. - TCP establishes connection by setting up
variables that are used in two peer TCP entities.
Most important variables are initial sequence
numbers. - TCP uses Selective Repeat ARQ.
- TCP terminates each direction of connection
independently, allowing data to continue flowing
in one direction after closing the other
direction. - TCP does not keep messages boundaries and treats
data as byte stream. e.g, when source sends out
two chunks of data with length 400 and 600 bytes,
the receiver may receive data in chunks of 300,
400, and 300 bytes, or 100 and 900 bytes.
5TCP operations
- TCP delivers byte stream.See picture
- TCP deals with old packets from old connections
by several methods. See picture - TCP uses sliding-window to implement reliable
transfer of byte stream. See picture - TCP uses advertised window for flow control.
- Adaptive timer
- tout tRTT4dRTT ,
- tRTT(new) ? tRTT(old) (1-?)?n ,
dRTT(new)?dRTT(old) (1-?)(?n-tRTT) - Where ?n is the time from transmitting a segment
until receiving its ACK. ?, ? are in 0 to 1 with
? being 7/8 and ? being ¼ typically. tRTT is
mean round-trip-time, dRTT is average of
deviation. - TCP uses congestion window for congestion
control. See picture
6TCP byte stream
Application
Application
byte stream
byte stream
segments
Transmitter
Receiver
Send buffer
Receive buffer
ACKs
Figure 8.18
7Back to TCP operations
An old segment could not be distinguished from
current ones
Question How does TCP prevent old packets of old
connections?
- Using long (32 bit) sequence number
- Random initial sequence number
-- set a timer at the end of a connection to
clear all lost packets from this connection.
As a result, that an old packet from an old
connection conflicts with packets in current
connection is very low!!
Figure 8.23
8Back to TCP operations
TCP uses Selective-Repeat ARQ
Receiver
Transmitter
Receive Window
Send Window
RlastWR1
Rlast
SlastWS-1
...
...
...
Octets transmitted and ACKed
Rnext
Rnew
SlastWA-1
Slast
Srecent
Advertised window
Rlast highest-numbered octet not yet read by the
application Rnext next expected octet Rnew
highest numbered octet received correctly RlastWR
-1 highest-numbered octet that can be
accommodated in receive buffer
Slast oldest unacknowledged octet Srecent
highest-numbered transmitted octet SlastWA-1
highest-numbered octet that can be
transmitted SlastWS-1 highest-numbered octet
that can be accepted from the application
Note 1. Rnew highest bytes received correctly,
which are out-of sequence bytes.
2. Advertised window WA Srecent Slast ? WA WR
( Rnew Rlast)
Figure 8.19
9Back to TCP operations
Dynamics of TCP congestion window
Congestion occurs
Congestion
20
avoidance
15
Congestion
window
Threshold
10
Slow
start
5
0
Round-trip times
Figure 7.63
10TCP protocol
- TCP segment See Segment format
- TCP pseudoheader. See pseudoheader
- TCP connection establishment. See establishment
- Client-server application See socket
- TCP Data transfer
- Sliding window with window sliding on byte basis
- Flow control and piggybacking See flow control
- TCP connection termination
- After receiving ACK for previous data, but no
more data to send, the TCP will terminate the
connection in its direction by issuing an FIN
segment. Graceful termination - TCP state transition diagram
11Back to TCP protocol
TCP segment format
0 4 10
16
24 31
Source Port
Destination Port
Sequence Number
Acknowledgement Number
U
A
P
R
S
F
Header
R
C
S
S
Y
I
Reserved
(Advertised) Window Size
Length
G
K
H
T
N
N
Checksum
Urgent Pointer
Options
Padding
Data
1.SYN request to set a connection. 2. RST
tell the receiver to abort the connection. 3.
FIN tell receiver this is the final segment, no
more data, i.e, close the connection in this
direction. 4. ACK tell the receiver (or sender)
that the value is the field of acknowledgment
number is valid. 5. PSH tell the receiving TCP
entity to pass the data to the application
immediately. 6. URG tell the receiver that the
Urgent Pointer is valid. Urgent Pointer this
pointer added to the sequence number points to
the last byte of the Urgent Data, (the data
that needs immediately delivery).
Figure 8.20
12Back to TCP protocol
TCP pseudoheader
0 8
16
31
Source IP Address
Destination IP Address
0 0 0 0 0 0 0 0 Protocol 6
TCP Segment Length
The padding of 0s and pseudoheader is only used
in computation of checksum but not be
transmitted, as in UDP checksum.
Figure 8.21
13Back to TCP protocol
Host A
Host B
- Random initial SN
- Initial SNs in two
- directions are different
- 3. Initial SNs for two
- connections are different.
- 4. It should be clear here that
- what setting up connection
- means
- both A and B know that
- they will exchange data,
- and go into ready state to
- send and receive data.
- Most important is that
- they agree upon the
- initial SNs.
SYN, Seq_no x
SYN, Seq_no y, ACK, Ack_no x1
Seq_no x1, ACK, Ack_no y1
Three-way handshake to set up connection
Figure 8.22
14Back to TCP protocol
Host B (Server)
Host A (Client)
socket bind listen accept (blocks)
socket connect (blocks)
SYN, Seq_no x
SYN, Seq_no y, ACK, Ack_no x1
connect returns
Seq_no x1, ACK, Ack_no y1
write read (blocks)
accept returns read (blocks)
request message
read returns
write read (blocks)
reply message
read returns
Figure 8.24
15Back to TCP protocol
TCP window flow control
Host A
Host B
t0
Seq_no 1, Ack_no 2000, Win 2048, No Data
t1
Seq_no 2000, Ack_no 1, Win 1024, Data
2000-3023
t2
Seq_no 3024, Ack_no 1, Win 1024, Data
3024-4047
t3
Seq_no 1, Ack_no 4048, Win 512, Data 1-128
t4
Seq_no 4048, Ack_no 129, Win 1024, Data
4048-4559
Figure 8.25
16Back to TCP protocol
TCP graceful termination
Host A
Host B
Question is termination easier than
establishment? Or to say, is it possible that a
connection is closed when both of two parties
confirm with each other?
FIN, seq 5086
ACK 5087
Data (150 bytes), seq. 303, ACK 5087
ACK 453
No, Saying goodbye is hard to do. Famous blue-red
armies problem.
FIN, seq. 453, ACK 5087
ACK 454
Figure 8.27
17Back to TCP protocol
Thick lines normal client states Dashed lines
normal server states
CLOSED
passive open, create TCB
applic.close
active open,create TCB send SYN
LISTEN
receive SYN, send SYN, ACK
receive RST
send SYN
applic. close or timeout, delete TCB
SYN_SENT
SYN_RCVD
receive SYN, send ACK
receiveACK
receive SYN, ACK, send ACK
applic. close, send FIN
ESTABLISHED
receive FIN, send ACK
applic. close, send FIN
CLOSE_WAIT
receive FIN send ACK
applic. close send FIN
CLOSING
FIN_WAIT_1
receive ACK
LAST_ACK
receive ACK
receive ACK
receive FIN, ACK send ACK
receive FIN send ACK
2MSL timeout delete TCB
FIN_WAIT_2
TIME_WAIT
Figure 8.28
18Sequence number wraparound and timestamps
- Original TCP specification for MSL (Maximum
Segment Lifetime) is 2 minutes. - How long will it take to wrap around 32 bit
sequence number when 2324,294,967,296 bytes have
been sent (maximum window size231) - T-1 line, (232?8)/(1.544 ? 106) 6 hours
- T-3 line, (232?8)/(45 ? 106) 12 minutes
- OC-48 line, (232?8)/(2.4 ? 109) 14 seconds !!!
- When sequence number wrap around, the
wraparounded sequence number will confuse with
previous sequence number. - Solution optional timestamp field (32 bits) in
TCP header, thus, 232?232264 is big enough right
now.
19Internet routing protocols
- Autonomous system (AS)
- A set of routers or networks technically
administrated by a single organization. - No restriction that an AS must run a single
routing protocol - Only requirement is that from outside, an AS
presents a consistent picture of which ASs are
reachable through it. - Three types of ASs
- Stub AS has only a single connection to outside.
- Multihomed AS has multiple connections to
outside, but refuses to carry out transit traffic - Transit AS multiple connections to outside and
carry transit traffic. - ASs need to be assigned globally unique AS number
(ASN)
20Classification of Internet routing protocols
- IGP (Interior Gateway Protocol)
- For routers to communicate within an AS and
relies on IP address to construct paths. - Provides a map of a county dealing with how to
reach each building. - RIP (Routing Information Protocol) distance
vector - OSPF (Open Shortest Path First) link state
- EGP (Exterior Gateway Protocol)
- For routers to communicate among different ASs
and relies on AS numbers to construct AS paths. - Provides a map of a country, connecting each
county. - BGP (Border Gateway Protocol) (distance) path
vector
21RIPRouting Information Protocol
- Distance vector
- On top of UDP with port 520
- Metric is number of hops
- Maximum number of hops is 15, 16 stands for
infinity - Using split-horizon with poisoned reverse.
- May speed up convergence by triggered updates.
- Routers exchange distance vector every 30 seconds
- If a router does not receive distance vector from
its neighbor X within 180 seconds, the link to X
is considered broken and the router sets the cost
to X is 16 (infinity). - RIP-2 contains more information subnet mask,
next hop, routing domain, authentication, CIDR
22RIP message format
- Command 1 request other routers to send routing
information - 2 a response containing its routing information
2. Version 1 or 2 3. Up to 25 routing
information message 3.1 Family identifier
only 2 for IP address 3.2 IP address can be a
host address or a network address 3.3 Metric
115. 16 indicates infinity
Problems of RIP not scalable, slow convergence,
counting-to-infinity, therefore replaced By OSPF
in 1979.
Figure 8.32
23OSPFOpen Shortest Path First
- Flooding LSP to all routers
- Partitioning ASs into areas to improve
scalability, thus two level hierarchical routing. - Calculating multiple routes to a given
destination. - Supporting for variable-length subnetting
- A more flexible link cost 1 to 65535
- Balancing traffic over multiple paths having
equal cost - Supporting authentication
- Multicast rather than broadcast to reduce load on
systems which do not understand OSPF - Using designated router on multiaccess networks
to reduce the number of OSPF messages
24OSPF areas
To another AS
R1
N1
N5
R3
R6
R7
N2
N4
R2
N6
R4
R5
N3
Area 0.0.0.0
Area 0.0.0.1
R8
Area 0.0.0.2
N7
Areas like cities or towns in a county. Area
0.0.0.0 is called backbone area.
R router N network
Area 0.0.0.3
Internal routers just within an area, e.g,
R1,R3,R7 Area border routers connect to more
than one area, e.g., R3,R6,R8 Backbone routers
connect to the backbone, e.g., R2,R4,R5,R6,R8 Auto
nomous system boundary routers connect to other
ASs, e.g., R4.
Figure 8.33
25OSPF routing (cont.)
- Neighbors the routers having an interface to a
common network - multiaccess networks a set of routers that can
communicate directly with each other. - Designated router in multiaccess networks the
router responsible for routing information
exchange on behalf of the entire multiaccess
network. - Adjacent if two routers are neighbors and
connected by a link, then they are called
adjacent. For a multiaccess network, the
designated router and other routers are called
adjacent. There is no adjacent relationship among
non-designated routers of a multiaccess network.
The purpose of adjacent relation is that OSPF
only exchange (flood) routing information among
adjacent routers to reduce the routing
information exchange.
26OSPF routing (cont.)
- OSPF runs over IP, with port number 89.
- Five types of OSPF packets hello, database
description, link-state-request, link-state
update, link-state ACK. - OSPF operations
- Neighbors are discovered via the sending of hello
messages and designated routers are elected in
multiaccess networks - Adjacent relationships are established and
link-state database are synchronized - Link-state advertisements (LSAs) are exchanged
- (flooded) among adjacent routers reliably (i.e.,
the receiver of a routing information gives ACK.
27OSPF routing (cont.)
- In summary
- 0. Using hello messages, neighbors, designated
routers and adjacent relationship are established - Using flooding among adjacent routers, each
router informs all the other routers in its area
of its neighbors and costs. - Using these link state information, each internal
router/area border router constructs a graph for
its area/areas and computes its intraarea
routes/interarea routes. The backbone routers do
the same and compute interarea routes among all
areas. - As a result, intraarea routing and interarea
routing.
28Border Gateway Protocol
- InterAS routing protocol
- (Distance) Path-vector protocol not keep cost
(distance) to each destination, but keep exact
AS path to the destination - In order to exchange routing information, the TCP
connection was established - TCP connection is 179.
- Routing decision is mainly based on policies, not
the reachability - Initially complete routing information are
exchanged, then incremental updates are sent.
29IPv6 (IPng)
- IPv4 is very successful but the victim of its own
success. - IPv6 Keeps IPv4 connectionless feature, with
changes - Longer address fields 16 bytes (128 bits)
- Simplified header format, no checksum,IHL,identifi
cation,flag, offset - Flexible support for options
- Flow label capacity identify certain QoS flow
- Security built-in authentication and
confidentiality. - Large packets longer 64Kbytes, called jumbo
payload - Fragmentation at source only routers not allowed
to do fragment - No checksum field since upper level (TCP, UDP)
and lower level (Ethernet, token-ring) have
error-check capacity, removing error check from
IP layer is not a big problem.
30Internet multicast
- A packet is to be sent to multiple hosts with the
same multicast address - Class D multicast addresses e.g.,
- 224.0.0.1 all systems on a LAN
- 224.0.0.2 all routers on a LAN
- 224.0.0.5 all OSPF routers on a LAN
- 224.0.0.6 all designated OSPF routers on a LAN
- It is not efficient to implement multicast by
unicast, i.e., the source sends a separate copy
for every destination. - Reverse-path broadcasting / multicasting, each
packet is transmitted once per link - IGMP (Internet Group Management Protocol) allow
a user to join a multicast group and let routers
to collect multicast group membership
information.
31DHCP (Dynamic Host Configuration Protocol)
- A host broadcasts a DHCP discovery message in its
physical network for an IP address. - Server(s) reply with DHCP offer message
- The host selects one IP address and broadcasts a
DHCP request message including the IP address - The selected server allocates the IP address and
sends back a DHCP ACK message with a lease time
T, two thresholds T1 (0.5T), T2(0.875T) - when T1 expires, the host asks the server for
extension. - If T2 expire, the host broadcasts DHCP request
to any server on the network - If T expires, the host relinquishes the IP
address and reapply from scratch.
32Mobile IP
- Mobile host, home agent, foreign agent
- If mobile host is currently at the same network
with HA (home agent), the packet to the mobile
host will be broadcast to it. - If mobile host moves to another network,
- the mobile host will register itself with FA
(foreign agent) and gets a new care-of IP
address. Then packet is sent to HA, which will
forward to the FA and FA continues to forward to
destination.
33Deliver packets to mobile host through home agent
and foreign agent
Foreign network
Home network
Foreign agent
Mobile host
2
Home agent
Internet
3
1
Correspondent host
Figure 8.29