Download 5.Transport Layer

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Computer security wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Hacker wikipedia , lookup

Internet protocol suite wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

TCP congestion control wikipedia , lookup

Transcript
Section 5:
The Transport Layer
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
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
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.
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
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.
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
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)
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
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 roundtrip time (RTT) and set the timeout accordingly.
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
CS 320 - Computer Networks
John Mc Donald, Dept. of Computer Science, NUI Maynooth.
5.12
Sliding window
Bytes
already
sent
Bytes
not
sent
yet
12
34
56
78
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CS 320 - Computer Networks
Back edge
of window
Bytes already
acknowledged
Bytes not
yet acknowledged
Window size
(determined
by the recipient)
Front edge
of window
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
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
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)
CS 320 - Computer Networks
John Mc Donald, Dept. of Computer Science, NUI Maynooth.
5.16
Setting up a connection
Send SYN
Receive SYN
Send SYN + ACK
Receive SYN + ACK
Send ACK
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 reservedJohn
forMcstandard
services
CS 320 - Computer Networks
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
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
given
A 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
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
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 viceversa)
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
data
To release a connection
a call to CLOSE is made
CS 320 - Computer Networks
John Mc Donald, Dept. of Computer Science, NUI Maynooth.
The End!