Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer...

22
Section 5: The Transport Layer

Transcript of Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer...

Page 1: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

Section 5: The Transport Layer

Page 2: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.2

Introduction

In the previous section we looked at the services provided by the network layer and specifically how the Internet uses IP to provide unreliable connectionless packet delivery service.

Building on top of this, transport protocols must provide reliable end-to-end communication, independent of the underlying network used.

In order to describe the services provided by the transport layer we will use TCP as an example

Page 3: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.3

TCP Services

From an application program’s point of view, the service offered by TCP has seven major features:– Connection Orientation– Point-To-Point Communication– Complete Reliability– Full Duplex Communication– Stream Interface– Reliable Connection Start-up– Graceful Connection Shutdown

Page 4: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.4

Hence, TCP provides a completely reliable (no data duplication or loss), connection oriented, full-duplex stream transport service that allows two application programs to form a connection, send data in either direction, and then terminate the connection.

Each TCP connection is started reliably and terminated gracefully, with all data being delivered before the termination occurs.

Page 5: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.5

TCP and IP

With TCP/IP, irrespective of whether the underlying network is a LAN, WAN, single network, or internetwork, the internet protocol (IP) is always present in the network layer.

Thus, all transport packets (known as segments) are transferred across the underlying network in IP datagrams.

The underlying internet system does not provide hardware support or software support for connections

Page 6: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.6

Therefore, for TCP to provide an end-to-end protocol, it uses what are known as virtual connections (i.e. connections held in software)

In essence TCP treats IP as a packet communication system that connects hosts at two endpoints of a connection, and IP treats each TCP message as data to be transferred

This idea is shown graphically in the next slide.

Page 7: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.7

Courtesy of Computer Networks 3rd Ed. by A.S.Tanenbaum, 1994

Page 8: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.8

Achieving reliability

Problems:– Unreliable delivery by the underlying communications

system, and, system crashes and reboots.

TCP combines a number of different mechanisms to achieve reliability, of which the more prominent are:– Adaptive retransmission– Sliding window for flow control– 3-way handshake for establishing and releasing connections– (We will not cover congestion control)

Page 9: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.9

Adaptive retransmission

To compensate for packet loss the sender uses a retransmission scheme whereby if a packet is not acknowledged by the receiver in a certain amount of time, the sender assumes it to be lost and retransmits

The delay required for the data to reach a destination and an acknowledgement to return depends on the traffic in the internet and the distance to the destination

In order for the network usage to be optimised TCP adapts to these delays

Page 10: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.10

It performs this adaptation policy by building up a sequence of round-trip times for a connection and then performing a statistical analysis of that sequence.

This then allows TCP to accurately estimate the round-trip time (RTT) and set the timeout accordingly.

Page 11: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.11

Flow Control

To overcome the maximum achievable bandwidth associated with the positive acknowledgement and retransmission, TCP uses a sliding window protocol, which allows several unacknowledged segments to be present in the network.

The next slide show a diagrammatic representation of the technique

Page 12: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.12

Sliding window1 2 3 4 5 6 7 8 9 10111213141516171819202122

Bytesalready

sent

Bytesnotsentyet

Bytes alreadyacknowledged

Bytes not yet acknowledged

Window size(determined

by the recipient)

Front edgeof window

Back edgeof window

Page 13: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.13

Bytes behind the trailing edge of the window have been both transmitted and acknowledged.

Bytes in front of the leading edge of the window have not been sent yet.

To control this sliding window, there are three fields with the TDP header.

The sequence number is placed in the header by the sender and indicates the byte offset within the data stream at which this segment begins

Page 14: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.14

The acknowledgement number is used in the acknowledgements returned by the recipient, to indicate which segment is being acknowledged

A third field, called the window size field is used in acknowledgement packets to indicate how many more bytes of data (beyond the one that is currently being acknowledged) the recipient is willing to accept before further acknowledgements are sent

Page 15: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.15

Three-Way Handshake

To guarantee that connection are established or terminated reliable, TCP uses a 3-way handshake in which three message are exchanged (a minimum of 3 message are required to ensure setup or release)

When setting up a connection TCP uses synchronisation segments (SYN segment)

When releasing a segment it uses finish segments (FIN segments)

Page 16: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.16

Setting up a connection

Send SYN

Send SYN + ACK

Send ACK

Receive SYN

Receive SYN + ACK

Page 17: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.17

Accessing TCP Services

Access to the services provided by TCP can only be granted through transport service access points (TSAPs) known as ports.

To use a port a socket must be created and bound to it. Each socket is addressed by a number made up of the

machines IP address and a 16-bit port number local to that host (e.g. 149.157.245.10,23 is the telnet port on csa10)

Port numbers below 1024 are called well-known ports and are reserved for standard services

Page 18: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.18

Berkeley sockets

One implementation of TCP used in Berkeley UNIX a set of socket primitives described below– SOCKET: Create a new communication end point– BIND: Attach a local address to a socket– LISTEN: Announce willingness to accept connections– 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

Page 19: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.19

Building servers

Servers execute the first four primitives in the order givenA successful call to SOCKET return an ordinary file

descriptor that may be used in succeeding calls.BIND assigns an specific address to the newly created

socket, at which stage clients who know this address may connect to it

The LISTEN call allows a number of clients to try and connect simultaneously in which case they will be queued for service

Page 20: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.20

LISTEN is non-blocking i.e. once called it sets up the queue, tells the TCP to look after it, and returns control to the programs

When the server wishes to accept an incoming connection it executes the ACCEPT call. If a client is waiting a connection is set-up otherwise the call blocks until a client tries to connect.

ACCEPT returns a new file descriptor specifically assigned for communication between the server and the new client

Page 21: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.

5.21

Building clients

When a client wishes to utilise the services of TCP it must also first make a call to SOCKET. In this case however the address of the TSAP does not matter since the client connects to the server (not vice-versa)

Once the socket has been created the CONNECT call asks TCP to make a connection to the server

SEND and RECEIVE may then be used to exchange dataTo release a connection a call to CLOSE is made

Page 22: Section 5: The Transport Layer. 5.2 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth. Introduction In the previous section.

The End!