Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet...

36
Layer 4 - Transport Layer Core of the protocol hierarchy : Network-independent, reliable and economical data transfer Tasks of the transport layer: Connection-oriented or connectionless data transfer Addressing of a certain communication process on a computer Error handling, error detection, error correction Flow control on end-to-end basis Quality guarantees (as far as possible) In general: improvement of the data transmission of layer 3

Transcript of Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet...

Page 1: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 1Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Layer 4 - Transport Layer

Core of the protocol hierarchy:

• Network-independent, reliable and economical data transfer

Tasks of the transport layer:

• Connection-oriented or connectionless data transfer

• Addressing of a certain communication process on a computer

• Error handling, error detection, error correction

• Flow control on end-to-end basis

• Quality guarantees (as far as possible)

• In general: improvement of the data transmission of layer 3

Page 2: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 2Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

TCP (Transmission Control Protocol): Reliable, connection-oriented.

UDP (User Datagram Protocol): Datagram principle, connectionless, unreliable, without flow control, permutation of a packet order can happen.

Connection-oriented Connectionless

ApplicationLayer

TransportLayer

InternetLayer

Host-to-NetworkLayer

Wireless LANEthernet Token Ring Token Bus

FTP Telnet SMTP DNS SNMP TFTPHTTP

UDPTCP

ICMP IP RARPARPIGMP

Transport Protocols in the TCP/IP Reference Model

Page 3: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 3Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Transport protocols are used by the application layer as communication services. They make communication available between application processes.

• TCP is a connection-oriented protocol• TCP confirms the receipt of the packets• UDP is a connectionless and fast protocol

IP network

A

B

Client process

Server process

TCP and UDP - the Transport Layer

Page 4: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 4Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Connection-oriented and reliable (error-free, keeps packet order, without duplicates)

• Error handling, acknowledgments, flow control (Sliding Window procedure)• Byte stream, not message stream• Segmentation (max. segment size of 64 KByte)

• “Urgent”-messages outside of flow control• Limited QoS

• Addressing of the application by port numbers

Characteristics of TCP

Host-to-network layer

Network layer

Transport layer

Application layerClient Server1Port number

IP address

Server waits on several ports

Server2

Page 5: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 5Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

TCP as a safe connection

• Establishes logical connections between two Sockets: IPv4 address + 16 bit port number (48 bit address information)

• For an application, sockets are the access point to the network

• A socket can be used for several connections at the same time

• TCP connections are always full-duplex and point-to-point connections

• TPDUs exchanged between the two communicating stations are called segments

• Segments are being exchanged for realizing

o Connection establishment,

o Agreement on a window size,

o Data transmission,

o Sending of confirmations,

o Connection termination.

Page 6: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 6Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Well known TCP ports

20/21 23 25 80 179

FTP telnet

Electronic Mail

SMTP HTTP BGP

File transferWorld Wide Web

Virtual terminalRouting information

1023

RFC 1700

• Port number is 16-bit address

• Ports from 0 to 1023 are reserved for standardized applications

• Ports from 1024 to 65535 can be specified by each host

TCP-based Applications

Page 7: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 7Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

The TCP Header

Source Port Destination Port

Data

0 16 24 31Bit position

8

PaddingOptions

Checksum Urgent Pointer

Window Size6 FlagsHL Res.

Acknowledgment Number

Sequence Number

• 20 byte header

• Plus options

• Up to 65495 data bytes

Page 8: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 8Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Source and Destination Port: port number of sender resp. receiver• Sequence Number/Acknowledgment Number: Segments have a 32 bit sequence

and acknowledgement number for the window mechanism in flow control (Sliding Window).

• Sequence and acknowledgement number count single bytes!• The acknowledgement number indicates the next expected byte!

• Sequence numbers begin not necessarily with 0!• Piggybacking, i.e. an acknowledgement can be sent in a data segment.

• HL: HL = Header Length. As in case of IP, also the TCP header has an indication of its length. The length is counted in 32-bit words.

• Res = Reserved for later use.

• Window Size: Size of the receiver’s buffer for the connection. Used in flow control: the window of a flow indicates, how many bytes at the same time can be sent – the size of the buffer indicates, how many bytes can be stored within the receiver. The window of flow control is adapted to this value.

The TCP Header

Page 9: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 9Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Flags:

• URG: URGENT. When using the Urgent pointer, e.g. for special keyboard input (Ctrl-C).

• ACK: This bit is set, if an acknowledgement is sent.

• PSH: PUSH. Direct forwarding of the data, no more waiting for further data.

• RST: RESET. Reset a connection, e.g. during a host crash or a connecting rejection. (“Generally problems arise when a segment with set RST bit is received.”)

• SYN: set to 1 for the establishment of a connection.

• FIN: set to 1 for the termination of a connection.

• Urgent pointer: indicates, at which position in the data field the urgent data end (byte offset of the current sequence number).

• Option: additional functions: negotiation of a window scale; use of e.g. Selective Repeat instead of Go-Back-n in the event of an error; Indication of the Maximum Segment Size (MSS) to determine the size of the data field.

The TCP Header

Page 10: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 10Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Source address (IP)

Destination address (IP)

The checksum is computed using a pseudo header. The pseudo header is placed in front of the TCP header, the checksum is computed from both headers (the checksum field is occupied here with 0). The checksum is computed as the 1-complement of the sum of all 16-bit words of the segment including the pseudo header. The receiver also places the pseudo header in front of the received TCP header and executes the same algorithm (the result must be 0).

Length of the TCP segmentProtocol = 600000000

• Checksum: serves among other things for the verification that the packet was delivered to the correct device.

TCP Pseudo Header

Page 11: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 11Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Sounds easy…

… is however nevertheless quite complicated: the network can loose packets, store packets, duplicate packets.

Solution:

• Sequence numbers• Three-Way Handshake

A connection establishment consists of three parts:

� The Connection Request,

� The confirmation of the receiver that the connection establishment is accepted,

� The confirmation of the sender that the confirmation of the receiver was received and the sending request is still given.

A compromise between reliability and complexity is to be obtained by this principle.

REJECT (ACK=y)

ACK (seq=y, ACK=x)

ACK (seq=x+1, ACK=y)

Host 1 Host 2

CR (seq=x)

Host 1 Host 2

CR (seq=x)

ACK (seq=y, ACK=x)

Duplicate

Connection Establishment

Page 12: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 12Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

TCP Connection Management: 1. Connection Establishment

Server

SYN, SEQ=x

SYN, SEQ=y, ACK=x+1

Client

ACK=y+1, SEQ=x+1

Three Way Handshake

• The server waits for connection requests using LISTEN and ACCEPT.

• The client uses the CONNECT operation by indicating IP address, port number and maximally acceptable segment size.

• CONNECT sends a SYN.

• If the destination port of the CONNECT is identical to the port number on which the server waits, the connection is accepted, otherwise it is rejected with RST.

• The server sends also sends a SYN to the client and acknowledges at the same time the receipt of the client’s SYN segment.

• The client sends an acknowledgement for the SYN segment of the server. The connection is established.

Page 13: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 13Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

SYN, SEQ=x

SYN, SEQ=y

Client/Server Client/Server

SYN, SEQ=x, ACK=y+1

SYN, SEQ=y, ACK=x+1

• Possibly, two computers at the same time try to establish a connection between the same sockets.

• Connections are characterized by their endpoints; only one connection is established between a pair of endpoints. The endpoints are uniquely characterized:

(IP Address1, Port1, IP Address2, Port2)

TCP Connection Management: Irregular Connection Establishment

Page 14: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 14Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

SEQ=101, ACK=201, DATA

SEQ=201, ACK=102

SEQ=102, ACK=201, DATA

SEQ=201, ACK=110

Client Server

• Full-duplex connection

• Segmentation of a byte stream into segments. Usual sizes are 1500, 536 or 512 byte; thus IP fragmentation is avoided.

• Usual acknowledgement mechanism: all segments up to ACK-1 are confirmed. If the sender has a timeout before an ACK, he repeats the sending.

• Usual procedure for repeating: Go-Back-N or Selective Repeat.

TCP Connection Management : 2. Data Transmission

Page 15: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 15Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

TCP Connection Management: 3. Connection Termination

FIN, SEQ=207, ACK=116

FIN, SEQ=116, ACK=208

SEQ=208, ACK=117

Client Server

• Termination as two simplex connections

• Send a FIN segment

• If the FIN segment is confirmed, the direction is “switched off”. The opposite direction remains however still opened, data can be still further sent.

• Use of timers to protect against packet loss.

Page 16: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 16Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Normal path of server Normal path of client

Unusualevents

Event/action pair

• Event: System call by user, arrival of segment, timeout

• Action: Send a control segment

The Entire TCP Connection

Page 17: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 17Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

States during a TCP Session

Wait for late packetsLAST ACK

The other side initiates a connection terminationCLOSE WAIT

Connection terminationCLOSING

Wait for late packetsTIME WAIT

The other side confirms the connection terminationFIN WAIT 2

Application starts a connection terminationFIN WAIT 1

Connection established, transmit dataESTABLISHED

Application began to open a connectionSYN SENT

A connection request was received and processed, wait for the last ACK of the connection establishment

SYN RCVD

The server waits for a connection requestLISTEN

No active communicationsCLOSED

DescriptionState

Page 18: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 18Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Initial window

Window slides

Segment 1, 2 and 3 acknowledged

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

• Sender sends according to the window size (byte)

• Window is shifted by nbyte as soon as an ACK for n byte arrives

• Exception: Urgent data (URGENT flag is set) are sent immediately

• Characteristic: the window size can be changed during the transmission phase to consider a larger number of connections and packet loss (variable window)

Flow Control – Sliding Window

Page 19: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 19Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Sliding Window - Example

Sender ReceiverApplication writes 2 KB

2K SEQ = 0

Receiver buffer

Empty

0 4K

ACK=2048 WIN=2048

2K SEQ = 2048

ACK=4096 WIN=0

ACK=4096 WIN=2048

1K SEQ = 4096

Full

Application writes 2 KB

Sender can transfer up to 2 KB

Sender is blocked

2K

2K

2K1K

Application reads 2 KB

Page 20: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 20Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Solution of Clark:The receiver must wait with the next window actualization until the receiver buffer again is reasonably empty

Receiver buffer is full

Application reads 1 byte

Space for 1 byte

Transfer segment for window actualization

New byte arrives

Receiver buffer is full

Header

1 byte

Header

“Silly Window” Syndrome

Page 21: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 21Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

The whole TCP Session

ServerClientSYN/SEQ=2999/ACK=x/Window=2500/MSS=1460

SYN, ACK/SEQ=2000/ACK=3000/Window=4200/MSS=1400ACK/SEQ=3000/ACK=2001/Window=2500

DATA 1400 byte/SEQ=3000/ACK=2001/Window=2500

DATA 1400 byte/SEQ=4400/ACK=2001/Window=2500

DATA 1400 byte/SEQ=5800/ACK=2001/Window=2500

ACK/SEQ=2001/ACK=4400/Window=4200

ACK/SEQ=2001/ACK=5800/Window=4200

ACK/SEQ=2001/ACK=7000/Window=4200

DATA 1400 byte/SEQ=7000/ACK=2001/Window=2500DATA 1400 byte/SEQ=8400/ACK=2001/Window=2500

ACK/SEQ=2001/ACK=8400/Window=4200

ACK/SEQ=2001/ACK=9800/Window=4200

FIN, ACK/SEQ=9800/ACK=2001

FIN, ACK/SEQ=2001/ACK=9801ACK/SEQ=9801/ACK=2002

Page 22: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 22Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Assumption:

packet loss is rarely because of transmission errors, rather because of overload situations.

Capacity of the receiver:Flow Control Window

Capacity of the network:Congestion Window

Necessary:

Congestion Control

Flow Control - Network Bottlenecks

Page 23: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 23Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Control Algorithm in the Internet

• Each sender maintains two windows for the number of bytes which can be sent:

1. Flow Control Window: granted receiver buffer

2. Congestion Window: “network granted” capacity (cwnd)

• Minimum of both windows is the number of bytes which can be sent maximally

• With connection establishment, the sender initializes the congestion window to the size of the maximum segment (MSS, the MTU the sender is able to send)

• Maximum segment is sent

• If an acknowledgement arrives before timeout, double the congestion window (Slow Start Algorithm), otherwise reset it to the initial value. Thus a “grope” takes place up to the transmission capacity.

• Enlargement stops with reaching the flow control window

• Refinement by introduction of a threshold value ssthresh (at the beginning 64 Kbyte):

- Only linear enlargement by one maximum segment size (Congestion Avoidance)

- With a timeout the threshold value is put back to half of the maximum window size reached before

Page 24: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 24Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Control Algorithm in the Internet

Start with one segment

Slow start, fast utilization of the free capacity

Congestion Avoidance, groping to the maximum capacity

Overload assumed, reduce the data amount

Be more careful in the next attempt

Page 25: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 25Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

TCP uses several timers:

• Retransmission timer (for repeating a transmission)

• But: how to select the timer value?

• Probability density of the time till an acknowledgement arrives:

10 20 30 40 500

0.1

0.2

0.3

Wah

rsch

ein

lich

keit

Roundtrip-Time [ms]

Data Link Layer

10 20 30 40 500

0.1

0.2

0.3

Wah

rsch

ein

lich

keit

Roundtrip-Time [ms]

Transport Layer

T T2T1

Problem on the transport layer:

• T1 is too small: too many retransmissions

• T2 is too large: inefficient for actual packet loss

Timer management with TCPP

rob

abili

ty

Pro

bab

ility

Round Trip Time [ms] Round Trip Time [ms]

Page 26: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 26Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Only meaningful solution: dynamic algorithm, which can adapt the timer by current measurements of the network performance.

Algorithm of Jacobson (1988):

• TCP manages a variable RTT (Round Trip Time) for each connection

• RTT is the momentarily best estimation of the round trip time to the target computer and back

• When sending a segment, a timer started which measures, which time the acknowledgement needs and initiates a retransmission if necessary.

• If the acknowledgement arrives before expiration of the timer (after a time unit t), RTT is updated:

RTT = α • RTT + (1 - α) • t

• α is a smoothing factor, typically 0.875

• The choice of the timeout is based on RTT: Timeout = β • RTT

• At the beginning, β was chosen as 2, but this was too inflexible

Retransmission Timer

Page 27: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 27Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Improvement (Jacobsson): select β proportionally to the standard deviation of the arrival time of acknowledgements

• Computation of β:

β = α • β + (1 - α) • |RTT - t|

• The factor α does not need to be the same as during the RTT computation

• Standard timeout interval: Timeout = RTT + 4 • β

• The factor 4 was determined on the one hand by trying out, on the other hand because it is fast and simple to use in computations.

Alternative, very simple proposal, which is used in many TCP implementations:

• Double the timeout as long as an acknowledgement arrives in time.

Retransmission Timer

Page 28: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 28Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Persistence timer

• Prevents a deadlock with a loss of the buffer release message of a receiver

• With expiration of the timer, the sender transfers a test segment. The response to this transmission contains the current buffer size of the receiver. If it is still zero, the timer is started again.

Keep-alive timer

• If a connection is inactive for a longer time, at expiration of the timer it is examined whether the other side is still living.

• If no response is given, the connection is terminated.

• Disputed function, not often implemented.

Time Wait timer

• During the termination of a connection, the timer runs for the double packet life time to be sure that no more late packets arrive.

Further Timers

Page 29: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 29Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

The User Datagram Protocol (UDP)

• 8 byte header

• Like IP: connectionless and unreliable

• Small reliability, but fast exchange of information

• No acknowledgement of packets on the UDP layer, incorrect packets simply are discarded. Duplication, sequence order permutation, and packet loss are possible.

• The checksum offers the only possibility of testing the packets on transfer errors

• Possible: ACKs and retransmissions are controlled by the application.

• Use in multicast (not possible with TCP)

Principle: “Keep it simple!”

Why at all UDP?

Only the addition of a port to a network address marks communication clearly.

Page 30: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 30Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

• Addressing of the applications by port numbers• Message length indicates the overall length (header + data) in 32-bit words

• Checksum (optional!) – IP does not have a checksum for the data part, therefore it can be a meaningful addition here. Execution of the computation as for TCP

• Data are filled up if necessary to an integer multiplei of 32 bits(because Message Length is indicated in 32-bit words)

Source Port Destination Port

Message Length Checksum

Data

0 8 16 24 31Bit Positon

UDP Header

Page 31: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 31Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Well known UDP ports

53 67/68 69 161/162 520

DNS BOOTP

File Transfer

TFTP SNMP RIP

Name serviceNetwork Management

Automatic Address AssignmentRouting Information

UDP-based Applications

Page 32: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 32Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

Real-Time Transport Protocol - RTP

Internet telephony, video conference,…

• TCP is unsuitable for real-time traffic

• UDP is fast, but unreliable

Advantage: many applications have approximately the same real-time requirements. Thus: provide own transport protocol for such requirements: RTP.

Idea of RTP: use the fast UDP and add some reliability.

Page 33: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 33Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

RTP

The application can

• adapt the data compression rate to the current capacity and error rate• decide if and how many packet losses can be tolerated

• correct packet permutations

Standard functions provided by RTP:• Timestamps: Mark the start point of the data relatively to the whole data stream.

This is an indication for the receiver, when to play out the data.

• Filters: To adapt the data stream to capacities of receiver and network, a feedback from the receiver to the sender is needed. Based on the feedback, the sender can adapt the data rate and/or the compression grade. Also, retransmission are possible.

• Mixers: Sometimes it can be useful to combine several data streams to save capacity.

Page 34: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 34Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

RTP Header

• RTP introduces sequence numbers to detect missing data. If a packet is missing, the receiver can interpolate contents from the previous data.

• No flow control, no error correction, no retransmissions.

• Sequence Number: the appropriate sequence number

• Timestamp: indicates the relative starting time of the data. Thus, data can be buffered within the receiver till they are in turn regarding the whole data stream.

Page 35: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 35Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

RTP Header

• Payload Type: indicates the coding of the data stream.

• P: packet size was padded to a multiple of 4 byte.• X: an extension header is used.

• CC: indicates the number of sources.• M: User-specific mark. Can e.g. mark the beginning of a word on an audio channel.• Synchronization Source Identifier: identifies the data stream, to which the packet

belongs.• Contributing Source Identifier: used by mixers in the studio. The mixed flows are

listed here.

RTP actually consists of two protocols: RTP only is the transport protocol.

RTCP (Real-Time Transport Control Protocol) takes over synchronization of data streams (e.g. audio and video) and feedback on flow parameters (delay, jitter, congestion,…) for the adaptation of the sender to the current network status

Page 36: Layer 4 - Transport Layer€¦ · Transport Layer Internet Layer Host-to-Network Layer Ethernet Token Ring Token Bus Wireless LAN HTTP FTP Telnet SMTP DNS SNMP TFTP TCP UDP IGMP ICMP

Lehrstuhl für Informatik 4

Kommunikation und verteilte Systeme

Page 36Chapter 3.5: Layer 4 – Transport Protocols TCP and UDP

RTCP

RTCP controls the data flow:

• Feedback to the sender about QoS on receiver side• Data losses, delay and jitter are reported

• Note: RTCP does not provide corrective actions - this is left over to the application

Application

RTP / RTCP

UDP

IP

Application

RTP / RTCP

UDP

IP

RTP RTP RTP RTP RTPRTP

RTCP RTCP RTCPRTCP

Sender Receiver