You are on page 1of 16

Transport Overview and UDP

Transport Layer 3-1


Goals
 Understand transport services
 Multiplexing and Demultiplexing
 Reliable data transfer
 Flow control
 Congestion control

 TCP and UDP

Transport Layer 3-2


Transport services and protocols
 provide logical communication application
transport
between app processes network
data link
running on different hosts physical
network
data link
network physical

lo
 transport protocols run in end data link

icg
physical
systems

al
network

en
data link

d
 send side: breaks app

-e
physical network

nd
data link
messages into segments, physical

tr
a
passes to network layer network

ns
data link

po
physical

rt
 rcv side: reassembles
segments into messages, application
transport
passes to app layer network
data link
 more than one transport physical

protocol available to apps


 Internet: TCP and UDP

Transport Layer 3-3


Transport vs. network layer
 network layer: logical Household analogy:
communication 12 kids sending letters to
between hosts 12 kids
 transport layer: logical  processes = kids
communication  app messages = letters
between processes in envelopes
 relies on, enhances,  hosts = houses
network layer services
 transport protocol =
Ann and Bill
 network-layer protocol
= postal service

Transport Layer 3-4


Internet transport-layer protocols
 reliable, in-order application
transport

delivery (TCP) network


data link network
physical
congestion control
data link
 network physical

lo
data link

g
flow control

ic
 physical

al
network

en
 connection setup data link

d
-e
physical network

nd
data link
 unreliable, unordered physical

tr
a
delivery: UDP
network

ns
data link

po
physical

rt
 no-frills extension of
“best-effort” IP application
transport
network
 services not available: data link
physical

 delay guarantees
 bandwidth guarantees

Transport Layer 3-5


Multiplexing/demultiplexing
Demultiplexing at rcv host: Multiplexing at send host:
gathering data from multiple
delivering received segments
sockets, enveloping data with
to correct socket
header (later used for
demultiplexing)
= socket = process

P3 P1
P1 P2 P4 application
application application

transport transport transport

network network network

link link link

physical physical physical

host 2 host 3
host 1
Transport Layer 3-6
How demultiplexing works
 host receives IP datagrams
 each datagram has source IP address,
destination IP address 32 bits
 each datagram carries 1 transport-
layer segment source port # dest port #
 each segment has source, destination
port number
(recall: well-known port numbers for other header fields
specific applications)
 host uses IP addresses & port numbers to
direct segment to appropriate socket

application
data
(message)

TCP/UDP segment format

Transport Layer 3-7


Connectionless demultiplexing
 When host receives UDP
 Create sockets with port
numbers: segment:
DatagramSocket mySocket1 = new
 checks destination port
DatagramSocket(99111); number in segment
DatagramSocket mySocket2 = new  directs UDP segment to
DatagramSocket(99222); socket with that port
 UDP socket identified by number
 IP datagrams with
two-tuple:
(dest IP address, dest port number) different source IP
addresses and/or source
port numbers directed
to same socket

Transport Layer 3-8


Connectionless demux (cont)
DatagramSocket serverSocket = new DatagramSocket(6428);

P2 P1
P1
P3

SP: 6428 SP: 6428


DP: 9157 DP: 5775

SP: 9157 SP: 5775


client DP: 6428 DP: 6428 Client
server
IP: A IP: C IP:B

SP provides “return address”

Transport Layer 3-9


Connection-oriented demux
 TCP socket identified  Server host may support
by 4-tuple: many simultaneous TCP
 source IP address sockets:
 source port number  each socket identified by
 dest IP address its own 4-tuple
 dest port number  Web servers have
 recv host uses all four different sockets for
values to direct each connecting client
segment to appropriate  non-persistent HTTP will
socket have different socket for
each request

Transport Layer 3-10


Connection-oriented demux
(cont)

P1 P4 P5 P6 P2 P1P3

SP: 5775
DP: 80
S-IP: B
D-IP:C

SP: 9157 SP: 9157


client DP: 80 DP: 80 Client
server
IP: A S-IP: A
IP: C S-IP: B IP:B
D-IP:C D-IP:C

Transport Layer 3-11


Connection-oriented demux:
Threaded Web Server

P1 P4 P2 P1P3

SP: 5775
DP: 80
S-IP: B
D-IP:C

SP: 9157 SP: 9157


client DP: 80 DP: 80 Client
server
IP: A S-IP: A
IP: C S-IP: B IP:B
D-IP:C D-IP:C

Transport Layer 3-12


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

Transport Layer 3-13


UDP: more
 often used for streaming
multimedia apps 32 bits
 loss tolerant
Length, in source port # dest port #
 rate sensitive bytes of UDP length checksum
segment,
 other UDP uses
including
 DNS header
 SNMP
 reliable transfer over UDP: Application
add reliability at data
application layer (message)
 application-specific
error recovery!
UDP segment format

Transport Layer 3-14


UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment

Sender: Receiver:
 treat segment contents as  compute checksum of received
sequence of 16-bit segment
integers  check if computed checksum
 checksum: addition (1’s equals checksum field value:
complement sum) of  NO - error detected

segment contents  YES - no error detected.


 sender puts checksum But maybe errors
value into UDP checksum nonetheless? More later ….
field

Transport Layer 3-15


Internet Checksum Example
 Note
 When adding numbers, a carryout from the
most significant bit needs to be added to the
result
 Example: add two 16-bit integers

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 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-16

You might also like