3rd Edition: Chapter 3 - Wayne State University
Download
Report
Transcript 3rd Edition: Chapter 3 - Wayne State University
Transport Layer
Our goals:
understand principles
behind transport
layer services:
multiplexing/demultipl
exing
reliable data transfer
flow control
congestion control
learn about transport
layer protocols in the
Internet:
UDP: connectionless
transport
TCP: connection-oriented
transport
TCP congestion and flow
control
Transport Layer
3-1
Recap: Internet protocol stack
application: supporting network
applications
FTP, SMTP, HTTP
transport: process-process data
transfer
TCP, UDP
network: host-host data transfer
IP
link: data transfer between
neighboring network elements
application
transport
network
link
physical
PPP, Ethernet
physical: bits “on the wire”
Transport Layer
3-2
source
message
segment Ht
datagram Hn Ht
frame
Hl Hn Ht
M
M
M
M
Encapsulation
application
transport
network
link
physical
Hl Hn Ht
M
link
physical
Hl Hn Ht
M
switch
destination
M
Ht
M
Hn Ht
Hl Hn Ht
M
M
application
transport
network
link
physical
Hn Ht
Hl Hn Ht
M
M
network
link
physical
Hn Ht
Hl Hn Ht
M
M
router
Transport Layer
3-3
TL: Outline
3.1 Transport-layer
services
3.2 Multiplexing and
demultiplexing
3.3 Connectionless
transport: UDP
3.4 Principles of
reliable data transfer
3.5 Connection-oriented
transport: TCP
segment structure
reliable data transfer
flow control
connection management
3.6 Principles of
congestion control
3.7 TCP congestion
control
Transport Layer
3-4
Transport services and protocols
provide
logical communication
between app processes
running on different hosts
transport protocols run in
end systems
send side: breaks app
messages into segments,
passes to network layer
(Multiplexing)
rcv side: reassembles
segments into messages,
passes to app layer
(DeMultiplexing)
more than one transport
protocol available to apps
TCP and UDP
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
Transport Layer
3-5
Transport vs. network layer
network layer: logical
communication between
hosts
transport layer: logical
communication between
processes
relies on, enhances,
network layer services
Constrained by network
layer service: e.g. bounded
delay
Enhancement: e.g. reliable
data transfer, encryption
to guarantee message
secrecy
Household analogy:
12 kids sending letters to 12 kids
processes = kids
app messages = letters in
envelopes
hosts = houses
transport protocol = Ann and
Bill: mail service to
collect/distribute mails
Susan/Harvey can provide
another type of mail service
network-layer protocol = postal
service
Transport Layer
3-6
Internet transport-layer protocols
IP service model
Host-to-host best-effort delivery
service, datagram
Unreliable serivce
application
transport
network
data link
physical
UDP: unreliable, unordered delivery
Proc to proc segment delivery: nofrills extension of “best-effort” IP
(Multiplexing /demultiplexing)
Error checking
TCP:
reliable, in-order delivery: flow
control, sequence number, ack, timer,
etc
congestion control to prevent TCP
connection from swamping the links
and switches
services not available in either TCP
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
or UDP:
delay guarantees
bandwidth guarantees
Transport Layer
3-7
Multiplexing/demultiplexing (encode/decode)
Demultiplexing at rcv host:
Multiplexing at send host:
The job of delivering received
transport-layer segments to correct socket.
The job of gathering data from different
sockets, enveloping data with header
(later used for demultiplexing) and passing
the data to the network layer.
= socket
application
transport
network
link
Each socket has a unique identifier (a set of
fields in each segment)
= process
P3
P1
P1
application
transport
network
P2
P4
application
transport
network
link
link
physical
host 1
physical
host 2
physical
host 3
Transport Layer
3-8
How demultiplexing works
host receives IP datagrams
each datagram has source and
destination IP addresses
each datagram carries 1
transport-layer segment
each segment has source,
destination port number
(ranges from 0-65535)
0~1023 well-known ports
host/OS uses IP addresses &
port numbers to direct segment
to appropriate socket
Note the naming convention:
IP datagrams vs TCP/UDP segments
32 bits
source port #
dest port #
other header fields
application
data
(message)
TCP/UDP segment format
Transport Layer
3-9
Connectionless demultiplexing
Create UDP sockets with
port numbers; the OS
assigns ports if not
specified by programmer:
DatagramSocket mySocket1 = new
DatagramSocket(99111);
DatagramSocket mySocket2 = new
DatagramSocket();
UDP socket is identified by
two-tuple:
(dest IP address, dest port number)
When host/server
receives UDP segment:
checks destination port
number in segment
directs UDP segment to
socket with that port
number
IP datagrams with
different source IP
addresses and/or source
port numbers directed
to same socket
Transport Layer 3-10
Connectionless demux (cont)
DatagramSocket serverSocket = new DatagramSocket(6428);
P2
port 9157
One Server
Socket
P3
DP: 6428
port 6428
SP: 6428
SP: 6428
DP: 9157
DP: 5775
SP: 9157
client
IP: A
P1
P1
port 5775
SP: 5775
server
IP: C
DP: 6428
Client
IP:B
SP = Source Port, DP = Destination Port
Source Packet provides “return address” that destination host can use to reply
Transport Layer
3-11
Connection-oriented demux
TCP socket identified by 4-
tuple:
source IP address
source port number
dest IP address
dest port number
Server host may support
many simultaneous TCP
sockets:
recv host uses all four
values to direct segment to
appropriate socket
each socket identified by its
own 4-tuple
TCP server appl has a
“welcome socket”, waiting for
conneciton-setup requests
Web servers have different
sockets for each connecting
client
non-persistent HTTP will
have different socket for
each request because it reconnects at each request.
Transport Layer 3-12
Recap: Client/server TCP socket interaction
Server (running on hostid)
Client
create socket,
port=x, for
incoming request:
welcomeSocket =
ServerSocket()
TCP
wait for incoming
connection request connection
connectionSocket =
welcomeSocket.accept()
read request from
connectionSocket
write reply to
connectionSocket
close
connectionSocket
setup
create socket,
connect to hostid, port=x
clientSocket =
Socket()
send request using
clientSocket
read reply from
clientSocket
close
clientSocket
Transport Layer 3-13
Connection-oriented demux
(Web Server example 1)
P1
Three Server
Sockets
P4
P5
P2
P6
P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
SP: 9157
client
IP: A
DP: 80
S-IP: A
D-IP:C
SP: 9157
server
IP: C
DP: 80
S-IP: B
D-IP:C
Client
IP:B
SP = Source Port, DP = Destination Port, S-IP = Source IP, D-IP = Destination IP
Transport Layer 3-14
Connection-oriented demux:
(Web Server example 2)
P1
P2
P4
P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
SP: 9157
client
IP: A
DP: 80
S-IP: A
D-IP:C
SP: 9157
server
IP: C
DP: 80
S-IP: B
D-IP:C
Client
IP:B
Transport Layer 3-15
Transport Layer: Outline
3.1 Transport-layer
services
3.2 Multiplexing and
demultiplexing
3.3 Connectionless
transport: UDP
3.4 Principles of
reliable data transfer
3.5 Connection-oriented
transport: TCP
segment structure
reliable data transfer
flow control
connection management
3.6 Principles of
congestion control
3.7 TCP congestion
control
Transport Layer 3-16
UDP: User Datagram Protocol [RFC 768]
“no frills,” “bare bones”
Internet transport
protocol
“best effort” service, UDP
segments may be:
lost
delivered out of order
to app
connectionless:
no handshaking between
UDP sender, receiver
each UDP segment
handled independently
of others
Why is there a UDP?
no connection establishment
(which can add delay)
simple: no connection state
(parameters,buffers) at
sender, receiver
small segment header, 8
bytes for UDP vs 20 bytes
for TCP per segment.
Finer application control on
what and when to send
data.no congestion control.
Transport Layer 3-17
Internet Applications that use UDP
Domain Name Service (DNS):
DNS would be much slower if it ran over TCP
Network Management Applications: using Simple Network
Management Protocol (SNMP):
they often run when the network is in a stressed state and TCP and
its overhead is difficult to achieve.
Multimedia appl: Internet phone, real-time video conf. that
can tolerate small packet loss and is sensitive to transfer rates.
reliability can be built into the application that have their own
acknowledgements and retransmissions techniques.
• But UDP senders may crowd out TCP sessions
Application
electronic mail
remote terminal access
Web
file transfer
remote file server
streaming multimedia
Internet telephony
Network Management
Routing Protocol
Name Translation
Application-layer protocol
SMTP
Telnet
HTTP
FTP
NFS
proprietary
proprietary
SNMP
RIP
DNS
Transport Protocol
TCP
TCP
TCP
TCP
typically UDP
typically UDP
typically UDP
typically UDP
typically UDP
typically UDP
Transport Layer 3-18
UDP Segment Structure
UDP segment has an 8 byte
header.
Length of UDP segment, in
bytes, including header.
Minimum length is 8 and
maximum is 64k.
32 bits
source port #
dest port #
length (16-bit)
checksum (16-bit)
Application
data
(message)
UDP segment format
Transport Layer 3-19
UDP checksum
Goal: detect “errors” due to noise or router storage (e.g., flipped
bits) in transmitted segment. A damaged packet is sometimes
passed to the appl. with a warning or sometime discarded.
Sender:
Receiver:
treat segment contents
compute sum of all 16-bit
as sequence of 16-bit
integers (words)
checksum: 1’s complement
of the addition of all
segment words with
overflow wrapped around
sender puts checksum
value into UDP checksum
field
words including checksum in
received segment
check if computed sum equals
all 1’s:
NO - error detected
YES - no error detected.
All 1-bit errors will be detected
but two-bit errors can be undetected
Transport Layer 3-20
Internet Checksum: Sender Example
Note
When adding numbers, a carryout from the most
significant bit needs to be added to the result
Segment has two 16-bit integers and the checksum
Add the two 16-bit integers
compute the checksum by taking the 1’s complement of the
sum.
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound:
add carry to LSB
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
Transport Layer 3-21
Internet Checksum: Receiver Example - no errors
Compute the sum of all 16-bit words including the
checksum.
If All 1’s then no error
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound:
add carry to LSB
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
sum (All 1s)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Transport Layer 3-22
Checksum: Receiver Example - 1 bit error
Compute the sum of all 16-bit words including the
checksum.
If All 1’s then no error
Flipped bit
1 1 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound:
add carry to LSB
1 1 0 1 1 1 0 1 1 1 1 0 0 0 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
sum (not all 1s)
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
Transport Layer 3-23
Checksum: Receiver Example - 3 bit error undetected
Compute the sum of all 16-bit words including the
checksum.
If All 1’s then no error !
Flipped bits circled
1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
sum (All 1s)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Transport Layer 3-24
Why Checksum at TL layer
No guarantee that all the links between src
and dest provide error checking
Bit errors may be introduced in a router’s
memory
An example of end-to-end design principle
End-to-end data transfer with error detection
Transport Layer 3-25
Summary
Transport layer vs Network layer
logical communication between processes vs between hosts
Transport Layer minimum services:
Multiplexing and DeMultiplexing of application layer packets
Data error handling via checksums.
Difference between Multiplexing at send host vs Demultiplexing at rcv
host
UDP Socket vs TCP Socket identification parameters
(dest-IP, dest-port) vs (source-IP, source-port, dest-IP, destport)
UDP Advantages over TCP and what type of applications use it.
UDP Segment Structure and the checksum calculation for handling 1bit errors
Transport Layer 3-26