The Transport Layer

Download Report

Transcript The Transport Layer

CEN 4500
Data Communications
Chapter 6: The Transport Layer
Instructor: S. Masoud Sadjadi
http://www.cs.fiu.edu/~sadjadi/Teaching/
sadjadi At cs Dot fiu Dot edu
Recap: Transport Layer
•
Transport layer is not just another layer. It is the heart of the
whole protocol hierarchy.
•
Its task is to provide reliable, cost-effective data transport
from source machine to the destination machine (hence, endto-end), independently of the physical network or networks
currently in use.
Accepts data from above, split it up into smaller units if need
be, pass these to the network layer, and ensures that the
pieces all arrive correctly at the other end.
•
CEN 4500, S. Masoud Sadjadi
2
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
3
The Transport Service
•
•
•
•
Services Provided to the Upper Layers
Transport Service Primitives
Berkeley Sockets
An Example of Socket Programming:
–
An Internet File Server
CEN 4500, S. Masoud Sadjadi
4
Services Provided to the Upper Layers
•
Goal
–
–
–
To provide efficient, reliable, and cost-effective
service to its users, normally processes in the
application layer.
To achieve this, transport layer makes use of the
services provided by the network layer.
The hardware/software within the transport layer
that does the work is called the transport entity.
•
Can be located in the operating system kernel, in a
separate user process, in a library package bound into
network applications, or on the network interface card.
CEN 4500, S. Masoud Sadjadi
5
Services Provided to the Upper Layers
The network, transport, and application layers.
CEN 4500, S. Masoud Sadjadi
6
Services Provided to the Upper Layers
•
Similar to the type of services in the network
layer, there are two types of transport services:
–
Connection-Oriented Service
•
•
–
Connectionless Service
•
•
Connection establishment, data transfer, and release.
Addressing, flow control, etc.
Also very similar to NL.
Then why two layers? What is the difference?
–
The transport code runs entirely on the users’
machines, but the network layer mostly runs on
the routers, which are typically operated by one or
more carriers.
CEN 4500, S. Masoud Sadjadi
7
Services Provided to the Upper Layers
Relation between hosts on LANs and the subnet.
A stream ofCEN
packets
sender
4500, S.from
Masoud
Sadjadi to receiver.
8
Services Provided to the Upper Layers
The OSI
reference
model.
CEN 4500, S. Masoud Sadjadi
9
Services Provided to the Upper Layers
•
So, what happens if the network layer provide
inadequate service? For example, what if the
subnet loses packets frequently.
–
–
The users have no real control over the network
layer, so they cannot solve the problem of poor
service by using better routers or putting more
error handling in the data link layer!
The only possibility is to put on top of the
network layer another layer that improves the
quality of the service according to the users’
preference.
CEN 4500, S. Masoud Sadjadi
10
Services Provided to the Upper Layers
•
Why do we need transport layer? (cont.)
–
–
–
The network service calls may vary considerably from
network to network.
Transport layer provides a network independent layer by
hiding the network service behind a set of transport
service primitives.
This way, changing the network service merely requires
replacing one set of library procedures by another one
•
–
that basically does the same thing, but with a different underlying
service.
Therefore, application programmers can write code
according to a standard set of primitives and portable on
variety of networks.
CEN 4500, S. Masoud Sadjadi
11
Services Provided to the Upper Layers
•
Revisiting the hybrid reference model
transport service user
transport service provider
•
•
The bottom four layers are transport service provider,
whereas the upper layer(s) are the transport service user.
Therefore, the transport layer forms the major boundary
between the provider and user of the reliable data
transmission service.
CEN 4500, S. Masoud Sadjadi
12
The Transport Service
•
•
•
•
Services Provided to the Upper Layers
Transport Service Primitives
Berkeley Sockets
An Example of Socket Programming:
–
An Internet File Server
CEN 4500, S. Masoud Sadjadi
13
Transport Service Primitives
•
To allow users to access the transport service,
the transport layer must provide some
operations to application programs
–
•
That is, a transport service interface.
Types of services
–
–
Connection-oriented service
Connectionless service
CEN 4500, S. Masoud Sadjadi
14
Transport Service Primitives
The primitives for a simple transport service.
•
Example: A Connection-Oriented Client-Server App.
–
Connection Establishment
•
The server executes a LISTEN primitive
–
•
Typically by calling a library procedure that make a system call to block the
server until a client turns up.
When a client wants to talk to the server, it executes a CONNECT
primitive.
–
–
The transport entity blocks the caller and sends a packet to the server.
CENREQUEST
4500, S. Masoud
Sadjadi
15
A CONNECTION
TPDU
is sent to the server.
Transport Service Primitives
The nesting of transport protocol data units
(TPDUs), packets, and frames.
CEN 4500, S. Masoud Sadjadi
16
Transport Service Primitives
•
Example: A Client-Server Application (cont.)
–
Connection Establishment (cont.
•
•
•
–
When the CONNECTION REQUEST TPDU arrives at the server transport
entity, it checks to see if the server is blocked on a LISTEN.
It then unblocks the server and sends a CONNECTION ACCEPTED TPDU
back to the client.
When the client transport entity receives this TPDU, it unblocks the client and
the connection is now established.
Data Exchange
•
Data can now be exchanged using the SEND and RECEIVE primitives.
–
–
–
–
Either party can do a (blocking) RECEIVE to wait for the other party to do a SEND
When the TPDU arrives, the receiver is unblocked and …
This works as long as the two sides can keep track of the turns.
Connection Termination
•
When a connection is no longer needed, it must be released to free table space
within the two transport entities.
CEN 4500, S. Masoud Sadjadi
17
Transport Service Primitives
•
Connection Termination Types
–
Asymmetric
•
•
•
–
Either of the two transport user can issue a
DISCONNECT primitive.
This results in a DISCONNECT TPDU being sent
Upon its arrival, the connection is released
Symmetric
•
•
•
Each direction is closed separately (independently).
When one side is disconnected, it does not mean that
the other side has no more data to transmit.
So, a connection is released when both side disconnect.
CEN 4500, S. Masoud Sadjadi
18
Transport Service Primitives
A state diagram for a simple connection management scheme.
Transitions are caused either by primitive execution ( ) or by packet
arrivals (labeled in italics, ). The solid lines show the client's state
CEN 4500, S. Masoud Sadjadi
sequence. The dashed lines
show the server's state sequence. 19
The Transport Service
•
•
•
•
Services Provided to the Upper Layers
Transport Service Primitives
Berkeley Sockets
An Example of Socket Programming:
–
An Internet File Server
CEN 4500, S. Masoud Sadjadi
20
Berkeley Sockets
The socket primitives used in Berkeley UNIX for
TCP.
CEN 4500, S. Masoud Sadjadi
21
•
Berkeley Sockets
Sever Side
–
1.
The first four primitives in the list are executed in that order by
servers.
The SOCKET primitive
–
–
–
2.
The BIND primitive
–
–
3.
creates a new end point and allocates table space for it within the
transport entity.
The parameters of the call specify the addressing format to be used, the
type of service desired, and the protocol.
A successful SOCKET call returns an ordinary file descriptor for use in
succeeding calls
assigns a newly-created socket to a network address
The reason for doing the address binding through as separate call is that
some servers want to used a predefined (fixed) address and some do not
really care.
The LISTEN primitive
–
–
would allocate space to queue incoming calls for the case that several
clients try to connect at the same time.
It is not a blockingCEN
call.
4500, S. Masoud Sadjadi
22
•
Berkeley Sockets
Sever Side (cont.)
4.
The ACCEPT primitive
–
–
–
–
•
Blocks the server for an incoming connection
When a TPDU asking for a connection arrives, the transport entity
creates a new socket with the same properties as the original one and
returns a file descriptor for it.
The server can then fork off a process or thread to handle the connection
on the new socket and go back to waiting for the next connection on the
original socket.
ACCEPT returns a normal file descriptor, which can be used for reading
and writing in the standard way, the same as for files.
Client Side
–
•
First the SOCKET and then CONNECT (BIND not necessary).
Server and Client
–
Use SEND/RECV to transmit/receive data (full-duplex conn.)
•
–
Or use WRITE/READ, if none of the special options are required.
Use CLOSE for releasing the connection (symmetric).
CEN 4500, S. Masoud Sadjadi
23
The Transport Service
•
•
•
•
Services Provided to the Upper Layers
Transport Service Primitives
Berkeley Sockets
An Example of Socket Programming:
–
An Internet File Server
CEN 4500, S. Masoud Sadjadi
24
Socket
Programming
Example:
Internet File
Server
Client code using
sockets.
Command line:
> cc –o client client.c –lsocket
> client goliath.cs.fiu.edu \
/usr/sadjadi/passworkFile.txt > HeHeHe
CEN 4500, S. Masoud Sadjadi
25
Socket
Programming
Example:
Internet File
Server (2)
Server code
using sockets.
Command line:
> cc –o server server.c –lsocket –lnsl
> Server
CEN 4500, S. Masoud Sadjadi
26
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
27
Elements of Transport Protocols
•
The transport service is implemented by a
transport protocol used between the two
transport entities.
–
–
•
It resembles the data link protocols
Both have to deal with error control, sequencing,
and flow control, among other issues.
What is the difference with the data link?
–
–
At the data link layer, two routers communicate
directly via a physical channel.
At the transport layer, the physical channel is
replaced by the entire subnet.
CEN 4500, S. Masoud Sadjadi
28
Transport Protocol
(a) Environment of the data link layer.
(b) Environment of the transport layer.
CEN 4500, S. Masoud Sadjadi
29
Elements of Transport Protocols
•
What is the difference with the data link?
1.
Addressing
–
–
2.
Connection Establishment
–
–
3.
Data link layer: The process is simple as the other end is either always there or it
is crashed!
Transport layer: Initial connection establishment is much more complicated.
Storage in the Subnet
–
–
4.
Data link layer: it is not necessary for a router to specify which router it wants to
talk to—each outgoing line uniquely specifies a particular router.
Transport layer: explicit addressing of destinations is required.
Data link layer: When a router sends a packet, it may arrive or be lost, but it
cannot bounce around for a while.
Transport layer: If the subnet uses datagrams and adaptive routing inside, there
is a non-negligible probability that a packet may be stored for a number of
seconds and then delivered later.
Flow Control and Buffering
–
–
Data link layer: required in both layers.
Transport layer: Presence of a large and dynamically varying number of
connections.
CEN 4500, S. Masoud Sadjadi
30
Elements of Transport Protocols
•
•
•
•
•
Addressing
Connection Establishment
Connection Release
Flow Control and Buffering
Multiplexing
CEN 4500, S. Masoud Sadjadi
31
Addressing
•
When an application process wishes to set up a
connection to a remote application process, it must
specify which one to connect to.
–
–
–
–
–
The problem exists for a connectionless transport as it
needs to know which process the messages should be
delivered to.
The method normally used is to define transport addresses
to which processes can listen for connection requests.
In the Internet, these end points are called ports.
The generic term is Transport Service Access Point
(TSAP) for transport layer addresses and NSAP for
network addresses.
This way, two or more processes using the same NSAP can
be distinguished through TSAP.
CEN 4500, S. Masoud Sadjadi
32
Addressing
TSAPs, NSAPs and transport connections.
CEN 4500, S. Masoud Sadjadi
33
Addressing
•
Initial Connection Protocol
–
–
Problem: Assume that there are many server
processes and most of which are rarely used;
therefore, it is wasteful of resources to have each
of them active and listening to a stable TSAP
address all the time.
Solution: A special process server that acts as a
proxy for less heavily used servers that receives
all connections requests that no server is waiting
for them. This process server spawns the
requested server and allows it to inherit the
existing connection with the user.
CEN 4500, S. Masoud Sadjadi
34
Addressing
•
How a user process in host 1 establishes a
connection with a time-of-day server in host 2.
CEN 4500, S. Masoud Sadjadi
35
Elements of Transport Protocols
•
•
•
•
•
Addressing
Connection Establishment
Connection Release
Flow Control and Buffering
Multiplexing
CEN 4500, S. Masoud Sadjadi
36
Connection Establishment
•
Connection establishment is not as easy as it
sounds!
–
–
If the network can lose, store, and duplicate
packets, then we have a problem!
Example
•
•
•
•
A user establishes a connection with a bank
Sends a message to the bank asking to transfer a large
amount of money to the account of a not-entirelytrustworthy person
Then the user releases the connection.
Assume that each packet is duplicated and stored in the
subnet
– The duplicate packets pop up in the bank with the right order!
CEN 4500, S. Masoud Sadjadi
37
Connection Establishment
•
Three-Way Handshake
–
–
–
Host1 chooses a sequence number, x, and sends a
CONNECTION REQUEST TPDU to host 2.
Host2 replies with an ACK TPDU acknowledging
x and announcing its own initial sequence
number, y.
Host1 acknowledges Host2’s choice of an initial
sequence number in the first data TPDU that is
sends.
CEN 4500, S. Masoud Sadjadi
39
Connection Establishment
Three protocol scenarios for establishing a connection using a
three-way handshake. CR denotes CONNECTION REQUEST.
(a) Normal operation,
(b) Old CONNECTION REQUEST appearing out of nowhere.
(c) Duplicate CONNECTION REQUEST and duplicate ACK.
CEN 4500, S. Masoud Sadjadi
40
Elements of Transport Protocols
•
•
•
•
•
Addressing
Connection Establishment
Connection Release
Flow Control and Buffering
Multiplexing
CEN 4500, S. Masoud Sadjadi
41
Connection Release
•
•
Releasing a connection is easier than
establishing one
Types of connection release
–
Asymmetric
•
•
–
Like telephone system
May result in data loss (see next slide).
Symmetric
•
•
•
Treats the connection as two separate unidirectional
connections.
Each direction is released independent of the other one.
Determining when all the work is done to disconnect is
not obvious (two-army problem).
CEN 4500, S. Masoud Sadjadi
42
Connection Release
Abrupt disconnection with loss of data.
CEN 4500, S. Masoud Sadjadi
43
•
Connection Release
The two-army problem.
–
–
–
–
The white army is larger than either of the two blue armies.
The blue armies need to synchronize their attacks.
How about three-way handshake? How about four-way?
In practice, one is usually prepared to take more risks!
Unreliable communication channel CEN 4500, S. Masoud Sadjadi
44
Connection Release
Four protocol scenarios for releasing a connection.
(a) Normal case of a three-way handshake.
(b) final ACK lost. The situation is saved by a timer.
6-14, a, b
CEN 4500, S. Masoud Sadjadi
45
Connection Release
(c) Response lost. We use timeout.
(d) Response lost and subsequent DRs lost. After N retries, the
senders gives up and disconnects.
CEN 4500, S. Masoud Sadjadi
46
Elements of Transport Protocols
•
•
•
•
•
Addressing
Connection Establishment
Connection Release
Flow Control and Buffering
Multiplexing
CEN 4500, S. Masoud Sadjadi
47
Flow Control and Buffering
•
The main difference with data link is that the
router has only a few lines, but a host may
have numerous connections.
–
–
–
This difference makes it impractical to implement
the data link buffering strategy in the transport
layer.
The receiver may, for example, maintain a single
buffer pool shared by all connections.
Recall that the sender cannot trust the network
layer’s acknowledgement, because the
acknowledgement means only that the TPDU
arrive, not that it was accepted!
CEN 4500, S. Masoud Sadjadi
48
Flow Control and Buffering
(a) Chained fixed-size buffers. (b) Chained variable-sized buffers.
(c) One large circular buffer per connection.
CEN 4500, S. Masoud Sadjadi
49
Elements of Transport Protocols
•
•
•
•
•
Addressing
Connection Establishment
Connection Release
Flow Control and Buffering
Multiplexing
CEN 4500, S. Masoud Sadjadi
51
Multiplexing
•
Multiplexing several conversations onto
connections, virtual circuits, and physical links plays
a role in several layers.
When a TPDU comes in, there should be a way to
tell which process to give it to.
•
–
•
This situation is called upward multiplexing
If a user needs more bandwidth than one virtual
circuit can provide, a way out Is to open multiple
network connections and distribute the traffic among
them
–
This situation is call downward multiplexing
CEN 4500, S. Masoud Sadjadi
52
Multiplexing
(a) Upward multiplexing. (b) Downward
multiplexing.
CEN 4500, S. Masoud Sadjadi
53
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
56
A Simple Transport Protocol
•
•
To make the ideas discussed so far concrete,
we will study an example transport layer in
detail.
We use the below connection-oriented
abstract service primitives.
–
It is similar to, but simpler than TCP protocol
CEN 4500, S. Masoud Sadjadi
57
A Simple Transport Protocol
•
We will study
–
The Example Service Primitives
•
–
The Example Transport Entity
•
–
How to express these transport primitives concretely?
We see an example transport entity.
The Example as a Finite State Machine
•
We model the transport entity using an FSM.
CEN 4500, S. Masoud Sadjadi
58
The Example Service Primitives
•
How to express these transport primitives concretely?
–
CONNECT
•
•
•
•
•
–
A library procedure connect that can be called with the appropriate
parameters necessary to establish a connection.
The parameters are the local and remote TSAPs.
During the call, the caller is blocked.
If the connection succeeds, the caller is unblocked.
The caller can start transmitting data.
LISTEN
•
•
•
•
A process is willing to accept incoming calls, calls listen.
It needs to specify a specific TSAP to listen to.
The process the blocks until a process attempts to establish a
connection to its TSAP.
This model in highly asymmetric (active and passive sides).
CEN 4500, S. Masoud Sadjadi
59
The Example Service Primitives
–
LISTEN (cont.)
•
What if the caller starts sooner?
– Call fails
– Call blocks forever until a listener appears
– Hold the connection request at the receiving end for a certain time
interval in the hope that the listener will call listen before the time
goes off (used here).
–
DISCONNECT
•
•
–
When both sides have disconnected, the connection is
released.
Symmetric disconnection model is used!
SEND & RECEIVE
•
Active call send; and passive call receive.
CEN 4500, S. Masoud Sadjadi
60
The Example Service Primitives
•
Concrete Service Definition:
–
–
–
–
–
connum = LISTEN (local)
connum = CONNECT (local, remote)
status = SEND (connum, buffer, bytes)
status = RECEIVE (connum, buffer, bytes)
status = DISCONNECT (connum)
CEN 4500, S. Masoud Sadjadi
61
A Simple Transport Protocol
•
We will study
–
The Example Service Primitives
•
–
The Example Transport Entity
•
–
How to express these transport primitives concretely?
We see an example transport entity.
The Example as a Finite State Machine
•
We model the transport entity using an FSM.
CEN 4500, S. Masoud Sadjadi
62
The Example Transport Entity
•
Note that
–
–
•
This example is analogous to the early examples in
Chapter 3 (data link layer).
Many of the details are omitted for simplicity.
The transport layer makes use of the the network
service primitives to send and receive TPDUs.
–
We need to choose the network service primitives to use.
•
Unreliable datagram service:
–
–
•
A complex transport layer!
We discussed most of the issues in the previous chapter
Connection-oriented, reliable network service:
–
This way, we only focus on the issues that do not occur in the lower
layers (e.g. connection establishment and release).
CEN 4500, S. Masoud Sadjadi
63
The Example Transport Entity
•
The transport entity
–
–
–
–
may be part of the operating system
may be a package of library routines running within
the user’s address space.
We assume the latter choice in our example.
We assume also that the application using our library
is single-threaded.
CEN 4500, S. Masoud Sadjadi
64
The Example Transport Entity
•
The interface to the network layer
–
to-net(cid, q, m, pt, p, bytes), from-net(cid, q, m, pt, p, bytes)
•
•
•
•
•
–
On calls to to-net,
•
–
the transport entity fills in all the parameters for the network layer to
read
On calls to from-net,
•
–
cid maps to network virtual-circuit
q is the quantifier bit that indicate control message (0/1=data/credit)
m is the more data bit
Pt is packet type (next slide)
p & bytes, are pointer to the data and an integer showing the length
the network layer dismembers an incoming packet for the transport
entity.
Thus, the transport layer is shielded from the details of network
CEN 4500, S. Masoud Sadjadi
65
layer.
The Example Transport Entity
The types of network layer packets used in our example.
CEN 4500, S. Masoud Sadjadi
66
The Example Transport Entity
•
Each connection is in one of seven states:
–
–
–
–
–
–
–
Idle – Connection not established yet.
Waiting – CONNECT has been executed, CALL
REQUEST sent.
Queued – A CALL REQUEST has arrived; no LISTEN
yet.
Established – The connection has been established.
Sending – The user is waiting for permission to send a
packet.
Receiving – A RECEIVE has been done.
DISCONNECTING – a DISCONNECT has been done
locally.
CEN 4500, S. Masoud Sadjadi
67
The Example Transport Entity
•
Transition between states can occur when any
of the following events occur:
–
–
–
•
A primitive is executed
A packet arrives
The timer expires
Types of procedures in the example
–
–
Directly callable by user programs
Packet_arrival and clock (interrupt routines)
•
•
These are spontaneously triggered by external events: the
arrival of a packet and the clock ticking, resp.
Assumption: these are called when the user process is
sleeping or executing outside the transport entity.
CEN 4500, S. Masoud Sadjadi
68
•
The Example Transport Entity
Flow Control in the example
–
To avoid having to provide and manage buffers within
the transport entity, a different mechanism from the
normal sliding window is employed
•
•
When a user calls RECEIVE, a special credit message is
sent to the transport entity on the sending machine and is
recorded in the conn array. conn is the main data structure
used by transport entity and has one record for each potential
connection.
When SEND is called, the transport entity checks to see if a
credit has arrived on the specified connection (conn[k]). If
so, the message is sent (in multiple packets if need be) and
the credit is decremented. If not, the transport entity puts
itself to sleep until a credit arrives.
CEN 4500, S. Masoud Sadjadi
69
The Example Transport Entity (3)
CEN 4500, S. Masoud Sadjadi
70
The Example Transport Entity (4)
CEN 4500, S. Masoud Sadjadi
71
The Example Transport Entity (5)
CEN 4500, S. Masoud Sadjadi
72
The Example Transport Entity (6)
CEN 4500, S. Masoud Sadjadi
73
The Example Transport Entity (7)
CEN 4500, S. Masoud Sadjadi
74
The Example Transport Entity (8)
CEN 4500, S. Masoud Sadjadi
75
The Example Transport Entity (9)
CEN 4500, S. Masoud Sadjadi
76
The Example Transport Entity (10)
CEN 4500, S. Masoud Sadjadi
77
A Simple Transport Protocol
•
We will study
–
The Example Service Primitives
•
–
The Example Transport Entity
•
–
How to express these transport primitives concretely?
We see an example transport entity.
The Example as a Finite State Machine
•
We model the transport entity using an FSM.
CEN 4500, S. Masoud Sadjadi
78
The Example as a Finite State Machine
•
•
Writing a transport entity is difficult and
exacting work, especially for more realistic
protocols.
In general, to reduce the chance of making
errors and to deal with complexity, we use
modeling.
–
–
In this case, we use a finite state machine to
represent the states that a transport entity may
have during its execution.
Our example has 7 states per connection.
CEN 4500, S. Masoud Sadjadi
79
The Example as a Finite State
Machine
Under what condition the action is taken
Action being taken
Next state
•The example protocol as a
finite state machine.
•Each entry has an optional
predicate, an optional action,
and the new state.
•The tilde indicates that no
major action is taken.
•An overbar above a predicate
indicate the negation of the
predicate.
•Blank entries correspond to
impossible or invalid events.
CEN 4500, S. Masoud Sadjadi
80
The Example as a Finite State Machine
State1
[predicate] event/action
State2
Use the above convention in your projects
when you develop the FSM for your protocols.
The example protocol in graphical form. Transitions that leave
the connection state unchanged
haveSadjadi
been omitted for simplicity.
CEN 4500, S. Masoud
81
Matrix Representation of a Protocol
•
Advantages:
–
For testing: It is much easier for the programmer to
systematically check each combination of state and event to
see if an action is required.
•
–
For testing, some of the states correspond to impossible and some
correspond to illegal states.
–
For implementation: A two dimensional array could keep
track of what procedure should be called when is a state and a
specific event is triggered.
For protocol description: A protocol can be easily expressed
using the matrix representation.
•
Disadvantages:
–
Might be hard to understand, which can be complemented by
the FSM graph.
CEN 4500, S. Masoud Sadjadi
82
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
83
The Internet Transport Protocols: UDP
•
The Internet Main Transport Protocols
–
UDP
•
•
–
TCP
•
•
•
•
A connectionless protocol
Basically, just the IP with a short header added!
A connection-oriented protocol
Introduction to UDP
Remote Procedure Call
The Real-Time Transport Protocol
CEN 4500, S. Masoud Sadjadi
84
Introduction to UDP
•
User Datagram Protocol (UDP)
–
–
It provides a way for applications to send
encapsulated IP datagrams and send them without
having to establish a connection.
It transmits segments of 8-byte header followed
by a payload (the header is shown below).
•
The two ports serve to identify the end points within
the source and destination machines.
The UDP header.
CEN 4500, S. Masoud Sadjadi
Optional: 0 for not computed!
85
Introduction to UDP
•
•
•
When a UDP packet arrives, its payload Is
handed to the process attached to the
destination port.
This attachment occurs when BIND primitive
or something similar is used (the binding
process is the same as in TCP).
In fact, the main value of UDP over just using
raw IP is the addition of the source and
destination ports.
CEN 4500, S. Masoud Sadjadi
86
Introduction to UDP
•
What UDP does NOT do?
1.
2.
3.
–
•
Flow control
Error control
Retransmission upon receipt of a bad segment
All of what UDP does not do is up to the user
process to take care of them.
What UDP do?
–
Providing an interface to the IP protocol with the
added feature of demultiplexing multiple
processes using the ports.
CEN 4500, S. Masoud Sadjadi
87
Introduction to UDP
•
UDP Applications
–
Client-server situations
•
•
•
–
Often, a client sends a short request to a server and
expects a short reply back.
If either the request or reply is lost, the client can just
time out and try again.
Not only the code is simple, but also fewer messages
are required (one in each direction without initial
setup)
Domain Name System (DNS)
•
Uses UDP this way
CEN 4500, S. Masoud Sadjadi
88
Remote Procedure Call
•
In a certain sense, sending a request to a remote
host and getting a reply back is similar to making
a function call in a programming language.
–
–
–
–
In both cases, you start with one or more parameters
and you get back some results.
The observation has led people to arrange requestreply interactions on networks to be cast in the form of
procedure calls.
Such an arrangement, makes the network applications
much easier to program and more familiar to deal
with.
In this way, all the detail of networking is hidden from
the programmer.
CEN 4500, S. Masoud Sadjadi
89
Remote Procedure Call
•
The key work in this area was done by Birrell and
Nelson (1984)
–
–
–
–
–
–
Allowing programs to call procedures located on remote
hosts.
When a process on machine 1 calls a procedure on machine
2, the calling process on 1 is suspended and execution of the
called procedure takes place on 2.
Information can be transported from the caller to the callee
in the parameters and can come back in the procedure
results.
No message passing is visible to the programmer.
This technique is known as Remote Procedure Call (RPC)
The calling/called procedures is known as client/server
CEN 4500, S. Masoud Sadjadi
90
Remote Procedure Call
•
The idea is to make the RPC to look as a local
one, as much as possible.
–
The client program is bound with a small library
(generated) procedure, called the client stub.
•
–
The client stub represents the server procedure in the
client’s address space.
Similarly, the server is bound with a procedure
called the server stub.
•
The client and server stubs hide the fact that the
procedure call from the server to the client is not a
local call.
CEN 4500, S. Masoud Sadjadi
91
Remote Procedure Call
•
Steps in making a remote procedure call. The
stubs are shaded.
CEN 4500, S. Masoud Sadjadi
92
Remote Procedure Call
•
The steps shown in the previous slide:
–
Step 1: the client is calling the client stub.
•
–
Step 2: the client stub is packing the parameters into a
message and making a system call to send the message.
•
–
–
–
–
This is a local call with the parameters pushed onto the stack in a
normal way.
Packing the parameters is called marshalling.
Step 3: the kernel is sending message from the client
machine to the server machine
Step 4: the kernel passing the incoming packet to the
server stub.
Step 5: the server stub calling the server procedure with
the unmarshalled parameters.
The reply trace the same path in the other direction.
CEN 4500, S. Masoud Sadjadi
93
Remote Procedure Call
•
There are many problems left
– “The devil is in details!”
1. Pointer parameters
•
Call-by reference, shallow copy, complex data
structure, etc.
2. Weakly-typed languages
•
In a language like C, you can write a procedure that
computes the inner product of two vectors (arrays),
without specifying how large either one is.
3. Deducing the types of the parameters
•
printf may have a number of parameters, at least one!
4. Global Variables!
CEN 4500, S. Masoud Sadjadi
94
Remote Procedure Call
•
Should we develop RPC on top of UDP or
TCP?
–
–
RPC need not to use UDP packets, but RPC and
UDP are a good fit and UDP is commonly used
for RPC.
However, we use TCP
•
•
When the parameters of results may be larger than the
maximum UDP packet
When the operation requested is not idempotent (i.e.,
cannot be repeated safely, such as when incrementing a
counter).
CEN 4500, S. Masoud Sadjadi
95
The Real-Time Transport Protocol
•
•
•
•
Client-server RPC is one area in which UDP is
widely used.
Another area is real-time multimedia applications.
As different multimedia applications have been
emerging (e.g. Internet radios, Internet telephony,
music-on-demand, video conferencing, and videoon-demand), people started to realize that they are
reinventing the same real-time protocol.
Therefore, the Real-Time Transport Protocol
(RTP) was born as generic protocol for all these
multimedia applications.
CEN 4500, S. Masoud Sadjadi
96
•
The Real-Time Transport Protocol
It was decided to put RTP in user space and have it
(normally) run over UDP.
–
–
–
The multimedia application feeds the streams into the RTP
library, which is in the user space.
The library then multiplexes the streams and encodes them in
RTP packets, which then stuffs into a socket.
In the kernel, UDP packets are generated and embedded in IP
packet, and then in Ethernet frames.
(a) The position of RTP in theCEN
protocol
4500, stack.
S. Masoud Sadjadi
(b) Packet nesting.
97
The Real-Time Transport Protocol
•
Where is RTP?
–
•
RTP is a transport protocol that is implemented
in the application layer.
What is RTP’s function?
–
–
–
To multiplex several real-time data streams onto a
single stream of UDP packets.
The UDP stream can be sent to a single
destination (unicasting) or to multiple destinations
(multicasting).
As RTP just uses normal UDP, its packets are not
treated specially by the routers; there are no
special guarantees about delivery, jitter, etc.
CEN 4500, S. Masoud Sadjadi
98
The Real-Time Transport Protocol
•
Each packet sent in an RTP stream is
numbered
–
–
–
–
This way, the receiver can detect if a packet is
lost
One action on the receiving side can be to
estimate the packet contents (e.g., using
interpolation).
Retransmission is not a practical option.
RTP has no flow control, no error control, no
acknowledgements, and no mechanism to
request retransmissions.
CEN 4500, S. Masoud Sadjadi
99
The Real-Time Transport Protocol
•
RTP payload and its encoding
–
–
Each RTP payload may contain multiple samples,
and may be coded any way that the application
may choose.
To allow for interworking, RTP defines several
profiles and for each profile, multiple encoding
formats may be allowed.
•
•
e.g., a single audio stream may be encoded as 8-bit
PCM samples at 8kHz, delta encoding, predictive
encoding, GSM encoding, MP3, and so on.
RTP provides a header filed in which their source can
specify the encoding but is otherwise not involved in
how encoding is done.
CEN 4500, S. Masoud Sadjadi
100
The Real-Time Transport Protocol
•
Timestaming
–
–
–
The idea is to allow the source to associate a
timestamp with the first sample in each packet.
The timestamps are relative to the start of the
stream, so only the differences between timestamps
are significant (the absolute value has no meaning).
The destination can do a small amount of buffering
and play each sample the right number of
miliseconds after the start of the stream,
independently of when the packet arrived.
•
•
This reduces the jitter and allows multiple streams to be
synchronized with each other.
For example, a digital tv program supporting multiple
languages.
CEN 4500, S. Masoud Sadjadi
101
The Real-Time Transport Protocol
Padding to 4 bytes
Extension header
The RTP header.
Number of contributing source
Application-specific marker bit
(e.g., start of a video frame)
Encoding
scheme
At 2
Id of the
Which stream the
contributing sources packet belongs to
Time from the first sample for reducing
jitter and allowing synchronization
CEN 4500, S. Masoud Sadjadi
For detecting a
lost packet
102
The Real-Time Transport Control Protocol
•
RTCP is the little sister of the RTP that
handles
–
Feedback
•
–
For delay, jitter, bandwidth, congestion, etc.
Synchronization
•
–
For inter-stream synchronization for those streams
using different clocks.
Naming the various sources
•
•
E.g., in ASCII text
This information can be displayed on the receiver’s
screen to indicate who is talking at the moment.
CEN 4500, S. Masoud Sadjadi
103
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
104
The Internet Transport Protocols: TCP
•
•
•
•
•
•
•
•
•
•
•
•
Introduction to TCP
The TCP Service Model
The TCP Protocol
The TCP Segment Header
TCP Connection Establishment
TCP Connection Release
TCP Connection Management Modeling
TCP Transmission Policy
TCP Congestion Control
TCP Timer Management
Wireless TCP and UDP
Transactional TCP
CEN 4500, S. Masoud Sadjadi
105
Introduction to TCP
•
The User Datagram Protocol (UDP)
–
–
is a simple protocol and has its applications.
However, for most Internet applications, reliable,
sequenced delivery is needed.
TCP is the answer!
–
•
The Transport Control Protocol (TCP)
–
–
–
TCP was specifically designed to provide a reliable endto-end byte stream over an unreliable internetwork.
An internetwork can have parts with wildly different
topologies, bandwidths, delays, packet sizes, etc.
TCP was designed to dynamically adapt to properties of
the internetwork and to be robust with many failures.
CEN 4500, S. Masoud Sadjadi
106
Introduction to TCP
•
TCP transport entity can be realized as
–
–
–
•
A library procedure
A user process
Part of the kernel.
In all cases, TCP entity manages TCP streams and
interfaces to the IP layer.
A TCP entity
•
–
–
accepts user data streams from local processes
breaks them up into pieces not exceeding 64 KB
•
–
–
(in practice, often 1460 data bytes for Ethernet)
sends each piece as a separate IP datagram.
When the pieces arrive on the other side, the original byte
stream is reconstructed.
CEN 4500, S. Masoud Sadjadi
107
Introduction to TCP
•
TCP responsibilities
–
–
–
Time out and retransmit datagrams as need be
To reassembles the datagrams and deliver them in
the correct order
Furnishing the reliability requested by the user,
which is not provided by the IP layer.
CEN 4500, S. Masoud Sadjadi
108
The TCP Service Model
•
•
•
•
•
•
The service is obtained by both the sender and receiver
creating end points, called sockets.
Each socket has the socket number (address) consisting
of the IP address of the host and a 16-bit number local
to that host, called a port.
A port is the TCP name for a TSAP.
A socket might be used for multiple connections at the
same time.
Connections are identified by the sockets identifiers at
both ends (socket1, socket2).
No virtual circuit numbers or other identifiers are used.
CEN 4500, S. Masoud Sadjadi
109
The TCP Service Model
•
Port numbers below 1024 are called well-known
ports and are reserved for standard services.
–
–
–
•
ftp: 21
telnet: 23
http: 80
Instead of having one daemon to listen to each of
these port at startup, a single daemon, called inted
(Internet daemon) in UNIX, attaches itself to
multiple ports and wait for the first incoming
connection.
–
When this occurs, inetd forks off a new process and
executes the appropriate daemon in it, letting that daemon
handle the request.
CEN 4500, S. Masoud Sadjadi
110
The TCP Service Model
•
Some assigned ports.
Port
21
23
25
69
79
80
110
119
•
Protocol
FTP
Telnet
SMTP
TFTP
Finger
HTTP
POP-3
NNTP
Use
File transfer
Remote login
E-mail
Trivial File Transfer Protocol
Lookup info about a user
World Wide Web
Remote e-mail access
USENET news
All TCP connections are
–
–
full duplex: traffic goes in both directions.
point-to point: each connection has exactly two end points.
CEN 4500, S. Masoud Sadjadi
111
The TCP Service Model
•
A TCP connection is a byte stream not
message stream
–
–
message boundaries are not preserved.
Same as files in UNIX; the reader of a file cannot
tell how the file was written!
(a) Four 512-byte segments sent as separate IP datagrams.
(b) The 2048 bytes of data delivered to the application in a single
READ CALL.
CEN 4500, S. Masoud Sadjadi
112
The TCP Service Model
•
Urgent Data
–
–
–
When an interactive user hits the DEL or CTRL-C
key to break off a remote computation that has
already begun, the sending application puts some
control information in the data stream and gives it to
TCP along with the URGENT flag.
This event causes TCP to stop accumulating data
and transmit everything it has for that connection
immediately.
When the urgent data is received at the destination,
the receiving application is interrupted (e.g., given a
signal in UNIX terms) so it can stop whatever it was
doing and read the data stream to find the urgent
CEN 4500, S. Masoud Sadjadi
113
data.
The TCP Protocol
•
Every byte on a TCP connection has its own 32-bit
sequence number.
–
•
Separate 32-bit sequence numbers are used for
acknowledgements and for the window mechanism.
The sending and receiving entities exchange data in
the form of segments
A TCP segment consists of a fixed 20-byte header
(plus an optional part) followed by zero or more data
bytes.
•
–
–
The TCP software decides how big a TCP segment should
be.
It can accumulate data from several writes into one segment
or can split data from one write over multiple segments.
•
65,515 bytes of IP payload or 1500 bytes of Ethernet payload size?
CEN 4500, S. Masoud Sadjadi
114
The TCP Protocol
•
The basic protocol used by TCP entities is the
sliding window protocol.
–
–
–
When a sender transmits a segment, it also starts a
timer.
When the segment arrives at the destination, the
receiving TCP entity sends back a segment (with
data if any exist, otherwise without data) bearing
an acknowledgement number equal to the next
sequence number it expects to receive.
If senders timer goes off before the
acknowledgement is received, the sender
transmits the segment again.
CEN 4500, S. Masoud Sadjadi
115
The TCP Protocol
•
Issues
–
–
–
Segments can arrive out of order.
Segments can be delayed so long that the sender
times out and retransmits them.
The retransmissions may include different byte
ranges than the original transmission, requiring a
careful administration to keep track of which
bytes have been correctly received so far.
•
As each byte in the stream has its own sequence
number, this can be done!
CEN 4500, S. Masoud Sadjadi
116
The TCP Segment Header
Not to wait for the buffer to become full
Reset a connection that has To establish a To release a
been confused due to a crash connection connection
•
TCP Header.
The next
byte
expected
ACK is valid or not
Validity of urgent pointer
How many
32-bit words
Not Used
For extra
reliability
4500, S. Masoud
Allows each host to specify CEN
the maximum
TCPSadjadi
payload it is willing to accept!
117
The TCP Segment Header
•
Every segment begins with a fixed-format, 20-byte
header.
–
–
•
•
•
It may be followed by header options.
After options, if any, up to 65,495 (65,535 – 20 IP Header
– 20 TCP Header) data bytes may follow.
Segments without any data are legal and are
commonly used for acknowledgements and control
messages.
A port plus its host’s IP address forms a 48-bit
unique end point.
The source and destination end points together
identify the connection
CEN 4500, S. Masoud Sadjadi
118
The TCP Segment Header (2)
•
The Checksum includes the header, the data,
and the conceptual pseudoheader (see below)
CEN 4500, S. Masoud Sadjadi
119
TCP Connection Establishment
6-31
Three-Way Handshake
(a) TCP connection establishment in the normal case.
(b) Call collision.
CEN 4500, S. Masoud Sadjadi
120
TCP Connection Establishment
•
Normal case
–
When the first SYN segment arrives at the destination, the
TCP entity there checks to see if there is a process that has
done a LISTEN on the port given in the Destination port
field.
•
–
If not, it sends a reply with the RST bit on to reject the connection.
–
If so, the process is given the incoming TCP segment, and
it can either accept or reject the connection.
If it accepts, an acknowledgement segment is sent back.
•
Call Collision
–
The result of the events is that just one connection is
established, not two because connections are identified by
their end points.
CEN 4500, S. Masoud Sadjadi
121
TCP Connection Release
•
TCP connections are full duplex
–
–
–
We assume two simplex connections.
Each simplex connection is released independently.
Either party can send a TCP segment with the FIN bit set,
which means that it has no more data to transmit.
•
–
–
–
When the FIN is acknowledged, that direction is shut down for
new data.
When both connections are shut down, the connection is
rerleased.
Either three (FIN, FIN/ACK, ACK) or four (FIN, ACK,
FIN, ACK) segments!
To avoid the two army problem, timers are used.
CEN 4500, S. Masoud Sadjadi
122
TCP Connection Management Modeling
The states used in the TCP connection
management finite state machine.
CEN 4500, S. Masoud Sadjadi
123
TCP Connection Management Modeling
(2)
TCP connection
management finite state
machine. The heavy solid
line is the normal path for a
client. The heavy dashed
line is the normal path for a
server. The light lines are
unusual events. Each
transition is labeled by the
event causing it and the
action resulting from it,
separated by a slash.
CEN 4500, S. Masoud Sadjadi
124
Agenda
•
•
•
•
•
•
•
The Transport Service
Elements of Transport Protocol
A Simple Transport Protocol
The Internet Transport Protocol: UDP
The Internet Transport Protocol: TCP
Performance Issues
Summary
CEN 4500, S. Masoud Sadjadi
143
Summary
•
•
•
The transport layer is the key to
understanding layered protocols.
Among many services that it provides, the
most important one is an end-to-end, reliable,
connection-oriented byte stream from sender
to receiver.
Connection management
–
–
•
Connection establishment: three-way handshake
Connection release: symmetric & time out!
UDP and TCP
CEN 4500, S. Masoud Sadjadi
144