You are on page 1of 17

Computer Networks I

Transport Layer

Prof. Dr.-Ing. Lars Wolf

IBR, TU Braunschweig
Mühlenpfordtstr. 23, D-38106 Braunschweig, Germany,
Email: wolf@ibr.cs.tu-bs.de
Transport Layer

Scope
www.ibr.cs.tu-bs.de

Complementary Courses

Applications
Email
Web

...
Transitions, Address.

L5 Application Layer
L4 Transport Layer Internet: (TCP, UDP, ...)
L3 Network Layer
Computer Networks 1

Internet: (IP, ...)


L2 Data Link Layer LAN, ..., WAN: (ETH, ...)
L1 Physical Layer Other lectures of ET/IT, ...

Introduction

Transport Layer

Overview
1 Transport Layer Function
www.ibr.cs.tu-bs.de

2 Elements of Transport Protocols

3 Addressing (at Transport Layer)

4 Duplicates (at Data Transfer Phase)

5 Reliable Connection Establishment

6 Disconnect
Computer Networks 1

7 Flow Control on Transport Layer

8 Some Familiar Internet Protocols,


a Short Introduction to UDP and TCP

Transport Layer
1 Transport Layer Function
Provide data transport

www.ibr.cs.tu-bs.de
• reliably
• efficiently
• at low-cost

for
• process-to-process (applications)
• i.e. at endsystem-to-endsystem
Computer Networks 1

(if possible) independent from


• particularities of the networks (lower layers) used

Transport Layer

Transport Service
www.ibr.cs.tu-bs.de
Computer Networks 1

Connection oriented service


• 3 phases: connection set-up, data transfer, disconnect
Connectionless service
• transfer of isolated units

Realization: transport entity


• software and/or hardware?
5 • software part usually contained within kernel (process, library)
Transport Layer

Transport Service
Similar services of
www.ibr.cs.tu-bs.de

• network layer
and transport layer:
Why 2 Layers?

Network service
• not influenced by the user
• independent from application & user
• provides, for example,
Computer Networks 1

• “only” connection oriented communications


• or “only” unreliable data transfer

Transport service: improve the quality of Network Service


• provide better service for users (and higher layers)
than given by the network layer, e.g.
• reliable service

Transport Layer
Transport Service: Terminology
Entities exchanged:

www.ibr.cs.tu-bs.de
Layer Data Unit
Transport TPDU / Message
Network Packet
Data Link Frame
Physical Bit/Byte (bitstream)

TPDU: Transport Protocol Data Unit


Computer Networks 1

Nesting of TDPUs, packets, and frames:

Transport Layer

Transport Service Primitives


Berkeley Socket Primitives:
www.ibr.cs.tu-bs.de

Primitive Meaning
SOCKET Create a new communication end point

BIND Attach a local address to a socket

LISTEN Announce willingness to accept connections


Computer Networks 1

ACCEPT Block the caller until a connection attempt arrives

CONNECT Actively attempt to establish a connection

SEND Send some data over the connection

RECEIVE Receive some data from the connection

CLOSE Release the connection


13

Transport Layer

2 Elements of Transport Protocols


Transport service is implemented
www.ibr.cs.tu-bs.de

• by transport protocol used


between the two transport entities

Several issues have to be addressed such as:


• Addressing
• Connection Establishment
• Connection Release
Computer Networks 1

• Flow Control and Buffering


• Multiplexing
• Crash Recovery

14

Transport Layer
Elements of Transport Protocols
Transport protocols resemble somehow data link protocols:

www.ibr.cs.tu-bs.de
• but significant differences exist

Transport and data link


protocols operate in
different environments!

Addressing:
• DL: outgoing line of a router specifies particular router
Computer Networks 1

• TL: explicit addressing of destinations is required


Connection establishment:
• DL: peer is always there
• TL: reachability might be unclear
Storage capacity in the subnet:
• DL: negligible
• TL: serious problem, packet may be stored somewhere and delivered
later
Buffering and flow control:
• DL: few outgoing lines allow simple buffer allocation schemes
• TL: potentially large, dynamically #conn. requires flexible schemes
15

Transport Layer

3 Addressing (at Transport Layer)


Why identification?
www.ibr.cs.tu-bs.de

• sender (process) wants to address receiver (process)


• for connection setup or individual message
• receiver (process) can be approached by the sender (process)

Define transport addresses:


• generic term: (Transport) Service Access Point TSAP
• Internet: port
Reminder: analogous end points in network layer: NSAP
• e.g., IP addresses
Computer Networks 1

Model:

16

Transport Layer

Steps
In general
www.ibr.cs.tu-bs.de

1. Server (service provider)


• connects itself to TSAP 122
• waits for service request
(polling, signalling, ..)
2. Client (application)
• initiates connection via TSAP 6 as source
and TSAP 122 as destination
• i.e. connect.req
3. Transport system on host 1
• identifies dedicated NSAP
Computer Networks 1

• initiates communication at network layer


• communicates with transport entity on
host2
• informs TSAP 122 about desired
connection
4. Transport entity on host 2
• addresses the server
• requests acceptance for the desired
connection
• i.e. connect.ind
5. etc.
17

Transport Layer
Determination of Service Provider TSAP
How does the specific address of a service becomes known?

www.ibr.cs.tu-bs.de
1. Approach: TSAP known implicitly
• services that are well known and often used have pre-defined
TSAPs
• as "well known ports" of a transport protocol
Computer Networks 1

• e.g., stored in /etc/services file at UNIX systems


example: service ’time of day’ (port 13)
Characteristics:
• works well for small number of stable services
• not suitable for user specific processes
• existing for short time, no known TSAP addr
• waste of resources to have seldomly used servers active and
listening
18

Transport Layer

Determination of Service Provider TSAP


2. Approach: “initial connection protocol”
www.ibr.cs.tu-bs.de

1. process server acting as proxy for less often used servers


2. process server listens to set of ports at same time,
waiting for connection requests
3. creates the appropriate service provider process
4. transfers connection and desired service
5. waits for further requests
Characteristics:
• works well for servers which can be created on demand
• not suitable if service exists independently of process server at another
machine (e.g., file server)
Computer Networks 1

19

Transport Layer

Determination of Service Provider TSAP

3. Approach: Name Server (directory server)


www.ibr.cs.tu-bs.de

• context
• server process already exists
• procedure
1. client addresses Name server (establishing connection)
2. client specifies the service as an ASCII data set
• example “name of day”
3. name server supplies TSAP
4. client disconnects from name server
Computer Networks 1

5. client addresses TSAP provided by name server


.....

• comments
• new services
• have to register at the name server
• name server
• adds corresponding information at the database

20

Transport Layer
4 Duplicates
Initial (problematic) situation:

www.ibr.cs.tu-bs.de
• network has
• varying transit times for packets
• certain loss rate
• storage capabilities
• packets can be
• manipulated
• duplicated
• resent by the original system after timeout
Computer Networks 1

In the following, uniform term: “Duplicate”


• a duplicate originates due to one of the above
mentioned reasons and
• is at a later (undesired) point in time passed to the
receiver
22

Transport Layer

Example: Duplicates
Example of problems caused by
www.ibr.cs.tu-bs.de

duplicates:
• Let’s assume duplicates occur in
the network
• duplication of all sender’s packets
• subsequent to the first 5 packets,
duplicates are transferred in
correct order to the receiver

• also conceivable is that an old


delayed DATA packet (with faulty
contents) from a previous session
Computer Networks 1

may appear; this packet might be


processed instead of or even in
addition to the correct packet

Result:
• without additional means the
receiver cannot differentiate
between correct data and
duplicated data
à Receiver would re-execute the
transaction !
23

Transport Layer

Duplicates – Problematic Issues

3 somehow disjoint problems


www.ibr.cs.tu-bs.de

1. How to handle duplicates within a connection?

2. Which characteristics have to be taken into account regarding


• consecutive connections or
• connections which are being re-established after a crash?

3. What can be done to ensure that a connection that has been


established:
• has actually been initiated by and
Computer Networks 1

with the knowledge of both


communicating parties?
• see also lower part of previous illustration

24

Transport Layer
Duplicates – Problematic Issues

3 somehow disjoint problems

www.ibr.cs.tu-bs.de
1. How to handle duplicates within a connection?
àuse consecutive sequential numbers from sufficiently large
sequential number range
• TCP uses 32 bit sequence numbers
• 32 bit was large in 1980ies (link rates were low), but is small today
• sequence number range exploitation
• 10 Mbit/sec ~ 3400 sec (~57 Min)
• 10 Gbit/sec ~ 3,4 sec

2. Which characteristics have to be taken into account regarding


Computer Networks 1

• consecutive connections or
• connections which are being re-established after a crash?
à Choose initial sequential number wisely,
consider max. message lifetime (MSL)

3. What can be done to ensure that a connection that has been


established:
• has actually been initiated by and with the knowledge of both
communicating parties?
25
à Well prepared connection setup: three-way handshake

Transport Layer

5 Reliable Connection Establishment


Simple idea for connection establishment
www.ibr.cs.tu-bs.de

• Use two messages


Computer Networks 1

• approach using 2 messages (2 phases) is too simplistic


• problems may occur due to delayed duplicates
• compare with previous example (bank transaction)
37

Transport Layer

Connect: Three-way Handshake Protocol


Principle
www.ibr.cs.tu-bs.de

1. CR: Connect Request


• initiator (A) sends request with
• SequenceNo (X) selected by
sender
2. CC: Connect Confirmation
• receiver (B) responds with
• sequence number transmitted
by the initiator (X) and
• (randomly) selected sequence
number (Y) by receiver
Computer Networks 1

3. Acknowledgment
• initiator (A) acknowledges
• sequence numbers X, Y (as received before)
• only after receiving a valid ACK, receiver (B) accepts data

Note:
• some protocols (including TCP) acknowledge the next byte expected
• (ACK X+1,Y+1), not the last byte received

38

Transport Layer
Three Way Handshake Protocol: Results

www.ibr.cs.tu-bs.de
Computer Networks 1

CR and data duplicate


• duplicate data is discarded

39

Transport Layer

Three Way Handshake Protocol: Results


www.ibr.cs.tu-bs.de
Computer Networks 1

Connect Request (CR) Duplicate


and Acknowledgment (ACK) Duplicate

• ACK (X,Z) discarded because


• ACK (X, Y) expected
• ACK (X, Z) received,
• Y != Z must be ensured by B under the premise of a maximum packet
lifetime by selecting the initial sequence number accordingly
40

Transport Layer

6 Disconnect
Two variants:
www.ibr.cs.tu-bs.de

• asymmetric disconnect
• symmetric disconnect

Variant: symmetric disconnect


• disconnect takes place separately for each direction

Variant: asymmetric disconnect


Computer Networks 1

• disconnect in one direction implies disconnect for both


“directions”

41

Transport Layer
6.1 Asymmetric Disconnect
Approach

www.ibr.cs.tu-bs.de
• disconnect in one direction implies disconnect for both
“directions”
• analog to telephone
• may result in data losses

Example
Computer Networks 1

è approach for a solution:


• 3 phase-handshake-protocol
• to implement a disconnect like a connect
42

Transport Layer

6.2 Symmetric Disconnect


Idea:
www.ibr.cs.tu-bs.de

avoid data loss incurred by asymmetric disconnect


by using symmetric disconnect
• host can continue to receive data even after it has sent
DISCONNECT TPDU
• both sides have to issue a disconnect
• host received DISC. à stops to send data
• host sent DISC. à may continue to receive data

Properties
Computer Networks 1

• works when each process


has fixed amount of data to
send and knows when it has
sent it (and how much data will arrive)
• not as obvious as considered
if something can go wrong
• if host does not know about
data to be received after having
43 sent a disconnect
Transport Layer

Disconnect with Three-Way Handshake


Regular disconnect with Three-Way handshake
www.ibr.cs.tu-bs.de

Host A Host B
Send DR DR
+ start timer Send DR
+ start timer
DR
Release
connection
Computer Networks 1

Send AC K
ACK Release
connection

46

Transport Layer
Disconnect with Three-Way Handshake
Last acknowledgment lost

www.ibr.cs.tu-bs.de
• timer disconnects from host 2
• therefore no further problems

Host A Host B
Send DR DR
+ start timer Send DR
+ start timer
DR
Computer Networks 1

Release
connection
AC K
Send
ACK Lost (Timeout)
release
connection

47

Transport Layer

Disconnect with Three-Way Handshake


Second “disconnect request” lost
www.ibr.cs.tu-bs.de

• repeat to send “disconnect request”


• because response was an unexpected DR and ACK
• loss is repaired
• otherwise procedure as described using timer
Computer Networks 1

48

Transport Layer

Disconnect with Three-Way Handshake


Second and all further “disconnect requests” lost
www.ibr.cs.tu-bs.de

• disconnects by timeout
Computer Networks 1

49

Transport Layer
Disconnect with Three-Way Handshake

www.ibr.cs.tu-bs.de
All “disconnect requests” lost
• resulting problem:
Computer Networks 1

• Host1 disconnects,
but Host2 retains inconsistent information: “half-open” connections
• prevented by activity strategy
• TPDUs have to arrive within a certain time
• otherwise automatic disconnect
• implementation
• after TPDU has been sent: re-initiate timer
• when timeout before data has been sent: send “Dummy-TPDU” to retain
connection
(“keep-alive” packets without actual data)
50 (but these might be lost as well ...)

Transport Layer

7 Flow Control on Transport Layer


Joint characteristics (with flow control on data link layer)
www.ibr.cs.tu-bs.de

• fast sender shall not flood slow receiver


• sender has to store all unacknowledged packets

Differences (to flow control on data link layer)


• L2-DLL: router serves few “bitpipes”
• L4-TL: endsystem contains a multitude of
• connections
Computer Networks 1

• data transfer sequences


• L4-TL: receiver may store packets
(but does not always have to)

Strategies
1. sliding window / static buffer allocation
2. sliding window / no buffer allocation
51
3. credit mechanism / dynamic buffer allocation
Transport Layer

7.1 Sliding Window / Static Buffer Allocation


Flow control
www.ibr.cs.tu-bs.de

• sliding window - mechanism with window size w


Buffer reservation
• receiver reserves 2*w buffers per duplex connection

Characteristics
+ receiver can accept all PDUs
- buffer requirement may be very high
• proportional to #transport-connections
Computer Networks 1

- poor buffer utilization for low throughput connections


i.e.
è good for traffic with high throughput
• (e.g. data transfer)
è poor for intermittent (and potentially bursty) traffic with
low throughput
• (e.g. interactive applications)
52

Transport Layer
7.2 Sliding Window / No Buffer Allocation
Flow control

www.ibr.cs.tu-bs.de
• sliding window (or no flow control)

Buffer reservation
• receivers do not reserve buffers
• buffer allocation upon arrival of TPDU
• TPDU will be discarded if there are no buffers available
Computer Networks 1
• sender maintains TPDU buffer until ACK arrives from receiver

Characteristics
+ optimized memory utilization
- possibly high rate of discarded TPDUs during high traffic load
i.e.
è good for intermittent (and bursty) traffic with low throughput
è poor for traffic with high throughput

53

Transport Layer

7.3 Credit Mechanism


Flow control
www.ibr.cs.tu-bs.de

• credit mechanism

Buffer reservation
• receiver allocates buffers dynamically for the connections
• allocation depends on the actual situation

Principle
• sender requests required buffer amount
Computer Networks 1

• receiver reserves as many buffers as the actual situation permits


• receiver returns ACKs and buffer-credits separately
• ACK: confirmation only (does not imply buffer release)
• CREDIT: buffer allocation
• sender will be blocked, when all credits have been used up

54

Transport Layer

Credit Mechanism
www.ibr.cs.tu-bs.de
Computer Networks 1

Example: with dynamic buffer allocation


• 4 bit SeqNo (0..15) and "..." corresponds to data loss

Dynamic adjustment to
• buffer situation
• number of open connections
• type of connections
• high throughput: many buffers
55 • low throughput: few buffers
Transport Layer
8 Some Familiar Internet Protocols

www.ibr.cs.tu-bs.de
SMTP HTTP FTP TELNET NFS RTP
SCTP
TCP UDP
IP + ICMP + ARP
WANs LLC & MAC LANs, MANs
ATM, … Physical Ethernet, …
Computer Networks 1

ARP = Address Resolution Protocol


Here
FTP only a
= VERY short
File Transfer introduction to
Protocol
HTTP = Hypertext Transfer Protocol
UDP
IP and TCP canProtocol
= Internet be given.
ICMP = Internet Control Message Protocol
LLC = Logical Link Control
MAC = Media Access Control
Further
NFS (many) details
= Network about UDP, TCP, and
File System also
SMTP = Simple Mail Transfer Protocol
SCTP
TELNETare given
= RemoteinLogin
Computer
Protocol Networks II.
TCP = Transmission Control Protocol
UDP = User Datagram Protocol
63
SCTP = Stream Control Transmission Protocol
Transport Layer

Internet Transport Layer (in General & Addressing)

Lowest level end-to-end protocol


www.ibr.cs.tu-bs.de

• header generated by sender is interpreted only by destination


• routers / gateways view transport header as part of the payload
Adds extra functionality to the best effort packet delivery service
provided by IP
• makes up for shortcomings of core network

Host A Host B

Application Application
Computer Networks 1

end-to-end protocol
Transport Transport
Gateway G
Internet Internet Internet

Network Interface Network Interface Network Interface

64
Physical Net 1 Physical Net 2
Transport Layer

8.1 Some Functions of Transport Protocols


Multiplexing/demultiplexing data for multiple applications
www.ibr.cs.tu-bs.de

• uses “port’’ abstraction


Connection establishment
• logical end-to-end connection
Error control
• hides unreliability of network layer from applications
• some types of errors:
• corruption, loss, duplication, reordering
Computer Networks 1

End-to-end flow control


• to avoid flooding the receiver
Congestion control
• to avoid flooding the network

65

Transport Layer
Transport Layer: End-to-End Communications

www.ibr.cs.tu-bs.de
Email Email File S. File Web Web
Client Server Client Server Client Server

Transport
Internet
Network Interface
Computer Networks 1

• communication between applications required


• applications communicate
• locally by interprocess communication
• between systems via TRANSPORT SERVICES
Transport layer
• interprocess end-to-end communication via communication
networks
Internet protocol IP
66 • enables only endsystem-to-endsystem communication
Transport Layer

8.2 UDP – User Datagram Protocol


Specification:
www.ibr.cs.tu-bs.de

• RFC 768

UDP is a simple transport protocol


• unreliable
• connectionless
• message-oriented

“best effort” service, UDP segments may be:


• lost
Computer Networks 1

• delivered out of order to app


connectionless:
• no handshaking between UDP sender, receiver
• each UDP segment (message) handled independently of others

67

Transport Layer

UDP: Characteristics
UDP is mostly IP with a short transport header
www.ibr.cs.tu-bs.de

• source and destination port


• ports allow for dispatching of messages to receiver process

= socket = process

application P3 P1
P1 application P2 P4 application
Computer Networks 1

transport transport transport

network network network

link link link

physical physical physical

host 1 host 2 host 3


From Kurose/Ross

68

Transport Layer
UDP: Characteristics
no connection establishment

www.ibr.cs.tu-bs.de
• no delay for connection setup

simple
• no connection state at sender, receiver

small segment header


• less overhead

no flow control and no congestion control:


Computer Networks 1

• UDP can send as fast as desired / application may transmit


• as fast as it can/wants to and
• as fast as the network permits

no error control or retransmission


• no guarantee about packet sequencing
• packet delivery to receiver not ensured
• possibility of duplicated packets

may be used with broadcast / multicast and streaming


69

Transport Layer

UDP: Message Format


Sender port
www.ibr.cs.tu-bs.de

0 16 31
• 16 bit sender
identification Sender Port Receiver Port
• is optional
Packet Length Checksum
• use: response may
be sent there Data
…..

Receiver port
• receiver identification
Computer Networks 1

Packet length
• in bytes UDP Header
(including UDP header)
• minimum: 8 (byte)
i.e. header without data

Checksum
• of header and data for error detection
70
• use of checksum optional
Transport Layer

8.3 TCP – Transmission Control Protocol


Motivation: network layer provides unreliable connectionless service
www.ibr.cs.tu-bs.de

• packets and messages may be


• duplicated, delivered in wrong order, faulty
• given such an unreliable service
• each application would have to implement error detection and
correction separately
• network or service can
• impose packet length
• define additional requirements to optimize data transmission
• i.e. each application would have to be adapted separately
Computer Networks 1

è avoid to reinvent the wheel for every application

èTCP is the Internet transport protocol providing


• reliable end-to end byte stream over an unreliable internetwork

Specification:
• RFC 793: originally
• Enhancements, further details also in RFC 1122, RFC 1323
71

Transport Layer
TCP Features
Reliable, bidirectional, unstructured byte stream between two

www.ibr.cs.tu-bs.de
communicating peers
• fully ordered, fully reliable
Connections established & torn down
• three-way handshake connection setup
• disconnect per direction
Multiplexing/ demultiplexing
• ports at both ends
Computer Networks 1

Error control
• checksums, sequence numbers, automatic retransmissions
à users see correct, ordered byte sequences
End-to-end flow control
• avoid to overwhelm machine on other side
• credit mechanism (dynamic window size)
Congestion avoidance
72 • avoid to create traffic jam within network
Transport Layer

TCP Segments
www.ibr.cs.tu-bs.de

Pseudo- Source IP address


header Destination IP address
0 Protocol (6) TCP segment length
0 4 10 16 31
IP header Source TCP port Destination TCP port
(20 bytes +opt.)
Sequence number
TCP header
(20 bytes +opt.) Acknowledgement number
Computer Networks 1

Hdr.len. - Flags Window size


TCP data Checksum Urgent pointer
Options (if any)

Data (if any)

Flags:
CWR ECE URG ACK PSH RST SYN FIN

73

Transport Layer

TCP Message Exchange


www.ibr.cs.tu-bs.de

User A TCP A TCP B User B


(client) CLOSED CLOSED (server)
Open-Active Open-Passive
SYN, ...
SYN-SENT LISTEN
SYN+ACK, ... SYN-RCVD
Open-Success
ESTABLISHED ACK, ... Open-Success
Send(dt[100]) ESTABLISHED
..., dt[100]
Computer Networks 1

Deliver(dt[100])
ACK, ...
Close
FIN-WAIT-1 FIN, ... Closing
ACK, ... CLOSE-WAIT
Close
FIN-WAIT-2 FIN, ...
Terminate LAST-ACK
TIME-WAIT ACK, ... Terminate
CLOSED CLOSED
74

Transport Layer
TCP Congestion Control
Objective:

www.ibr.cs.tu-bs.de
• avoid that too much traffic exists which could collapse network

Basic idea:
• detect congestion, typically using packet loss as indicator
• on detection: adjust sending rate

Adjustment of sending rate:


• use TCP window to control number of unacknowledged packets
Computer Networks 1

• sending rate: ~Window/RTT à vary window size


• new parameter “congestion window” (cwnd) at sender
• upon receipt of ACK (of new data) à increase rate
• data successfully delivered, perhaps can send faster
• upon detection of loss à decrease rate

75

Transport Layer

TCP Congestion Control: Phases


Phase 1: Slow start
www.ibr.cs.tu-bs.de

• discover roughly the proper sending rate quickly


• initialize cwnd =1
• each time a segment is ACKed
à increment cwnd by 1 (cwnd++)
• until ss_thresh is reached
or packet loss occurs cwnd = 1 segment 1

ent 1
ACK for segm

cwnd = 2 segment 2
Computer Networks 1

segment 3

ents 2 + 3
ACK for segm
cwnd = 4 segment 4
segment 5
segment 6
segment 7

ents 4+5+6+7
ACK for segm
cwnd = 8
76

Transport Layer

TCP Congestion Control: Phases


14
Phase 2: Congestion avoidance
www.ibr.cs.tu-bs.de

12
ss_thresh
• additive increase
Cwnd (in segments)

10
• gradually probe for additional bandwidth 8
• if cwnd > ss_thresh then 6
• each time a segment is acknowledged 4
• increment cwnd by 1/cwnd 2
0
0

• multiplicative decrease
t=

t=

t=

t=

Roundtrip times
• decreasing cwnd upon loss/timeout
Computer Networks 1

• ss_thresh = cwnd / 2 ; cwnd = 1 ; go into slow-start

cwnd ss_thresh
Timeout

Congestion
Avoidance
ss_thresh
Slow Start

77
Time
Transport Layer

You might also like