Sie sind auf Seite 1von 100

TRANSPORT LAYER

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

Services provided by Transport Layer


The transport layer makes use of the services provided by the network layer to provide services to the processes in the application layer. The hardware and or software within the transport layer that does the work is called the transport entity. The transport entity can be located in the operating system kernel or in a separate user process or in the network interface card. The relationship of the network, transport and application layers is shown in fig.
4

Services provided by Transport Layer


1. Types of service: the transport layer provides 2 types of services connection oriented and connectionless or datagram service. A connection oriented service provides for the establishment, maintenance and termination of a logical connection between transport service users. It allows connection related features such as flow control, error control and sequenced delivery. Data transfer: it transfers data between 2 transport entities. Both user data and control data must be transferred. Full duplex service must be provided. User interface: there is no clear mechanism for user interface with the transport protocol. Security : the transport entity may provide a variety of security services. It provides encryption and decryption of data. The transport entity may be capable of routing through secure links or nodes if such a service is available from the transmission facility.
5

2. 3. 4.

Services provided by Transport Layer


5. Quality of service: the transport protocol entity should allow the transport service user to specify the quality of transmission service to be provided. Following are the transport layer QOS parameters: Error and loss levels measures the number of lost or garbled messages as a fraction of the total sent. Desired average and maximum delay measures the time between a message being sent by the transport user on the source machine and its being received by the transport user on the destination machine. Throughput measures the number of bytes of user data transferred per second, measured over some time interval. Priority level provides a way for a transport user to indicate that some of its connection are more important than other ones. High priority connections get serviced before low priority ones. Resilience gives problem of TL termination connection abruptly due to internal problems or congestion

Services provided by Transport Layer


6. Connection management: if connection oriented service is provided, the transport entity is responsible for establishing and terminating connections. 7. Status reporting : it gives the following information Addresses Performance characteristics of a connection Class of protocol in use Current timer values
7

Transport Service Primitives


To allow users to access the transport services, a transport service interface is required. Each transport service has its own interface. Difference between transport service and network service.
PARAMETER Connection oriented service Used by Transport Service Reliable End Users Network Service Unreliable Only transport layer.
8

Transport Service Primitives


TPDU : transport protocol data unit It is the message sent between transport entities. TPDUs are contained in packets which are in turn contained in frames. When a frame arrives DLL processes the frame header and passes the contents of the frame payload field up to the network entity. The network entity processes the packet header and passes the contents of the packet payload up to the transport entity.

Transport Service Primitives

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

Transport Service Primitives



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

Transport Service Primitives

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

Elements of Transport Protocols

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

Elements of Transport Protocols


Addressing Connection establishment and connection release Flow control and buffering Multiplexing Crash recovery

17

Elements of Transport Protocols


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 method usually used is to define transport addresses to which processes can listen for connection requests. These end points are called as TSAP(transport service access point). The analogous end points in the network layer are then called NSAPs. Application processes, both clients and servers can attach themselves to a TSAP to establish a connection to a TSAP. These connections run through NSAPs on each host.

18

Elements of Transport Protocols

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

Elements of Transport Protocols


A better approach is designed called the initial connection protocol. In this instead of every conceivable server listening at a well known TSAP each machine that wishes to offer services to remote users has a special process server that acts as a proxy for heavily used servers. It listens to a set of ports at the same time, waiting for a connection request. Potential users of a service begin by doing a CONNECT request, specifying the TSAP address of the service they want. If no server is waiting for them, they get a connection to the process server. After it gets the incoming request, the process server allows the requested server to inherit the existing connection with the user. The new server then does the requested work, while the process server goes back to listening for new requests.
20

Elements of Transport Protocols


Connection Establishment
When a communication link is made over a network (internet) problems can arise. The network can lose, store and duplicate packets. One solution to the problem is to use throw away transport addresses. In this approach each time a transport address is required, a new one is generated. When a connection is released the address is discarded and never used again. Another solution is to give each connection a connection identifier(i.e. a sequence number incremented for each connection established) chosen by the initiating party and put in each TPDU including the one requesting the connection. After each connection is released each transport entity could update a table listing obsolete connections as pairs. Whenever a connection request comes in, it could be checked against the table, to see if it belonged to a previously released connection. The drawback of this method is it requires each transport entity to maintain a certain amount of history information indefinitely. If a machine crashes and loses its memory, it will no longer know which connection identifiers have already been used. Also a better possible solution is to not allow packets to live longer than known time in the subnet.
21

Elements of Transport Protocols


Connection Establishment Packet lifetime can be restricted to a known maximum time using one or more of the following techniques: 1. Restricted subnet design 2. Putting a hop counter in each packet 3. Timestamping each packet The first method includes any method that prevents packets from looping, combined with some way of bounding congestion delay over the longest possible path. The second method consists of having the hop count initialised to some appropriate value and decremented each time the packet is forwarded. The network protocol simply discards any packet whose hop counter becomes zero. The thirdmethod requires each packet to bear the time it was created, with the routers agreeing to discard any packet older than some agreed upon time. This method requires the router clocks to be synchronised which is difficult to achieve.

22

Elements of Transport Protocols


Connection Establishment It is required to guarantee that a packet is dead and also all its acknowledgements are also dead. Consider T as some small multiple of the true maximum packet lifetime. The multiple is protocol dependent and simply has the effect of making T longer. If a time T is waited after a packet has been sent, it can be assured that all traces of it are gone and neither it nor its acknowledgements will appear suddenly. Clock binary counter lSBs sequence no.

23

Elements of Transport Protocols


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.
24

Elements of Transport Protocols


Connection Release

25

Elements of Transport Protocols


Connection Release

Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost.
26

Elements of Transport Protocols


Connection Release

27

Elements of Transport Protocols


Flow control and buffering Multiplexing Crash control

28

A simple Transport Protocol


A simple transport layer is discussed. The example Service primitives The example transport entity The example as a finite state machine.

29

The Example Service Primitives


CONNECT: a procedure that can be called with appropriate parameters necessary to establish a connection. The parameters are the local and remote TSAPs. During the call, the caller is blocked while the transport entity tries to set up the connection. If the connection succeeds, caller is unblocked and can start transmitting data. LISTEN: when a process wants to be able to accept incoming calls, it calls LISTEN specifying a particular TSAP to listen to. The process then blocks until some remote process attempt to establish a connection to its TSAP. This model is asymmetric. One side is passive executing LISTEN and waiting until something happens where as the other side is active and initiates the connection. Solution : -have the connection attempt fail if there is no listener at the remote TSAP. -have the initiator block until a listener appears. The example uses the strategy of holding the connection request at the receiving end for a certain time interval. If a process on that host calls LISTEN before the timer goes off, the connection is established otherwise rejected and the caller is unblocked.

30

The Example Service Primitives


DISCONNECT: procedure used to release connection. Symmetric disconnection is used in this model. SEND and RECEIVE: used for data transmission. Data transmission is done similar to connection establishment. Therefore there are 5 service primitives used. Each primitive corresponds to a library procedure that executes the primitive. The parameters for the service primitives and library procedures are as follows: - connum = LISTEN (local) - connum = CONNECT (local,remote) - status = SEND (connum,buffer,bytes) - status = RECEIVE (connum,buffer,bytes) - status = DISCONNECT(connum)

31

The Example Transport Entity


The transport layer makes use of the network service primitives to send and receive TPDUs. A connection oriented network is chosen. It includes connection establishment, connection release and management. In general transport entity may be part of host OS or some package of library routines in users space. Here it is considered to be a package of routines. Interface to NL can be through procedures : to_net or from_net. Each procedure has 6 parameters: 1.connection identifier 2. Q=1=>control message, 3. M=1 =>more data from this message follow next packet. 4. packet types: given above 5. pointer to data, 6.integer =>gives no. of data bytes.

33

The Example Transport Entity


When to_net is executed , the transport entity fills in all the parameters for the NL to read. When from_ net is executed, the NL organizes the incoming packet for the transport entity. Sliding window protocols will be used. If the destination window doesnt have space for a next/new packet then the transport entity is suspended till there is space for new /next packet. Also transport entity executes sleep and wakeup procedures. The procedure sleep is executed when the transport entity is logically blocked waiting for an arrival of a packet. Network layer virtual circuit numbers are used as connection identifiers.

34

The Example Transport Entity


Each connection is in one of seven states: 1. Idle Connection not established yet. 2. Waiting CONNECT has been executed, CALL REQUEST sent. 3. Queued A CALL REQUEST has arrived; no LISTEN yet. 4. Established The connection has been established. 5. Sending The user is waiting for permission to send a packet. 6. Receiving A RECEIVE has been done. 7. DISCONNECTING a DISCONNECT has been done locally. Trasnsitions between states occur when any of the following events occur : a primitive is executed, a packet arrives or the timer expires.

35

The Example Transport Entity


When the user calls CONNECT, the NL is instructed to send a CALL REQUEST packet to the remote machine and the user is put to sleep. When the CALL REQUEST packet arrives at the the other side , the transport entity is interrupted to run packet arrival procedure to check whether the local user is listening on the specified address. If so a CALL ACCEPTED packet is sent back and the remote user is awakened. If not CALL REQUEST is queued for time out. If a LISTEN is done within this period, the connection is established else it is rejected. When a user calls RECEIVE a special credit message is sent to the transport entity on the sending machine and is recorded. When SEND is called the transport entity checks to see if a credit has arrived on the specified connection. If so the message is sent and the credit is decremented else the transport entity goes to sleep mode till a credit arrives. As a result in this method data is transferred only when both hosts are ready and buffers are free to store the received data. (go through the program from text)

36

The Example as a Finite State Machine


To reduce the chance of making an error, it is often useful to represent the state of the protocol as a finite state machine. 5 primitives+6incoming packets+1Clock=12 events. Columns represent the states and rows are the 12 events. 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.
37

The Example as a Finite State Machine

38

Internet Transport Protocols


The internet has two main protocols in the transport layer, a connectionless protocol and a connection oriented protocol. The connectionless protocol is UDP user datagram protocol. The connection oriented protocol is TCP transmission control protocol. UDP is a simple protocol and used in applications like client server interactions and multimedia. In applications like internet where reliable and sequenced delivery is required TCP is used.
40

Internet Transport Protocols - TCP


TCP was specifically designed to provide a reliable end to end byte stream over an unreliable internetwork. It was designed to dynamically adapt to properties of the internetwork and to be robust in case of failures. Each machine supporting TCP has a TCP transport entity, either a library procedure, a user process or part of the kernel. In all cases it manages TCP streams and interfaces to the IP layer. A TCP entity accepts user data streams from local processes, breaks them into pieces not exceeding 64kb and sends each piece as a separate IP datagram. When datagrams containing TCP data arrive at a machine, they are given to the TCP entity which reconstructs the original byte stream. TCP checks for right sequence of datagrams an puts in right order. It also checks if any datagrams are lost and does retransmission.

41

TCP- Service Model


TCP service is obtained by both the sender and receiver creating end points called sockets. Each socket has a socket number(address) consisting of IP address of the host and a 16 bit number local to that host called port. A port is the TCP name for a TSAP. For TCP service to be obtained, a connection must be explicitly established between a socket on the sending machine and a socket on the receiving machine.

42

TCP- Service Model


A socket may be used for multiple connections at the same time. Connections are identified by the socket identifiers at both ends (i.e (socket1,socket2)). No virtual circuit numbers are used. Port numbers below 1024 are called well known ports and are reserved for standard services.
Port
21 23 25 69 79 80 110

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

Some assigned ports


43

TCP- Service Model


All TCP connections are full duplex and point-to-point. Full duplex means that traffic can go in both directions at the same time. Point-to-point means that each connection has exactly two end points. TCP does not support multicasting or broadcasting. A TCP connection is a byte stream, not a message stream. Message boundaries are not preserved end to end. For ex: if the sending process does 4, 512 byte writes to a TCP stream, these data may be delivered to the receiving process as four 512 byte chunks, two 1024 byte chunks, one 2048 byte chunk or some other way. There is no way for the receiver to detect the units in which data were 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.

44

TCP- Service Model


When an application passess data to TCP, TCP may immediately send or buffer data. However sometimes the application may really want the data to be sent immediately. In such case sender can use a PUSH flag to instruct TCP not to buffer or delay but to send. Sender can use URGENT flag to have TCP send data immediately and have the receiver TCP signal the receiver application that there is data to be read.
45

TCP Service Model

TCP Stream delivery

TCP Sending & Receiving process

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

TCP Segment Header


Every segment begins with a fixed-format, 20byte header. The fixed header may be followed by header options. After the options, if any, up to 65,535 - 20 - 20 = 65,495 data bytes may follow, the first 20 refer to the IP header and the second to the TCP header. Segments without any data are legal and are commonly used for acknowledgements and control messages.
48

TCP Segment Header

49

TCP Segment Header


The Source & Destination port fields: give the local end points of the connection. A port plus its host's IP address forms a 48bit unique end point. The source and destination end points together identify the connection. The sequence & Acknowledgement number: Ack. No. indictes the next byte expected, not the last byte correctly received. Both are 32 bits long because every byte of data is numbered in a TCP stream.
50

TCP Segment Header


The TCP header length: gives no. of 32-bit words that are contained in the TCP header. This is required because options field is of variable length. It indicates the start of the data Next 6-bit field is not used. Then comes six 1-bit flags.
51

TCP Header flags


URG urgent pointer in use indicates a byte offset from the current sequence number at which urgent data are to be found. The ACK bit=1 to indicate that the Ack. No. is valid. ACK=0=> the segment does not have an ACK so the Ack.no. field is ignored. The PSH bit=1, indicates PUSHed data. The receiver is hereby kindly requested to deliver the data to the application upon arrival and not buffer it until a full buffer has been received (which it might otherwise do for efficiency). The RST bit=1, indicates to reset a connection that has become confused due to a host crash or some other reason. It is also used to reject an invalid segment or refuse an attempt to open a connection.

52

TCP Header flags


The SYN bit is used to establish connections. CONNECTION REQUEST - The connection request has SYN = 1 and ACK = 0 to indicate that the piggyback acknowledgement field is not in use. CONNECTION ACCEPTED - The connection reply does bear an acknowledgement, so it has SYN = 1 and ACK = 1. Thus the SYN bit is used to denote CONNECTION REQUEST and CONNECTION ACCEPTED, with the ACK bit used to distinguish between those two possibilities. The FIN bit is used to release a connection. It specifies that the sender has no more data to transmit. However, after closing a connection, the closing process may continue to receive data indefinitely. Both SYN and FIN segments have sequence numbers and are thus guaranteed to be processed in the correct order.

53

TCP Segment Header


Window size field : Flow control in TCP is handled using a variable-sized sliding window. The Window size field tells how many bytes may be sent starting at the byte acknowledged. A Window size field of 0 is legal and indicates that bytes up to and including Acknowledgement number - 1 have been received, but that the receiver currently doesnt want to receive anymore data. The receiver can later grant permission to send by transmitting a segment with the same Acknowledgement number and a nonzero Window size field. In TCP, acknowledgements and permission to send additional data are completely decoupled. In effect, a receiver can say: I have received bytes up through k but I do not want any more just now. This decoupling (in fact, a variablesized window) gives additional flexibility.

54

TCP Segment Header


A Checksum is also provided for extra reliability. It checksums the header, the data, and the conceptual pseudo header. When performing this computation, the TCP Checksum field is set to zero and the data field is padded out with an additional zero byte if its length is an odd number. The checksum algorithm is simply to add up all the 16-bit words in one's complement and then to take the one's complement of the sum. As a consequence, when the receiver performs the calculation on the entire segment, including the Checksum field, the result should be 0.

55

TCP Segment Header


Urgent pointer: this 16 bit field is valid if the urgent flag is set and used when the segment contains urgent data. It defines the number that must be added to the sequence number to obtain the number of the last urgent byte in the data section of the segment. Options field: provides a way to add extra facilities not covered by the regular header. The most important option is the one that allows each host to specify the maximum TCP payload it is willing to accept.
56

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

TCP Connection Establishment


Connections are established in TCP by means of the three way handshake. Initially to set up a connection, server waits for an incoming connection by executing the LISTEN and ACCEPT primitives. The process starts with the server. The server program tells its TCP that it is ready to accept a connection. This is called a request for a passive open. Although the server TCP is ready to accept any connection from any machine it cannot make the connection itself. The client program issues a request for an active open. A client that wishes to connect to an open server tells its TCP that it needs to be connected to that particular server.

58

TCP Connection Establishment


1. The other side, the client issues a CONNECT primitive tells its TE: is active open to connect to a particular server Specifies the IP address and port to which it wants to connect, the maximum TCP segment size it is willing to accept, and optionally some user data (e.g., a password). The CONNECT primitive sends a TCP segment with the SYN=1, ACK=0 and waits for a response. Sends Seq. no.(arbitrary/random) to initailize the first byte sent from client to server.
59

TCP Connection Establishment


2. When this segment arrives, the destination TE 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 some process is listening to the port, that process is given the incoming TCP segment. It can then either accept or reject the connection. If server accepts, then segment with SYN=1,ACK=1 is sent back. SYN => connection segment Seq. no: initializes the first byte sent from server to client It also defines the receive window used (to be used by client: for flow control)
60

TCP Connection Establishment


3.
Client accepts, and sends back 3rd segment: ACK segment. Acks the 2nd segment with ACK=1 and ack. No Seq. no is same as the 1st segment, Does not use any new seq. nos. It also defines its receiving window size (to be used by server for sending)

Simulataneous open: when both client & server try to establish connection with each other by sending Syn segments, single connection is established.
61

TCP Data transfer (after connection is established)


Can Bidirectional data transfer : piggybacked Data segment can have PSH set so that server tries to deliver data to server process as soon as it receives
Pushing of data: TE maintains buffer for sending and receiving from remote m/c Queue is not be to used then there is flexibility for that using flag PSH Urgent data: As tcp is stream oriented Each byte has position in stream For situation where AL process has to send some urgent bytes Uses URG bit set in flags Puts them at the start of segment followed by normal data Hence uses offset : urgent offset The std TCP implemented does not ever deliver any data out of order.

63

TCP State Diagram

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

TCP Connection Termination

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

TCP Connection Termination


Half Close:

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)

Segment 2 Sequence Number: 11,001 (range: 11,001 to 12,000)


Segment 3 Sequence Number: 12,001 (range: 12,001 to 13,000) Segment 4 Sequence Number: 13,001 (range: 13,001 to 14,000)

Segment 5 Sequence Number: 14,001 (range: 14,001 to 15,000)

TCP/IP Protocol Suite

67

TCP Flow Control

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.

TCP/IP Protocol Suite

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.

TCP/IP Protocol Suite

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.

TCP/IP Protocol Suite

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

TCP Error control


Checksum: used to check corrupt segment Acknowledgment: data and control segments are acknowledged, but ACK segments are not acknowledged. Acknowledgment Type: Cumulative ACK: uses ACK field only when ACK flag is set. The Rx tells the next byte expected to receive. Selective ACK(SACK): Recently used as TCP do not discard out of order, It uses along with ACK defined above, it reports extra info abt block of segment that is duplicated, rcd out of order. TCP format doesnt have provision hence uses an OPTION field Retransmission: Common implementations, a retransmission occurs if the RTO timer or 3-duplicate ACK segments have arrived. Out-of-Order Segments: using SACK

73

TCP Error control

Normal operation
74

TCP Error control

Lost segment
75

TCP Error control

Fast retransmission

76

TCP Error control

Lost acknowledgements (a) before timer

77

TCP Congestion control


Congestion policy: 1. Slow start phase 2. Congestion avoidance 3. Congestion detection

78

TCP Congestion control

Slow start- exponential increase


In the slow start algorithm, the size of the congestion window increases exponentially until it reaches a threshold. Std threshold value is 65,535 bytes.

79

TCP Congestion control

Congestion control additive increase In the congestion avoidance algorithm the size of the congestion window increases additively until congestion is detected.
80

TCP Congestion control

Congestion detection multiplicative decrease

Most implementations react differently to congestion detection:

If
If

detection starts.

is

by

time-out,
three

new
a

slow
new

start

phase

detection is by avoidance phase starts.

ACKs,

congestion
81

TCP Congestion control


Congestion example

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)

Retransmission Time out: RTO = RTTS +4.RTTD

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

Use earlier equation for RTO calculation

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.

Internet Transport Protocols:UDP


It is a connectionless, unreliable transport protocol. It does not add anything to the services of IP except to provide process to process communication. It also performs limited error checking. UDP is a very simple protocol using a minimum of overhead. If a process wants to send a small message and does not care much about reliability it can use UDP. Sending a small message by using UDP takes much less interaction between the sender and receiver than using TCP or SCTP(stream control transmission protocol). UDP packets are called user datagrams and have a fixedsize header of 8 bytes.
87

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

UDP - Pseudoheader for checksum calculation


The pseudaheader is the part of the header of the IP packet in which the user datagram is to be encapsulated with some fields filled with 0s. The protocol field is added to ensure that the packet belongs to UDP and not to other transport layer protocols. The value of UDP in the protocol field is 17. if the value is changed during transmission the checksum calculation at the receiver will detect it and UDP drops the packet. It is not delivered to the wrong host.
91

UDP checksum calculation

92

UDP Operation
Connectionless service Flow and error control Encapsulation and decapsulation Congestion control Multiplexing and demultiplexing

93

UDP connectionless service


Each datagram sent by UDP is an independent datagram. There is no relationship between the different user datagrams even if they are coming from the same source process and going to the same destination process. The user datagrams are not numbered. Also there is no connection establishment and no connection termination, which means each datagram can travel in different paths.
94

UDP flow and error control


UDP is a very simple, unreliable transport protocol. There is no flow control and hence no window mechanism. The receiver may overflow with incoming messages. There is error control mechanism in UDP except for the checksum. This means that the sender doesnt know whether a message is lost or duplicated. When the receiver detects an error through the checksum, the user datagram is silently dsicarded.
95

UDP encapsulation & decapsulation

To send a message from one process to another, the UDP protocol encapsulates and decapsulates messages in an IP datagram.
96

UDP encapsulation & decapsulation


When a process has a message to send through UDP, it passes the message to UDP along with a pair of socket addresses and the length of data. UDP receives the data and adds the UDP header. It then passes the user datagram to IP with the socket addresses. IP adds its own header using the value 17 in the protocol field indicationg that the data has come from UDP. It is then passed to the DLL. The DLL receives the IP datagram adds its own header and passes it to the physical layer. The physical layer encodes the bits into electrical or optical signals and sends it to the remote machine.

97

UDP encapsulation & decapsulation


When the message arrives at the destination, the physical layer decodes the signals into bits and passes it to the DLL. The DLL uses the header to check the data. If there is no error, the header and trailer are dropped and the datagram is passed to the IP. The IP does its own checking. If there is no error the header is dropped and the user datagram is sent to UDP with the sender and receiver IP addresses. UDP uses the checksum to check the entire user datagram. If there is no error, the header is dropped and the application data along with the sender socket address is passed to the process.
98

UDP congestion control


Since UDP is a connectionless protocol, it does not provide congestion control. UDP assumes that the packets sent are small and cannot create congestion in the network.

99

UDP multiplexing & demultiplexing

100

UDP multiplexing & demultiplexing


At the sender site there may be several processes that need to send user datagrams. However there is only one UDP. Hence multiplexing is required. UDP accepts messages from different processes with different port numbers. After adding the header, UDP passes the user datagram to IP.
101

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

Refer to forouzan for problems

107

Das könnte Ihnen auch gefallen