Beruflich Dokumente
Kultur Dokumente
Introduction
1. 2.
3.
4. 5.
4th layer in the OSI layered structure. Provides logical communication between application processes running on different hosts It is responsible for reliable and cost effective data delivery. i.e. it ensures that packets are delivered error free, in sequence and with no losses or duplications. A high level of error recovery is also provided in this layer. The upper layer protocols depends heavily on the transport layer protocol. Without this layer the whole concept of layered protocols would make little sense. Functions of transport layer: This layer breaks messages into packets. It performs error recovery if the lower layers are not adequately error free. Function of flow control if not done adequately at the network layer. Functions of multiplexing and demultiplexing sessions together. This layer can be responsible for setting up and releasing connections across the network.
Introduction
2. 3. 4.
Consider an application with a server and a number of remote clients. To start with the server executes a LISTEN primitive. This blocks all process in the server until a client turns up. When a client wants to talk to the server it executes a CONNECT primitive. The transport entity carries out this primitive by blocking the caller and sending a packet to the server. Encapsulated in the payload of this packet is a transport layer message for the servers transport entity. The clients CONNECT call causes a CONNECTION REQUEST TPDU to be sent to the server. When it arrives the transport entity checks to see that the server is blocked on a LISTEN. It then unblocks the server and sends a CONNECTION ACCEPTED TPDU back to the client. When this TPDU arrives the client is unblocked and the connection is established. Data can be exchanged using SEND and RECEIVE primitives. When the TPDU arrives the receiver is unblocked. It can then process the TPDU and send a reply. As long as both sides can keep track of whose turn it is to send this scheme works fine.
10
Every data packet sent will also be acknowledged. The packets bearing control TPDUs are also acknowledged. These acknowledgements are managed by the transport entities and are not visible for transport users. Also it takes care about timers and retransmissions. When a connection is no longer needed, it must be released to free up table space within the two transport entities. Disconnection is of 2 types. In the asymmetric variant, either transport user can issue a DISCONNECT primitive, which results in a DISCONNECT TPDU being sent to the remote transport entity. Upon arrival the connection is released. In the symmetric variant each direction is closed separately, independently of the other one. When one side does a DISCONNECT that means it has no more data to send but it is still willing to accept data from its partner. In this case a connection is released when both sides have done a DISCONNECT.
11
A state diagram for a simple connection management scheme. Transitions labeled in italics are caused by packet arrivals. The solid lines show the client's state sequence. The dashed lines show the server's state sequence.
12
Berkley Sockets
Another set of transport primitives used in UNIX for TCP. These primitives are widely used for internet programming. The first 4 primitives are executed in the same order.
13
The transport service is implemented by a transport protocol used between the two transport entities. In the DLL, it is not necessary for a router to specify which router it wants to talk to, but In the TL, explicit addressing of destinations is required. Connection set up over the wire of is simple, but in the TL, initial connection establishment is more complicated. A final difference between the DLL and TL is one of amount rather than of kind. Buffering and flow control are needed in both layers, but the presence of a large and dynamically varying number of connections in the transport layer may require a different approach than we used in the data link layer. In DLL, protocols may allocate a fixed number of buffers to each line, so that when a frame arrives a buffer is always available, but In TL, the larger number of connections that must be managed, and dedicating many buffers to each one is less attractive.
16
17
18
A time of day server-process on host2 attaches itself to TSAP 1522 & wait for incoming call. A call such as LISTEN might be used. An TL user process on host1 wants to find out the time-of-day, & issues a CONNECT request specifying TSAP 1208 as the source and TSAP 1522 as the destination. A transport connection is being established between the TL user process on host1 and server1 on host 2. TL user process then sends over a request for the time. The time server process responds with the current time. The transport connection is then released. The problem with this approach is how does the user process on host1 know that the time of day server is attached to TSAP 1522? In this model services have stable TSAP addresses that are listed in files which lists which servers are permanently attached to which ports.
19
22
23
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.
24
25
Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost.
26
27
28
29
30
31
33
34
35
36
38
41
42
Protocol
FTP Telnet SMTP TFTP Finger HTTP POP-3
Use
File transfer Remote login E-mail Trivial file transfer protocol Lookup information about a user World wide web Remote email access
119
NNTP
USENET news
(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.
44
TCP Segments
46
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 window mechanism. Sending and receiving entities exchange data in segments. Each TCP segment consists of 20 byte header and data (total up to 64K) TCP software decides how big segments should be. It may accumulate data from several writes in to one segment or split data from one write into several segments. Two limits restrict the segment size. First a segment must fit in a single IP payload. Second each network has a maximum transfer unit or MTU and each segment must fit in the MTU (generally MTU is 1500 bytes). Segments may reach on time but acknowledgements may not, segments may be lost or delayed, retransmissions may be different from that transferred earlierhence it is TCPs task to monitor all these problems and fix it.
47
49
52
53
54
55
TCP Pseudoheader
It contains the 32 bit IP addresses of the source and destination machines, the protocol number for TCP (6) and the byte count for the TCP segment. Including pseudoheader in the TCP checksum computation helps detect misdelivered packets. UDP also uses same pseudoheader for its checksum.
57
58
Simulataneous open: when both client & server try to establish connection with each other by sending Syn segments, single connection is established.
61
63
The FSMs used by TCP client and server The first string on lines is i/p, and second is O/P Dashed lines: by server, solid lines: client Coloured lines: special conditions The common value for MSL is between 30 seconds and 1 minute.
64
The FIN segment consumes one sequence number if it does not carry data. The FIN + ACK segment consumes one sequence number if it does not carry data Send FIN segment : can include last chunk of data, or control segment that consumes one sequence number if it does not carry data. The server informs its process abt FIN segment, sends FIN+ACK (with last chunk of data or without data) to confirm, announces passive close(other direction) : also consumes 1 SN The client TCP sends ACK segment, to confirm FIN segment rcd from server, It uses ACK SN=last rcd SN in FIN segment from server+1. : It carries no data and consumes no SN
65
66
Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments, each carrying 1000 bytes?
Solution The following shows the sequence number for each segment:
Segment 1 Sequence Number: 10,001 (range: 10,001 to 11,000)
67
A sliding window is used to make transmission more efficient as well as to control the flow of data so that the destination does not become overwhelmed with data.
TCPs sliding windows are byte oriented.
Uses a protocol similar to go back n and selective repeat. Go back n , as no NAKs and selective repeat as out of order segments are not discarded. Uses byte oriented sliding window and variable size. Window is open closed or shrunk. Sender window size = minimum value of receiver window size or congestion window size. Receiver window size is the value or the no. of bytes the receiver can accept. Congestion window value is given by network to avoid congestion.
68
The server receives a packet with an ack value of 202 and an rwnd of 9. The host has already sent bytes 203, 204, and 205. The value of cwnd is still 20. Show the new window.
Solution: The window closes from the left and opens from the right by an equal number of bytes; the size of the window has not been changed. The acknowledgment value, 202, declares that bytes 200 and 201 have been received and the sender needs not worry about them; the window can slide over them.
69
Now if the sender receives a packet with an ack value of 206 and an rwnd of 12. The host has not sent any new bytes. The value of cwnd is still 20. Show the new window.
Solution: The value of rwnd is less than cwnd, so the size of the window is 12. The window has been opened from the right by 7 and closed from the left by 4; the size of the window has increased.
70
Now the host receives a packet with an acknowledgment value of 210 and an rwnd of 5. The host has sent bytes 206, 207, 208, and 209. The value of cwnd is still 20. Show the new window. (An example on window shrinking) Solution: The value of rwnd is less than cwnd, so the size of the window is 5. Although the sender has not sent bytes 215 to 217, the receiver does not know this.
71
How can the receiver avoid shrinking the window in the previous example? Solution: The receiver needs to keep track of the last acknowledgment number and the last rwnd. If we add the acknowledgment number to rwnd we get the byte number following the right wall. If we want to prevent the right wall from moving to the left (shrinking), we must always have the following relationship.
new ack + new rwnd last ack + last rwnd or new rwnd (last ack + last rwnd) new ack
To avoid shrinking the sender window, the receiver must wait until more space is available in its buffer.
TCP/IP Protocol Suite 72
73
Normal operation
74
Lost segment
75
Fast retransmission
76
77
78
79
Congestion control additive increase In the congestion avoidance algorithm the size of the congestion window increases additively until congestion is detected.
80
If
If
detection starts.
is
by
time-out,
three
new
a
slow
new
start
phase
ACKs,
congestion
81
82
TCP timers
Retransmission timer: used to transmit lost segments. Persistence timer: used to deal with a zero window size advertisement, TCP needs another timer. Keepalive timer: used to prevent a long idle connection between 2 tcps. Time wait timer: used during connection termination. (refer TCP/IP protocol suite by behrouz forouzan for this topic)
83
TCP timers
In TCP, there can be only be one RTT measurement in progress at any time. Measured RTTM , smoothed RTTS Initially: after 1st transmission : RTTS =RTTM ; RTT deviation: RTTD = RTTM/2 After each transmission : RTTS =(a) RTTM +(1-a) RTTS ; where (a=1/8) ; RTT deviation: RTTD = (1-b) RTTD +(b) [RTTS - RTTM]; where (b=1/4)
Karns algorithm
The first segment in the figure is sent, but lost. The RTO timer expires after 4.74 seconds. The segment is retransmitted and the timer is set to 9.48, twice the previous value of RTO. This time an ACK is received before the time-out. We wait until we send a new segment and receive the ACK for it before recalculating the RTO
Congestion Example
RTTM = 1.5 RTTS = 1.5 RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5
RTTM = 2.5 RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625 RTTD = 3/4 (7.5) + 1/4 |1.625 2.5| = 0.78 RTO = 1.625 + 4 (0.78) = 4.74
The sender does not start an RTT measurement when it sends the ACK segment, because it does not consume a sequence number and there is no time-out. No RTT measurement starts for the second data segment because a measurement is already in progress. TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO.
UDP Header
88
UDP Header
Source port number: this is the port number used by the process running on the source host. It is 16 bits long, which means that the port number can range from 0 to 65535. Destination port number: this is the port number used by the process running on the destination host. It is also 16 bits long.
89
UDP Header
Length : this is a 16 bit field that defines the total length of the user datagram, header and data. The 16 bits can define a total length of 0 to 65535 bytes. UDP length = IP length IP headers length Checksum: this field is used to detect errors over the entire user datagram. UDP checksum calculation is different from the one for IP and ICMP. Here the checksum includes three sections: a pseudoheader, the UDP header, and the data coming from the application layer.
90
92
UDP Operation
Connectionless service Flow and error control Encapsulation and decapsulation Congestion control Multiplexing and demultiplexing
93
To send a message from one process to another, the UDP protocol encapsulates and decapsulates messages in an IP datagram.
96
97
99
100
UDP - demultiplexing
At the receiver site there is only one UDP. However there may be many processes that can receive user datagrams, hence demultiplexing is required. UDP receives user datagrams from IP. After error checking and dropping of the header, UDP delivers each message to the appropriate process based on the port numbers.
102
UDP Design
103
UDP design
A UDP package involves 5 components: control block table, input queues, control block module, input module and output module. Control block table: used to keep track of the open ports. Each entry in this table has a minimum of 4 fields: the state (FREE or INUSE), process ID, port number and corresponding queue number. Input queues: used one for each process. Control block module: responsible for the management of the control block table. Input module: receives a user datagram from the IP. It searches the control block table to find an entry having the same port number as this user datagram. If the entry is found the module ,uses the information in the entry to enqueue the data. If the entry is not found, it generates an ICMP message. Output module: responsible for creating and sending user datagrams.
104
107