INTRODUCTION TO TRANSPORT LAYER
•
The The tran transp spor ortt laye layerr is loca locate ted d betw betwee een n the the appli applica cati tion on laye layerr and and the the netw networ ork k layer. It provides a process-to-process communication between two application layers, one at the local host and the other at the remote host.
•
•
Communicati Communication on is provided provided using a logical logical connection. connection. The transport layer is responsible for providing services to the application layer; it receives services from the network layer.
Transport rt layer also encomp encompasses asses these funct functions: ions: Transpo t o communicate over the network at the same time Enables multiple applications to on a single device. Ensures that, if required, all the data is received reliably and in order by the
correct application. Employs error handling mechanisms.
Logical connection at the transport layer
application transport network data link physical
application transport network data link physical
Transp anspo ort
lay layer provide videss logical between applicat application ion communication between processes running on different hosts.
Transport--Layer Services Transport •
Layer 4, responsible for the overall end-to-end transfer of application data. data.
Process--to Process to--Process Communica Communication tion
The first duty of a transport-layer protocol is to provide process-to-process communication.
process ss is an applic applicati ationon-lay layer er entity entity (runni (running ng progr program) am) that that uses uses the servic services es of the the A proce transport layer. networkk layer layer is respons esponsibl iblee for commun communica icatio tion n at the comput computer er level level (host(host-toto-hos host t The networ communication). A network-layer protocol can deliver the message only to the destination computer. protocol is responsible responsible for delivery of the message to the appropriate appropriate process A transport-layer protocol
Addressing: Port Numbers ProcessProcess-toto-Pro Process cess commun communicat ication ion is the most most common common impleme implementa ntation tion of clientclientserver paradigm. A process on the local host, called a client client,, needs services from a process usually on the remote host, called a server a server.. •
•
•
•
Operating systems today support both multiuser and multiprogramming environments. For communication, the local host, local process, remote host, and remote process must be defined. addresse essess. To define the The local host and the remote host are defined using IP addr numbers ers. In the TCP/IP protocol processes, we need second identifiers, called port numb suite, the port numbers are integers between 0 and 65,535 (16 bits).
•
•
The client program defines itself with a port number, called the ephemeral port number. The server process must also define itself with a port number. TCP/IP has decided to use universal port numbers for servers; these are called well-known port numbers.
The destination IP address defines the host among the diff differ eren entt host hostss in the the wor orld ld..
After the host has been selected, the port number defi define ness one one of the the proc proces esse sess on this this part partic icu ular lar host ost
•
ICAN ICANN N (Int (Inter erne nett Corp Corpor orat atio ion n for Assi Assign gned ed Name Namess and and Numb Number ers) s) has has divided the port numbers into three ranges: well-known, registered, and dynamic (or private).
Well-known ports: ports: The The ports ranging from 0 to 1023 are assigned and controlled by ICANN. These are the well-known ports. Used for Universal applications. Registered tered ports: ports: The ports ranging from 1024 to 49,151 are not assigned or Regis cont contro roll lled ed by ICANN ICANN.. They They can only only be regi regist stere ered d with with ICAN ICANN N to prev preven entt duplication. ports: The The ports ranging from 49,152 to 65,535 are neither controlled nor Dynamic ports: registered. They can be used as temporary or private port numbers.
•
•
A transport-layer transport-layer protocol in the TCP suite needs both the IP address and the port number, number, at each end, to make a connection. The combination of an IP address and a port number is called a soc socke kett add addre ress ss. The client socket address defines the client process uniquely just as the server socket address defines the server process uniquely
•
•
•
To send send a mess messag age e from from one one proc proces esss to anot anothe herr, the the tran transp spor ortt-la laye yerr prot protoc ocol ol encapsulates and decapsulates messages. The transport layer receives the data and adds the transport-layer header. The packets at the transport layer in the Internet are called user datagrams, segments, or packets. Decapsulation happens at the receiver site. When the message arrives at the destination transport layer, the header is dropped and the transport layer delivers the message to the process running at the application layer.
•
•
•
Whenever an entity accepts items from more than one source, this is multiplexing g (many to one); whenever an entity delivers referred to as multiplexin items to more than one source, this is referred to as demultiplexing (one to many). Th The transport layer at the source perf perfor orms ms mult multip iple lexi xing ng;; the the tran transp spor ortt layer at the destination performs demultiplexing. The The tran transp spor ortt laye layerr at the the clie clien nt site site accepts three messages from the three processes and creates three packets. It acts as a multiplexer.
•
•
•
Whenever an entity produces items and another entity consumes them, there should be a balance between production and consumption rates. If the items are produced faster than they can be consumed, the consumer can be overwhelmed and may need to discard some items. If the items are produced more slowly than they can be consumed, the consumer must wait, and the system becomes less efficient. Pushing or Pulling
If the sender delivers items whenever they are produced-without a prior request from the th e co cons nsum umer er-t -the he de deli live very ry is re reffer erre red d to as . If th the e pr prod oduc ucer er de deli live vers rs th the e it item emss after aft er the con consum sumer er has re reque quest sted ed the them, m, the de deliv livery ery is re refferr erred ed to as .
•
•
•
•
•
Four entities: sender process, sender transport layer, receiver transport layer, and receiver process are to be dealt with for communication at the transport layer. The The send sendin ing g proc proces esss at the the appl applic icat atio ion n lay layer is only only a prod produc ucer er,, prod produc ucing ing message chunks and pushes them to the transport layer. The sending transport layer has a double role: it is both a consumer and a producer. It consumes the messages pushed by the producer. The receiving transport layer also has a double role: it is the consumer for the pack packet etss rece receiv ived ed from from the the send sender er and and the the prod produc ucer er that that deca decaps psul ulat ates es the the messages and delivers them to the application layer. The The las last deli deliv very ery is a pull pullin ing g deli delive very ry;; the the tran transp spor ortt lay layer waits aits unti untill the the application-layer application-layer process asks for messages.
•
Two Two cases of flow control are required: from the sending transport layer to the sending application layer and from the receiving transport layer to the sending transport layer.
A common way of implementing flow control is to use two buffers: one at
the sending transport layer and the other at the receiving a transport layer. A buffer is a set of memory locations that can hold packets at the sender
and receiver. receiver. When the the buf buffer of the the send sendin ing g tran transp spor ortt lay layer is full full,, it inf informs orms the the When application layer to stop passing chunks of messages; when there are some vacancies, it informs the application layer that it can pass message chunks again. When the the buff buffer er of the the rece receiv ivin ing g tran transp spor ortt laye layerr is full, full, it inf informs orms the the When sendin sending g trans transpor portt laye layerr to stop stop sendin sending g pack packets. ets. When When ther there e are are some some vacancies, it informs the sending transport layer that it can send packets again.
15
•
Error control at the transport layer is responsible for
1. Detecting Detecting and discarding discarding corrupted corrupted packets. packets. 2. Keeping track of lost lost and discar discarded ded packets packets and resending esending them. them. 3. Recognizing Recognizing duplicate duplicate packets packets and discar discarding ding them. 4. Buffering Buffering out-of-or out-of-order der packets packets until until the missin missing g packets arrive. arrive. Error Error contr control, ol, unlik unlike flow flow contr control, ol, involv involves es only only the sendin sending g and recei receivin ving g
transport layers. The receiving transport layer manages error control, most of the time, by
informing the sending transport layer about the problems.
•
•
Error control requires that the sending transport layer knows which packet is to be resent and the receiving transport layer knows which packet is a duplicate, or which packet has arrived out of order. For this, packets are to be numbered and hence a field to hold the sequence number of number of the packet is added to transport-layer. For lost or damaged packet, the sending entity can request retransmission using the
sequence number. number. If two packets are having the same sequence number, the receiving entity can detect that it’s a duplicate. Out of Order packets are recognized by observing the gaps in the sequence numbers. •
Packets are numbered sequentially. If the header of the packet allows m bits for the sequence number, number, the sequence numbers range from 0 to 2m - 1.
•
The receiver side can send an acknowledgment (ACK) for for each of a collection of packets that have arrived safe and sound.
•
The receiver can simply discard the corrupted packets. The sender can detect lost packets if it uses a timer.
•
When a packet is sent, the sender starts a timer. If an ACK does not arrive before before the timer expires, the sender resends the packet.
•
Duplicate packets can be silently discarded by the receiver.
•
Out-of-order packets can be either discarded (to be treated as lost packets by the sender), or stored until the missing one arrives.
•
•
•
•
The two requiremen requirements ts can be combined combined if we use two numbered numbered buffers, buffers, one at the sender, one at the receiver. Sinc Since e the the sequ sequen ence ce numbe numbers rs use use modul modulo o 2m, 2m, a circ circle le can can repr repres esen entt the the sequence numbers from 0 to 2m - 1. The buffer buffer is repr represe esent nted ed as a set of slices slices,, called called the sliding window, window, that occupies part of the circle at any time. At the sender site, when a packet packet is sent, sent, the correspon corresponding ding slice is marked. marked. When all the slices are marked, it means that the buffer is full and no further messages can be accepted from the application layer. When an ackn acknow owle ledg dgme ment nt arri arrive ves, s, the the corr corres espo pond ndin ing g slic slice e is unma unmark rked ed.. If some some cons consec ecut utiv ive e slic slices es from from the the begi beginn nning ing of the the wind window ow are are unma unmark rked ed,, the the window slides over the range of the corresponding sequence numbers to allow more free slices at the end of the window.
Sliding window in linear format f ormat
•
Congestion in a network may occur if the load on the network-the
number of packets sent to the network-is greater than the capacity of the network-the number of packets a network can handle. •
Congestion Congestion cont control rol ref refers ers to the the mech mechan anis isms ms and and tech techni niqu ques es that that
control the congestion and keep the load below the capacity. capacity. •
Congestion happens in any any system system that involves waiting. waiting.
•
Congestion Congestion at the transport transport layer is actually the result of congestion congestion at the network layer, which manifests itself at the transport layer.
22
•
•
A transport-layer transport-layer protocol, like like a network-layer protocol, protocol, can provide two type typess of servic services: es: conn connec ecti tionl onless ess and conn connect ectio ion-o n-ori rien ente ted, d, but but the the nature of the services serv ices is different. Conne Connect ction ionles lesss servi service ce at the the tran transpo sport rt lay layer mean meanss inde indepen pende dency ncy between packets; connection-oriented means dependency.
connect ctio ion n le less ss se serv rvic ice e, if the two In conne transport layers do not coordinate with each other, the receiving transport layer does not know when the first packet will come nor when all of the packets have arrived.
No flow control, control, error control, control, or congestion congestion control can be effectively implemented in a
•
In a connectio connection-orie n-oriented nted service, service, the client client and the server first need to esta establi blish sh a logi logica call conn connec ectio tion n betw betwee een n them themse selv lves es.. The The data data exchange can only happen after the connection establishment. After data exchange, exchange, the connection needs to be torn down.
•
In
the network layer,
connection ion-orie riented
servi rvice
means a
coor coordi dina nati tion on betw betwee een n the the two two end end host hostss and and all all the the rout outers ers in between. At the transport layer, connection-oriented service involves only the two hosts; the service is end to end. •
Flow control, error control, and congestion control can be implemented in a connection-oriented protocol.
Connection Connection -oriented -oriented service
Packet 2
The behavior of a transport-la laye yerr pr prot otoc ocol ol,, both when it provides a connectionless and when it prov oviide dess a co conne nnecti ction on--orien oriented ted proto protocol col,, can be bette terr show own n as a finite state machine (FSM ). ).
•
•
•
The first protocol is a simple connectionless protocol with neither flow nor error control. We assume that the receiver can immediately handle any packet it receives. In other words, the receiver can never be overwhelmed with incoming packets.
The transport layer at the sender gets a mess messag agee from from its its appl applic icat atio ion n laye layerr, makes a packet out of it, and sends the packet. The The tran transp spo ort lay layer at the the rec receive eiver r rece receiv ives es a pack packet et from from its its netw networ ork k layer layer,, extr extrac acts ts the the mess messag agee from from the the packet, and delivers the message to its application layer. layer.
•
•
•
•
•
•
•
The The seco second nd prot protoc ocol ol is a conn connec ectio tionn-or orie ient nted ed prot protoc ocol ol call called ed the the Stop-and-Wait protocol, which uses both both flow and error control. Both the sender and the receiver use a sliding window of size size 1. The sender sends one one packet at a time and waits for an acknowledgment acknowledgment before sending sending the next one. A checksum is added to each data packet to detect corrupted packets. When a packet packet arrives at the receiver receiver site, it is checked. checked. If its checksum checksum is incorrect, incorrect, the packet is corrupted and silently silentl y discarded. The silence of the receiver is a signal signal for the sender that a packet packet was either corrupted or lost. Every Every time the sender sender sends a packet, packet, it starts a timer. timer. If an acknowledgm acknowledgment ent arrives before the timer expires, the timer is stopped stopped and the sender sends the next packet. If the timer expires, the sender sender resends the previous previous packet, assuming assuming that the packet was either lost or corrupted. This means that the sender needs to keep a copy of the packet until its acknowledgment acknowledgment arrives.
Stop-and-Wait protocol
The Stop-and- Wait protocol is a connection-oriente connection-oriented d protocol that that provides provides flow and error control.
•
•
To prev preven entt dupli duplica cate te pack packet ets, s, the the prot protoc ocol ol uses uses sequ sequen ence ce numb number erss and and acknowledgment numbers. Assume that the sender has sent the packet with sequence number x. Three things can happen. 1.
The The pack packet et arri arrive vess safe safe and and soun sound d at the the recei eceive verr site site;; the the recei eceive verr send sendss an acknowledgment. The acknowledgment arrives at the sender site, causing the sender to send the next packet numbered x + 1.
2.
The packet packet is corrupt corrupted ed or never arrives arrives at the receiv receiver er site; site; the sender sender resends resends the packet (numbered (numbered x) after the time-out. time-out. The receiver receiver returns an an acknowledgment.
3.
The The pack packet et arri arrive vess safe safe and and soun sound d at the the recei eceive verr site site;; the the recei eceive verr send sendss an acknowledgment, but the acknowledgment is corrupted or lost. The sender resends the packet (numbered (numbered x) after the time-out. Note that the packet here is a duplicate. The receiver can recognize this fact because it expects packet x + 1 but packet x was received.
There is a need for sequence numbers x and x + 1 because the receiver needs to distinguish
•
•
•
•
The acknowledgment numbers always announce the sequence number of the next packet expected by by the receiver. For Fo r example, if packet 0 has arrived safe and sound, the receiver receiver sends an ACK with acknowledgment 1 (meaning packet 1 is expected next). If packet 1 has arrived safe and sound, the receiver sends an ACK with acknowledgment 0 (meaning packet 0 is expected). In the the Stop Stop-a -and nd-- Wait prot protoc ocol ol,, the the acknow knowle ledg dgm ment num number ber alwa lways announces, in modulo-2 arithmetic, the sequence number of the next packet expected. The sender has a control variable, which we call S (sender), that points to the only slot in the send window. window. The receiver has a control variable, which we call R receiver), that points to the only slot in the receive window window..
FSM for the Stop-and-W Stop-and-Wait ait protocol protocol
•
•
The Stop-and- Wait protocol is very inefficient if our channel is thick (large bandwidth) and long(high Round Trip delay). In data communications, bandwidth-delay product refers to the product of a data link's capacity (in bits per second) and its round-trip delay time (in seconds). t 0 20
270
520
Example - satellite communication channel capacity: 50 kbps, frame size: 1kb round-trip propagation delay: 500 msec Time: t=0 start to send 1st bit in frame t=20 t=20 msec msec fram framee sent sent comple completel tely y t=270 t=270 msec msec fram framee arri arrives ves t=520 t=520 msec msec best case case of ack. Receive Received d Sender blocked 500/520 = 96% of time Bandwidth utilization 20/520 = 4%
In another example, assume that in a Stop-and- Wait system, the bandwidth of the line is 1 Mbps, and 1 bit takes 20 milliseconds to make a round trip. What is the bandwidth-delay product? If the system data packets are 1,000 bits in length, what is the utilization percentage
•
The bandwidth-delay product is (1 x 106) x (20 x 10-3) = 20,000 bits. The system can send 20,000 bits during the time it takes for the data to go from the sender to the receiver and the acknowledgment to come back. However, However, the system sends only 1,000 bits. We can say that the link utilization is only 1,000/20,000, or 5 percent. For this reason, in a link with a high bandwidth or long delay, the use of Stop-and- Wait wastes the capacity of the link.
What is the the utilization utilization percentage of the the link link if we we have have a protocol that protocol that can can send send up to up to 15 15 packets packets before before stopping stopping and and worrying worrying about about the acknowledgments? the acknowledgments? The bandwidth-delay product is still 20,000 bits. The system can send up to 15 packets or 15,000 bits during a round trip. This means the utilization is 15,000/20,000, or 75 pe perrce cent nt. Of course, if there are damaged packets, the utilization percentage percentage is much less because packets have to be resent.
Conclusion: Long transit time + high bandwidth + short frame length
•
In stop-and-wait, stop-and-wait, at any point in time, there is only one frame that is sent and waiting to be acknowledged.
•
This is not a good use of transmission medium. medium.
•
To improve efficiency, multiple frames should be in transition transitio n while waiting for ACK.
•
Solution: •
Allowing w frames frames sent before blocking
•
Problem: errors
•
Solutions
•
Pipelining improves the efficiency of the transmission if the number of bits in transition is large with respect to the bandwidthdelay product.
The
key to Go-back-N is that several packets are sent before receiving ing acknowledgments, but the receiver can only buffer one packet. packets is maintained until the acknowledgments acknowledgments arrive. arrive. A copy of the sent packets Receiving window size = 1 (i.e., frames must be accepted in the order they were sent)
An Example
The sequence numbers numbers a are re modulo 2 m , where m is the size of the s the sequence equence number numbe r field field in bits bi ts.. acknowledgment number number is cumulative is cumulative and and defines the sequence number of the In GBN, An acknowledgment next packet expected.
For example, example, if the acknowledgmen acknowledgmentt number (ackNo) is 7, it means all packets with sequence number up to 6 have arrived, safe and sound, and the receiver is expecting the packet with sequence number 7.
Send Send Windo Window w The send window is an imaginary box covering the sequence numbers of the data
packets that can be in transit or can be sent. sent. The maximum size of the window is 2 m- 1
fourr re regio gions ns. The send window at any time divides the possible sequence numbers into fou
The first region, left of the window, window, defines the sequence numbers numbers belonging to packets that are already acknowledged. The sender does not worry about these packets and keeps no copies of them.
The second region, colored, defines defines the range of sequence numbers numbers belonging to the packets that have been sent, but have an unknown status. status. The sender needs to wait to find out if these packets have been been received or were lost. We We call these outstanding packets.
The third range, white in the figure, defines defines the range of sequence sequence numbers for packets packets that can be sent; however, the corresponding data have not yet been received from the application layer. layer.
Finally, Finally, the fourth region, right of the window, defines defines sequence numbers that cannot be used until the window slides.
Thre Th ree e va vari riab able less de defi fine ne th the e wi wind ndow owss si size ze an and d location at any time .
Sf : send window, the first outstanding packet Sn: send window, the next packet to be sent Ssize: send window, size
Sliding direction
40
Recei Re ceive ve Windo Window w The receive window makes sure that the correct data packets are received and that the correct
acknowledgments are sent. In Go-Back-N, the size of the receive window is always 1. The receiver is always looking for the
arrival of a specific packet. Any packet arriving out of order is discarded and needs to be resent.
Only one variable, R n (receive window, next packet expected) is defined for the receive window. The sequence numbers to the left of the window belong to the packets already received and
acknowledged; the sequence numbers to the right of this window define the packets that cannot be received. Any received packet with a sequence number in these two regions is discarded. R is accepted and acknowledged. Only a packet with a sequence number matching the value of R is
Although there can be a timer for each packet that is sent, only one is used in this
protocol. The reason is that the timer for the first outstanding packet always expires first. When the timer expires, the sender resends all outstanding packets. That is why the protocol is called Go-Back-N. On a time-out, the machine goes back N
locations and resends all packets.
FSMs for the Go-Back-N protocol
In the Go-Back-N protocol, the size of the send window must be less than 2 m; the size of the receive window is always 1.
•
If m = 2, window size = 2 m – 1 = 3.
An example of a case where the forward channel is reliable, r eliable, but the reverse is not. No data packets are lost, but some ACKs are delayed and one is lost. The example also shows how cumulative acknowledgments can help if acknowledgments are delayed or lost.
Figure shows what happens when a packet is lost
process at the receiver. receiver. The receiver keeps track The Go-Back-N protocol simplifies the process of only one variable, and there is no need to t o buffer out-of-order out-of-order packets; they are simply discarded. However, this protocol is inefficient if the underlying network protocol loses a lot of packets. Another protocol, called the Selective-Repeat (SR) protocol, has been devised, which, as the name implies, resends only selective packets, those that are actually lost.
The Selective-Repeat protocol also uses two windows: a send window and a receive window. window.
The maximum size of the send window is much smaller; it is 2 m-1. The receive window is the same size as the send window. The Selective-Repeat protocol
allows as many packets as the size of the receive window to arrive out of order and be kept until there is a set of consecutive packets to be delivered to the application layer. layer.
In SR , an acknowledgement Number Number defines defines the se sequenc quencee number of of a si single ngle packet that is is r eceived safe and sound ; there is no f eedba eedbacck for any other.
At the sender, packet 0 is transmitted and acknowledged. Packet 1 is lost. Packets 2 and 3 arrive out of order and are acknowledged. When the timer times out, packet 1 (the only unacknowledged packet) is resent and is acknowledged. The send window then slides
Selective Repeat in Action
FSMs for the SR protocol
The size of the sender and receiver windows can be at most one-half of 2 m. For an example, we choose m = 2, which means the size of the window is 2 m/2 or 2(m-1) = 2. The following figure compares a window size of 2 with a window size of 3.
53
In two way communication, Whenever a data frame is received, the received waits and does not send the control frame (acknowledgement) back to the sender immediately. The receiver waits until its network layer passes in the next data packet. The delayed acknowledgement acknowledgement is then attached to this outgoing data frame. The technique of temporarily delaying the acknowledgement acknowledgement so that it can be hooked with next outgoing data frame is known as piggybacking piggybacking.. The major advantage of piggybacking is better is better use of available channel bandwidth.