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

Post on 25-Jun-2020

25 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

TSIN02 - Internetworking

© 2004 Image Coding Group, Linköpings Universitet

Lecture 4: Transport Layer

Literature:● Forouzan: ch 11- 12

TSIN02 - Internetworking

2

Lecture 4: Outline

● Transport layer responsibilities● UDP● TCP

TSIN02 - Internetworking

3

Transport layer in OSI model

Figure from Forouzan

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

TSIN02 - Internetworking

5

End to end delivery of a packet

Figure from Forouzan

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

TSIN02 - Internetworking

7

End to end delivery of a message

Figure from Forouzan

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

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.

TSIN02 - Internetworking

10

Some Well Known Ports

Port number Application20 FTP23 Telnet25 SNMP80 HTTP

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

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

TSIN02 - Internetworking

13

User Datagram Protocol

Why use UDP?

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

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

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

TSIN02 - Internetworking

17

Checksum example

Figure from Forouzan

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.

TSIN02 - Internetworking

19

Encapsulation

Figure from Forouzan

TSIN02 - Internetworking

20

Incoming and outgoing queues

Figure from Forouzan

TSIN02 - Internetworking

21

Multiplexing

Figure from Forouzan

TSIN02 - Internetworking

22

UDP Package

Figure from Forouzan

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

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.

TSIN02 - Internetworking

25

Buffers

Figure from Forouzan

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

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

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.

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.

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

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

TSIN02 - Internetworking

32

Connection Termination

4 segments needed to close a connection

Client Server

FIN

ACK of FIN

FIN

ACK of FIN

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)

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

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

TSIN02 - Internetworking

36

Senders window

Figure from Forouzan

TSIN02 - Internetworking

37

Sliding window

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

TSIN02 - Internetworking

39

Error control

Figure from Forouzan

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

TSIN02 - Internetworking

41

Congestion window size

Figure from Forouzan

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

TSIN02 - Internetworking

43

State transistions

Figure from Forouzan

TSIN02 - Internetworking

44

TCP packet

Figure from Forouzan

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

top related