lecture 4: transport layer - icg.isy.liu.setransport layer protocols there are two transport layer...

45
TSIN02 - Internetworking © 2004 Image Coding Group, Linköpings Universitet Lecture 4: Transport Layer Literature: Forouzan: ch 11- 12

Upload: others

Post on 25-Jun-2020

23 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

© 2004 Image Coding Group, Linköpings Universitet

Lecture 4: Transport Layer

Literature:● Forouzan: ch 11- 12

Page 2: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

2

Lecture 4: Outline

● Transport layer responsibilities● UDP● TCP

Page 3: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

3

Transport layer in OSI model

Figure from Forouzan

Page 4: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

4

Lower layer responsibilities

● The physical layer– transmits signals representing individual bits on a

channel

● The link layer – provides reliable link communication through

framing, physical addressing, flow- error- and access control

● The network layer– provides end to end delivery of individual packets

through logical addressing and routing support

Page 5: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

5

End to end delivery of a packet

Figure from Forouzan

Page 6: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

6

The Transport Layer

The transport layer is responsible for end to end delivery of messages. This is achieved through– Service point addressing– Segmentation and reassembly – Connection control– Flow control– Error control

Page 7: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

7

End to end delivery of a message

Figure from Forouzan

Page 8: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

8

Addressing - Protocol Ports

Port numbers are used as a process identifier.

They are needed since computers can run multiple programs at the same time.– IP addresses identify computers– Port numbers identify processes

An (IP address, port number) pair is called a socket.

Messages must define source and destination sockets

Page 9: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

9

Port Numbers

The IANA has divided the port numbers into three ranges:– Well known ports (0- 1023)

Assigned and controlled by IANA

– Registered ports (1024- 49151)Ports in this range can be registered with IANA to prevent duplication.

– Dynamic ports (49152- 65535)The ephemeral ports can be used by any process.

Page 10: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

10

Some Well Known Ports

Port number Application20 FTP23 Telnet25 SNMP80 HTTP

Page 11: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

11

Transport layer protocolsThere are two transport layer protocols in the TCP/IP stack:

● UDP - User Datagram Protocol

– Connectionless unreliable service

● TCP - Transmission Control Protocol

– Connection- oriented reliable stream service

IPICMPIGMP

ARP RARP

TCP UDP

Underlying networks

Page 12: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

12

User Datagram Protocol

UDP is a connectionless, unreliable transport protocol

UDP provides – process to process communication– limited error checking

UDP does not provide– acknowledgement for recieved packets– segmentation and reassembly– flow control

Page 13: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

13

User Datagram Protocol

Why use UDP?

Page 14: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

14

User Datagram Protocol

UDP is suitable for– processes that provide internal flow and error

control mechanisms, eg TFTP– multicasting and broadcasting– management processes, eg SNMP– some route updating protocols, eg RIP– processes that only send short messages

Page 15: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

15

User Datagram

UDP packets (datagrams):– 8 byte header– max 65507 bytes of data

.

.

.

16 bits 16 bits

Source port address Destination port address

UDP total length UDP Checksum

Data

Page 16: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

16

UDP Checksum

The UDP checksum includes– pseudoheader– UDP header– data from the

application layer– pad byte (if needed)

8 bits 8 bits

.

.

.

8 bits 8 bits

All 0sProtocol

(17)Header checksum

Source IP address

Destination IP address

Source port address

Destination port address

UDP total length UDP Checksum

Data

Page 17: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

17

Checksum example

Figure from Forouzan

Page 18: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

18

UDP Operation

● Messages are encapsulated in UDP datagrams● Usually each port is associated with one or two

queues● UDP handles multiplexing and demultiplexing

of messages.

Page 19: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

19

Encapsulation

Figure from Forouzan

Page 20: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

20

Incoming and outgoing queues

Figure from Forouzan

Page 21: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

21

Multiplexing

Figure from Forouzan

Page 22: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

22

UDP Package

Figure from Forouzan

Page 23: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

23

Transmission Control Protocol

TCP is a connection- oriented transport protocol

TCP provides– full duplex connections– reliable stream service

● flow control● error control

Page 24: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

24

Buffers

Sending and receiving buffers are used for storage. This makes it possible to handle differences in speed between the sending and receiving processes.

Buffers are also used in flow and error control mechanisms.

Page 25: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

25

Buffers

Figure from Forouzan

Page 26: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

26

Reliable Service

TCP provides reliable service by– breaking application data into suitable sized blocks

called segments– using an acknowledgement mechanism – retransmission when errors occur– providing flow control– checksum control of header and data

Page 27: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

27

TCP Segment

Sequence Number

8 bits 8 bits

6 bits reserved

.

.

.

8 bits 8 bits

hlen

Options (if any)

Window Sizeflags

Urgent Pointer

Source port address Destination port address

TCP Checksum

Data (if any)

Acknowledgement Number

Page 28: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

28

Sequence number

● All bytes transmitted in a connection are numbered, starting from a random position

● 32 bits are used for numbering● The value in the header is the number of the

first byte of data contained in the segment.

Page 29: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

29

Acknowledgement number

● This number is used to announce the sequence number of the next expected segment and thus acknowledging that all prior segments (with lower sequence numbers) have been received.

Page 30: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

30

TCP Flags

6 flags can be used to determine the purpose of the segment (more than one can be set)– URG - urgent pointer valid (set when sender wants the receiver to

read a piece of data urgently and possibly out of order)

– ACK - acknowledgement number valid

– PSH - push data, receiver should immediately pass the data to the application (buffers should be emtied!)

– RST - reset the connection

– SYN - synchronize sequence numbers to initiate connection

– FIN - terminate the connection

Page 31: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

31

TCP Handshake

A three- way handshake is used to establish a connection

Client Server

●Negotiation on initial sequence numbers

●Initial segment number (ISN) chosen so that each active connection has its own ISN●Normally initiation is made by the client

SYN, seq=x

ACK, seq=x+1, SYN, seq=y

ACK, seq=y+1

Page 32: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

32

Connection Termination

4 segments needed to close a connection

Client Server

FIN

ACK of FIN

FIN

ACK of FIN

Page 33: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

33

Maximum Segment Size

● MSS is the largest block of data TCP will send to the other side.

● MSS can be announced in the options field during connection establishment.

● Default MSS is 536 ● The larger the better (until fragmentation

occurs)

Page 34: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

34

TCP Options

●Up to 40 bytes of optional informationcan be included in the TCP header

●Used to convey additional information or to align other options

Options

Single- byte

Multiple- byte

End of option

No operation

Maximum segment size

Window scale factor

Timestamp

Page 35: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

35

Flow Control

● How much can a source send without receiving an ACK?

● The sliding window protocol is used in TCP– offered window– usable window

Page 36: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

36

Senders window

Figure from Forouzan

Page 37: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

37

Sliding window

Page 38: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

38

Silly window syndrome● Sender sends 1- byte segments because the

application produces data slowly.

– Solution - Nagle's algorithm● After sending one segment, wait until either an ack is

received or a full window can be transmitted.● 1- byte windows are announced by the receiver

because the application consumes data slowly.

– Solution - Clark's● Announce zero window size until a maximum size

segment fits into the buffer

– Solution - delayed ack● Wait with acknowledgments until there is room in the

buffer

Page 39: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

39

Error control

Figure from Forouzan

Page 40: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

40

Congestion Control

● Handles bottlenecks in the network● Without congestion control the network will

collaps!● Solution:

– Congestion window (CWND)– slow start– Additive increase of CWND– Multiplicative decrease of CWND– Fast retransmit and Fast recovery

Page 41: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

41

Congestion window size

Figure from Forouzan

Page 42: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

42

TCP Timers

● Retransmission timer– how long should sender wait for an ACK ?

● Persistence timer– how long should sender wait if window size = 0?

● Keepalive timer– Prevents connections to live forever

● Time- Waited timer– Each connection held in limbo before actually

closed

Page 43: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

43

State transistions

Figure from Forouzan

Page 44: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

44

TCP packet

Figure from Forouzan

Page 45: Lecture 4: Transport Layer - icg.isy.liu.seTransport layer protocols There are two transport layer protocols in the TCP/IP stack: UDP - User Datagram Protocol – Connectionless unreliable

TSIN02 - Internetworking

45

Summary

● Transport layer basics● UDP - a fairly simple connectionless protocol● TCP - a very complex protocol

– Reliability– Connection management– Flow control– Congestion avoidance– Timers