TSIN02 - Internetworking · TSIN02 - Internetworking 9 Addresses and Ports Figure from Forouzan...
Transcript of TSIN02 - Internetworking · TSIN02 - Internetworking 9 Addresses and Ports Figure from Forouzan...
TSIN02 - Internetworking
© 2004 Image Coding Group, Linköpings Universitet
Lecture 4: Transport Layer
Literature:� Forouzan: ch 11-12
2
� Transport layer responsibilities� UDP� TCP
TSIN02 - Internetworking
3
Transport layer in OSI model
Figure from Forouzan 4
� The physical layer� transmits signals representing individual bits on a
channel� The link layer
� provides reliable link communication throughframing, physical addressing, flow- error- and access control
� The network layer� provides end to end delivery of individual packets
through logical addressing and routing support
5Figure from Forouzan 6
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
7Figure from Forouzan 8
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
Addresses and Ports
Figure from Forouzan
10Figure from Forouzan
11
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.
12
Port number Application20 FTP23 Telnet25 SNMP80 HTTP
13
There 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 14
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
15
Why use UDP?
16
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
17
UDP packets (datagrams):� 8 byte header� max 65507 bytes of data
(=IP length – IP header – UDP header)
Figure from Forouzan 18
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 0s Protocol (17) UDP total length
Source IP address
Destination IP address
Source port address
Destination port address
UDP total length UDP Checksum
Data
19Figure from Forouzan 20
� Messages are encapsulated in UDP datagrams� Usually each port is associated with one or two
queues� UDP handles multiplexing and demultiplexing
of messages.
21Figure from Forouzan 22Figure from Forouzan
23Figure from Forouzan 24Figure from Forouzan
25
TCP is a connection-oriented transport protocol
TCP provides� full duplex connections� reliable stream service
� flow control� error control
26
27 28
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.
29Figure from Forouzan 30Figure from Forouzan
31
TCP provides reliable service by� breaking application data into suitably sized blocks
called segments� using an acknowledgement mechanism � retransmission when errors occur� providing flow control� checksum control of header and data
32Figure from Forouzan
33
� 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.
34
� 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.
35
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 - acknowledgment number valid
� PSH - push data, receiver should immediately pass the data to the application (buffers should be emptied!)
� RST - reset the connection
� SYN - synchronize sequence numbers to initiate connection
� FIN - terminate the connection
36
A three-way handshake is used to establish a connection
�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
Figure from Forouzan
37
4 segments needed to close a connection
Figure from Forouzan 38
� 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)
39
�Up to 40 bytes of optional informationcan be included in the TCP header
�Used to convey additional information or to align other options
Figure from Forouzan 40
� How much can a source send without receiving an ACK?
� The sliding window protocol is used in TCP� offered window� usable window
A sliding window is used to make transmission A sliding window is used to make transmission more efficient as well as to control the flow of data more efficient as well as to control the flow of data so that the destination does not become so that the destination does not become overwhelmed with data. TCP’s sliding windows are overwhelmed with data. TCP’s sliding windows are byte oriented.byte oriented.
41Figure from Forouzan 42
43
� 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
� Send acks as soon as possible, but announce zero window size until a maximum size segment fits the buffer
� Solution - delayed ack� Wait with acknowledgments until there is room in the
buffer 44
������������� ��������������������������� ���������� ��� �������������� ��� ����������������������������
�� ��� ����� ����������������������� ��
45
� The source does not have to send a full window's worth of data.
� The size of the window can be increased or decreased by the destination
� The destination can send an acknowledgement at any time.
46Figure from Forouzan
47Figure from Forouzan 48Figure from Forouzan
49
� TCP assumes that the cause of a lost segment is due to congestion in the network.
� If the cause of the lost segment is congestion, retransmission of the segment will not help, it will make things worse.
50
� 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
51Figure from Forouzan 52
� 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
53Figure from Forouzan
TSIN02 - Internetworking
54
TCP packet
Figure from Forouzan
55
� Transport layer basics� UDP - a fairly simple connectionless protocol� TCP - a very complex protocol
� Reliability� Connection management� Flow control� Congestion avoidance� Timers