Transport layer

Download Report

Transcript Transport layer

CS 1652
Jack Lange
University of Pittsburgh
The slides are adapted from the publisher’s material
All material copyright 1996-2009
J.F Kurose and K.W. Ross, All Rights Reserved
1
Chapter 3: Transport Layer
r Principles behind
transport layer
services:
m
multiplexing and
demultiplexing
m
reliable data transfer
m
flow control
m
congestion control
Transport layer protocols in
the Internet:
m
UDP: connectionless transport
TCP: connection-oriented
transport
•
TCP congestion control
m
Transport Layer
3-3
Transport-layer services
4
Transport services and protocols
r
provide logical communication
between app processes running
on different hosts
r
transport protocols run in end
systems
r
m
send side: breaks app
messages into segments,
passes to network layer
m
recv side: reassembles
segments into messages,
passes to app layer
application
transport
network
data link
physical
application
transport
network
data link
physical
more than one transport
protocol available to apps
m
Internet: TCP and UDP
Transport Layer
3-5
Transport vs. network layer
r network layer: logical
communication
between hosts
r transport layer: logical
communication
between processes
m
relies on, enhances,
network layer services
Soon to be outdated analogy:
Sending a letter
•
processes = people
•
app messages = letters in
envelopes
•
hosts = offices
•
transport protocol = Mail
room
•
network-layer protocol =
postal service
Transport Layer
3-6
Internet transport-layer protocols
r
r
reliable, in-order delivery
(TCP)
m
congestion control
m
flow control
m
connection setup
unreliable, unordered
delivery: UDP
m
r
no-frills extension of
“best-effort” IP
services not available:
m
delay guarantees
m
bandwidth guarantees
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
network
data link
physical
application
transport
network
data link
physical
Transport Layer
3-7
Multiplexing and Demultiplexing
8
Multiplexing/demultiplexing
Multiplexing at send host:
Demultiplexing at recv host:
gathering data from multiple
sockets, enveloping data with
header (later used for
demultiplexing)
delivering received segments
to correct socket
= socket
application
transport
network
link
= process
P3
P1
P1
application
transport
network
P2
P4
application
transport
network
link
link
physical
host 1
physical
host 2
What information is used to demultiplex?
physical
host 3
Transport Layer
3-9
How demultiplexing works
r
host receives IP datagrams
m
r
each datagram has source
IP address, destination IP
address
m
each datagram carries 1
transport-layer segment
m
each segment has source,
destination port number
host uses IP addresses &
port numbers to direct
segment to appropriate
socket
32 bits
source port #
dest port #
other header fields
application
data
(message)
TCP/UDP segment format
Transport Layer 3-10
Connectionless demultiplexing
r UDP dest socket identified
r
When host receives UDP
segment:
m checks destination port
number in segment
m directs UDP segment to
socket with that port
number
r
IP datagrams with different
source IP addresses and/or
source port numbers directed
to same socket
by two-tuple:
(dest IP address, dest port number)
r Source port available to
apps that need it
Transport Layer
3-11
Connectionless demux (cont)
P2
client
IP: A
P1
P1
P3
SP: 6428
SP: 6428
DP: 9157
DP: 5775
SP: 9157
DP: 6428
SP: 5775
server
IP: C
DP: 6428
Client
IP:B
Source port provides “return address”.
What have we seen that would use this?
Transport Layer 3-12
Connection-oriented demux
r TCP socket identified
by 4-tuple:
m
source IP address
m
source port number
m
dest IP address
m
dest port number
r recv host uses all four
values to direct
segment to appropriate
socket
r Server host may support
many simultaneous TCP
sockets:
m
each socket identified by
its own 4-tuple
r Web servers have
different sockets for
each connecting client
m
non-persistent HTTP will
have different socket for
each request
Transport Layer 3-13
Connection-oriented demux
(cont)
P1
P4
P5
P2
P6
P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
client
IP: A
SP: 9157
DP: 80
S-IP: A
D-IP:C
SP: 9157
server
IP: C
DP: 80
S-IP: B
Client
IP:B
D-IP:C
Transport Layer 3-14
Connection-oriented demux:
Threaded Web Server
P1
P2
P4
P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
client
IP: A
SP: 9157
DP: 80
S-IP: A
D-IP:C
SP: 9157
server
IP: C
DP: 80
S-IP: B
Client
IP:B
D-IP:C
Transport Layer 3-15
Connectionless tranport: UDP
16
UDP: User Datagram Protocol [RFC 768]
r
“no frills,” “bare bones”
Internet transport protocol
r
“best effort” service, UDP
segments may be:
r
m
lost
m
delivered out of order to
app
connectionless:
m
no handshaking between
UDP sender, receiver
m
each UDP segment
handled independently of
others
Why is there a UDP?
r no connection establishment
(which can add delay)
r simple: no connection state at
sender, receiver
r small segment header
r no congestion control: UDP can
blast away as fast as desired
r Higher level functionality can
be added by applications
Transport Layer 3-17
UDP: more
r
often used for streaming
multimedia apps
m
loss tolerant
m
rate sensitive
r other UDP uses
r
m
DNS
m
SNMP
Length, in
bytes of UDP
segment,
including
header
reliable transfer over UDP:
add reliability at
application layer
m
application-specific
error recovery!
32 bits
source port #
dest port #
length
checksum
Application
data
(message)
UDP segment format
Transport Layer 3-18
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
Sender:
r
treat segment contents
as sequence of 16-bit
integers
r
checksum: addition (1’s
complement sum) of
segment contents
r
sender puts checksum
value into UDP checksum
field
Receiver:
compute checksum of received
segment
r check if computed checksum
equals checksum field value:
m NO - error detected
m YES - no error detected. But
maybe errors nonetheless?
More later ….
r
Transport Layer 3-19
Internet Checksum Example
r Note
m
When adding numbers, a carryout from the
most significant bit needs to be added to the
result
r Example: add two 16-bit integers
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
1
1
0
1
1
1
0
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
1
0
1
1
1
0
1
1
1
1
0
0
1
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
1
wraparound
checksum
Transport Layer 3-20
Announcements
r
Project 1 DUE (9/24)
m
Project 2 out shortly afterwards
r Two commands that will save hours of your life:
m
m
nc -l <port>
nc <host> <port>