Unit IV Revised Transport Layer
Unit IV Revised Transport Layer
H1 H2 H3 H4
H5
10.0.1.2 10.0.1.3 10.0.1.2 10.0.1.3
213.168.112.3
10.0.1.1 10.0.1.1
Private network 1 Private network 2
Internet
Router/NAT Router/NAT
128.195.4.119 128.143.71.21
• ARP(Address Resolution
Protocol)
Types of Addresses in Internet
• Media Access Control (MAC) addresses :
▫ Associated with network interface card (NIC)
▫ 48 bits or 64 bits
• IP addresses for the network layer
▫ 32 bits for IPv4, and 128 bits for IPv6
▫ E.g., 123.4.56.7
• IP addresses + ports for the transport layer
▫ E.g., 123.4.56.7:80
• Domain names for the application/human
layer
▫ E.g., www.google.com
IP And MAC working together
•IP addresses are chosen by the local system
administrator to suit the local network
• The DHCP server receives the request, assigns a new address for a
specific time period (called a lease period) and sends it to the client
together with the other required configuration information.
• The DHCP server will not reallocate the address during the lease period
and will attempt to return the same address every time the client requests
an address.
• The client may extend its lease with subsequent requests, and may send a
message to the server before the lease expires telling it that it no longer
needs the address so it can be released and assigned to another client on
the network.
DHCP procedures
• Obtaining a new address
• Reusing a previously allocated address
Allocating new address
Server (not selected) Client Server (selected)
Sent on Ethernet DHCP DISC. DHCP DISC.
broadcast address
DHCPOF FER
FE R DHCPOF
Client selects
DHCP REQ.
Collects repliesDHCP REQ. configuration;
Also broadcast
in DCHP REQ
CK
DHCPA it accepts one
server’s offer
Initialization Complete (server identifier
option)
Graceful Shutdown
and implicitly
DHCPRELEASE reject rest
Discard lease
What happens if there is no DHCP server on a network and an IP host
connects to it with the “Obtain IP address automatically” option
selected?
lo
• transport protocols run in end
gi
ca
systems
enl
d-
– send side: breaks app
en
messages into segments,
d
tr
a
passes to network layer
ns
po
– rcv side: reassembles
tr
segments into messages, applicatio
n
passes to app layer transport
network
• more than one transport data link
physical
protocol available to apps
– Internet: TCP and UDP
lo
data link
network
gi
physical
data link
– flow control
ca
physical
l en
– connection setup
d-
en
network
d
data link
tr
a
physicalnetwork
ns
• unreliable, unordered data link
po
physical
rt
delivery: UDP network
data link
applicatio
physical network n
– No congestion control data link transport
physical network
– No flow control data link
physical
– No need for connection
setup
– Supports broadcast and
multicast 3-31
UDP: User Datagram Protocol [RFC 768]
• “best effort” service, UDP TCP – 20 bytes, UDP – 8 bytes
segments may be:
– lost
Why is there a UDP?
• no connection establishment
– delivered out of order to
(which can add delay)
app
• simple: no connection state
• connectionless:
at sender, receiver
– no handshaking between
• small segment header
UDP sender, receiver
• no congestion control: UDP
– each UDP segment
can blast away as fast as
handled independently of
desired
others
UDP header format
32 bits
Application
data
(message)
Sender: Receiver:
• treat segment contents as • compute checksum of received
sequence of 16-bit integers segment
• checksum: addition (1’s • check if computed checksum
complement sum) of segment equals checksum field value:
contents – NO - error detected
• sender puts checksum value – YES - no error detected.
into UDP checksum field
UDP checksum example:
• Three packets of 16 bits • The 1’s complement of
each ‘r’ is:
– 0110011001100110 – 0011010100110101
– 0101010101010101 • at destination, the sum
– 0000111100001111 of four packets should
• adding the three, calling be:
it ‘r’: – 1111111111111111
– 1100101011001010 • If the packet is
• Send the four packets, damaged:
the original three and – 1111101111111111
1’s complement of ‘r’ to (zeros!!)
zeros!!
destination
39
Typical TCP Transaction
Client Server
• A TCP Transaction
consists of 3 Phases
1. Connection Establishment
Handshaking between
Connection Establishment
client and server
Connection Termination
3. Connection Termination
Closing the connection
time time
TCP Connection Establishment
• TCP sender, receiver establish “connection” before
exchanging data segments
handshake:
Connection
Step 1: client host sends TCP request
SYN
SYN segment to server , S eq
=42 host ACKs
– specifies a random initial and selects
seq # 3 its own
CK =4
– no data 79 , A initial seq #
q=
K , Se
Step 2: server host receives SYN, Y N+ AC
S
replies with SYNACK segment
host ACKs
– server allocates buffers ACK
, Seq
– specifies server initial seq. =43,
A CK=8
# 0
Connection
request
SYN
Seq. #’s: , S eq
=42 host ACKs
– byte stream “number” of and selects
first byte in segment’s data 3 its own
CK =4
ACKs: 79 , A initial seq #
q=
K , Se
– seq # of next byte expected Y N+ AC
S
from other side
host ACKs
– cumulative ACK
ACK
, Seq
=43,
A CK=8
0
time time
Three-way handshake
TCP Connection Termination
Closing a connection:
client closes socket: client server
clientSocket.close(); close
FIN
Step 1: client end system
sends TCP FIN control
segment to server
ACK DATA Data
Step 2: server receives FIN, ACK write
replies with ACK. Server
might send some buffered FIN
timed wait
but not sent data before close
ACK
closing the connection.
Server then sends FIN and
moves to Closing state. closed
Byte stream to TCP Segment
…Emulated Using TCP
“Segments”
Host A
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
TCP Data
Host B
Byte 0
Byte 1
Byte 2
Byte 3
Byte 80
46
Sequence Numbers
Host A
ISN (initial sequence number)
Sequence TCP
TCP Data
number = 1st HDR
47
TCP Segment
IP Data
TCP Data (segment) TCP Hdr IP Hdr
• IP packet
– No bigger than Maximum Transmission Unit (MTU)
– E.g., up to 1500 bytes on an Ethernet
• TCP packet
– IP packet with a TCP header and data inside
– TCP header is typically 20 bytes long
• TCP segment
– No more than Maximum Segment Size (MSS) bytes
–
48 E.g., up to 1460 consecutive bytes from the stream
Flow control and Reliability
• Flow control (process-to-process): TCP makes sure that the sender does not cause
the receiver buffer to overflow
– By defining the amount of data that can be sent before receiving an acknowledgement
from the receiver (sliding – window protocols)
• Error control (process-to-process): entire message arrives at the receiving
transport layer without error, loss, duplication and in the same order they
were sent
– Error detection is done using checksum and correction by retransmission
– Implemented by a sliding window ARQ
– Every transmission of data is acknowledged by the receiver.
– Acknowledgements are cumulative.
– If the sender does not receive ACK within a specified amount of time, the sender
retransmits the data.
– Accepts out of order but does Not send negative acknowledgements,
– if a segment is not acknowledged before time-out, it is considered to be either
corrupted or lost and the sender will retransmit the segment only when it times-out
TCP Flow Control
• receive side of TCP flow control
sender won’t
connection has a receive overflow
buffer: receiver’s buffer by
transmitting too
much,
too fast
• speed-matching
service: matching the
send rate to the
receiving app’s drain
rate
app process may be
slow at reading from
buffer
Transport Layer 3-50
TCP Flow control: how it works
• Rcvr advertises spare
room by including value
of RcvWindow in
segments
• Sender limits unACKed
(Suppose TCP receiver data to RcvWindow
discards out-of-order – guarantees receive buffer
segments) doesn’t overflow
• spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd -
LastByteRead]
Increase utilization
by a factor of 3!
3*L/ R .024
U = = = 0.0008
sender 30.008
RTT +L / R microsecon
ds
ex: 1 Gbps link, 15 ms prop. delay, 8000 bit packet: 3-54
Pipelining Protocols
Go-back-N: big picture: Selective Repeat: big pic
• Sender can have up to N • Sender can have up to N
unacked packets in unacked packets in
pipeline pipeline
• Rcvr only sends • Rcvr acks individual
cumulative acks packets
– Doesn’t ack packet if • Sender maintains timer
there’s a gap for each unacked packet
• Sender has timer for – When timer expires,
oldest unacked packet retransmit only unack
– If timer expires, retransmit packet
all unacked packets
Congestion:
• informally: “too many sources sending too much data
too fast for network to handle”.
• different from flow control!
• manifestations:
– lost packets (buffer overflow at routers)
– long delays (queueing in router buffers)
16 K bytes
8 K bytes
time
RTT
loss event:
two segm
– double CongWin every en ts
RTT
– done by incrementing
four segm
CongWin for every ACK ents
received
• Summary: initial rate is
slow but ramps up
exponentially fast time