Loading

Module 1: Performance and Control

Notes
Study Reminders
Support
Text Version

Transmission Control Protocol

Set your study reminders

We will email you at these times to remind you to study.
  • Monday

    -

    7am

    +

    Tuesday

    -

    7am

    +

    Wednesday

    -

    7am

    +

    Thursday

    -

    7am

    +

    Friday

    -

    7am

    +

    Saturday

    -

    7am

    +

    Sunday

    -

    7am

    +

Transmission Control Protocol
Welcome back to the course on Computer Network and Internet Protocols.So, till now we looked into the details of the transport layer, and what different services is being provided by the transport layer. Now we will take a specific example a transport layer protocol which is widely used in the networks. So, more than 80 percent of thetraffic over the internet it uses this transmission control protocol to transfer end to enddata. So, we will look in to the details of this Transmission Control Protocol or TCP inshort. And later on we will look into that how you can write an application with the helpof such a programming to send or receive data over TCP connections. So, let us start ourjourney to learn the TCP protocol in details.(Refer Slide Time: 01:03)Well, so this TCP it was specifically design to provide a reliable end to end bytestreaming over an unreliable inter network. So, what is meant by unreliable internetwork? By the time I hope it is clear to you that the network layer, the IP basednetwork layer that we are considering it is providing unreliable service because of this abuffer filled up are buffer over flow from intermediate routers, there is a possibility ofpacket drop. And whenever there is a packet drop from this intermediate routers, thenetwork layer does not take care of that.So, the transport layer, if you want to provide the reliable service on top of the transportlayer, that needs up needs to take care of that packet drop. So, TCP is the protocol whichsupports this reliability on top of this unreliable internetwork. And by internetwork wealso look into that different parts of the network may have quitely different topology. So,it may happen that well one part of the network is using wireless technology, one part ofthe network is using wired technology, another part of the network is using say like thatoptical communication technology.So, there that can be this kind of the various type of technologies which are there in theunderlying network, and on top of that I need to transfer the data. So, for example; if youjust think of an example when you are doing Facebook on top of your mobile; so,whenever you are doing Facebook on top of your mobile so, the first hop is wireless,from mobile, from your mobile to mobile destination that part is wireless.So, that uses a different set of protocol at the data link layer. Then from that destinationto this mobile switching center, that part is the wired network. And that uses high speedethernet networks. So, there it uses another set of protocol. Now from there from thismobile switching center to the service gateway, because say you are just accessing theFacebook server and the Facebook server is somewhere there in say USA. So, you needto send the data to USA so, the gateway which is connecting this Asian network to theUS network that uses optical fiber cable in between. So, you need to transfer the data ontop of that top optical fiber cable. So, the underlying network is hugely different to whichdifferent properties, and you can have different type of packet loss, delay, retransmissionon top of this unreliable network.Now TCP is a protocol which is designed to handle all this different challenges. So, let uslook that how we use TCP to handle this different heterogeneity this different challengesin the networks.(Refer Slide Time: 03:53)Well so, TCP dynamically adapts to the properties of the inter network, and is robust toface many kind of failures which may happen in the network.But this TCP protocol has a long history. So, the base TCP protocol it came as a part ofthis RFC 793. So, this RFCs are some the full form of the RFC is request for comments,and this RFCs are you can think of it as a standard document for a protocol specification,which is published by IETF Internet Engineering Task Force, which is a global body tohandle protocol standardization.So, the first version of TCP came in September 1981 as a part of this RFC 793, and thenit has seen many such changes. So, I have just listed the few changes, this RFC 1122which does some clarification on the TCP protocol, the some level of bug says then RFC1323 which was designed and extension of TCP for high performance, then RFC 2018.So, the standard TCP protocol, it uses this go back N it go back N ARQ for flow controlalgorithm. So, RFC 2018 it uses this selective acknowledgement. So, we call it versioncall TCP SACK, TCP selective acknowledgement protocol with which uses this selectiverepeat protocol to handle the flow control mechanism. In RFC 2581 it discusses aboutthe TCP congestion control algorithm, RFC 3168, it uses one concept called explicitcongestion notification. Even after that there are multiple amendment over the basic TCPprotocol. So, this TCP protocol has changed a lot from what it was designed initially inSeptember 1981.(Refer Slide Time: 05:40)So, a broad look on the TCP service model. So, all TCP connections they have fullduplex and point to point. So, point to point means they are between 2 end host. And fullduplex means both host A and host B whenever you are making a TCP connectionbetween them, host A and send data to host B and at the same time host B will be able tosend data to host A.So, TCP it was designed for this point to point data transfer. Data transfer between 2different machines. It was not designed to support multi casting or broadcasting, whenyou want to send data from one node to a group of nodes, or from one node to set oflarge set of nodes. So, for that TCP was not suitable. So, this TCP in a (Refer Time:06:25) Unix-based system it uses the concept of socket, which define an end to endconnection. So the concept of pipe that we are talking about during our discussion ofgeneric service model of the transport layer. The same thing is a termed as a socket in thecontext of the TCP. So, a socket as 6 tuples, 6 parameters to uniquely identify a socket,the source IP, the source port, the source sequence number, source initial sequencenumber, the destination IP, destination port, and destination initial sequence number; thesame thing that was designed to uniquely identify a pipe in a, logical pipe in a transportlayer.Now once this host A and host B has set up a socket among them, then say host A wantsend some data to host B, sorry, differs host B want to send some data to host A. So, hostB can use this write system call to write the data in this socket. So, host B will write thedata in the socket, then this data will be delivered to this different layer of the protocolstack. Received at the transport layer of host A, then host A can execute the read call toread the data from the transport layer buffer.And this delivery the reliable delivery that will be taken care of the by the transport layerand the delivery of the packet to host A based on it is IP address that will be taken care ofby the network layer. And that way with all this layers of the protocol stack.So this logical pipe or logical socket that defines the service model of a TCP protocol.So, all the services of this TCP protocol is implemented to support reliable data throughthis pipe which is termed as the socket.(Refer Slide Time: 08:17)So, in a Unix model, Unix-based socket implementation, we normally run a singledaemon process, which is called as a internet daemon or inetd, this inetd it runs all thetimes at different well known ports. So, it is not like that the all the time you have toopen you have to keep one socket open.So, this inetd takes care of that, the inetd keeps on running on different well known ports,and wait for the first incoming connection. So, when the first incoming connectioncomes, this inetd it forks; that means, it creates a child process with a new process id andstarts the corresponding daemon. So, for example, if you want to do a http file transfer.So, http file transfer for that you have to run http daemon which at the http server whichruns at port 80. So, initially this inetd keeps on listening on port 80 and whenever you tryto initiate a connection and port 80, then httpd pops up, because http httpd daemonprocess, which will use hypertext transfer protocol at port 80, that will have looked intothe discussion of application layer protocol. So, it will start that daemon process andcreate the socket at port 80 at the client, port 80 at the server and some random port atthat the client and start receiving the http packet.Similarly, for ftpd type of the protocol the ftpd will start at port 21.(Refer Slide Time: 09:44)So, few details about TCP; so, first of all TCP connection is a byte stream not a messagestream, so, every byte is identified by a unique sequence number, that we discussedduring the generic service discussion of a transport layer protocol.And this message boundary - they are not provided preserved end to end; that means, allthe messages are in TCP terms we call it as a segment that we have looked into, thesegments may not be of the same size. The difference segments may vary. So, here fromhost B to host A, it may happen that the first segment is starting from sequence number100, and has a length 100 so, it goes from 100 to 200. The second sequence it goes fromthis should be 201 it goes from 201 to 250, the third segment it goes from 251 to 400. So,that way this segment contains some 100 bytes of data, this segment contains so, this issay from 101 to 200. This context contain contains 100 bytes of data. This contains 50bytes of data and this contains 200 bytes of data. So, they have different segments mayhave different size and the size of the segment will be determined by the flow controlalgorithm that we’ll see later on. Now in a hypothetical example, if it happens that wellthis segment 1 is received correctly by host A and say segment 2 and segment 3 aredropped a lost. So, host B will try to retransmit bytes 201 to bytes 400. So, this should be201. So, it will try to retransmit from bytes 201 to bytes 400.So, in this TCP philosophy it is not trying to retransmit 2 segments, rather it willunderstand that byte 201 to byte 400 has lost. And it need to retransmit bytes 201 tobytes 400, not the 2 segment. So, this segments may not preserve, because in TCPeverything is in the form of a byte stream, and everything is identified by how manybytes I have sent or how many bytes I have received or how many bytes are in transitionin the network. So, whenever it is doing the retransmission, may be because of that ratecontrol algorithm which we will discuss in details.(Refer Slide Time: 12:16)It may happen that this entire thing is divided into 2 different bytes 2 different segments.So, the first segment contains bytes 201 to 300. And the second segment contains bytes301 to 400. So now, you can see that the earlier earlier division that were that we hadfrom bytes to segment that was not being preserved here. So, earlier I have a smallsegment of 50 bytes and another large segment of 150 bytes. But now whenever I amdoing the retransmission, I found out or better to say that TCP at host B finds out thatwell, now I do not need to send a small segment of 50 byte, rather I can retransmit thisentire byte with 2 segments of 100 bytes each. So, that is why we use this term that themessage boundaries are not preserved end to end in the context of a TCP protocol. So,everything is byte stream.(Refer Slide Time: 13:24)One example that the sending process it does four 512 byte writes to a TCP stream usingthe write call to the TCP socket. So, the application is sending four 512 bytes of blocks tothe transport layer, and if you remember that the transport layer architecture, you havethis application whenever the application is making a write call, that data is going to abuffer.So, the data is going to a buffer, and the transport layer entity, it is reading the data fromthis buffer and creating the segments. Now when it is creating the segments, if thesending process writes four 512 bytes block to this buffer, now this data may bedelivered as four 512 bytes chunks that mean four 512 bytes segment, two 1024 bytessegments or one 2048 byte segments or in some other way it is not necessary that all thesegments need to be a of same size.So, there is no way for the receiver when the receiver will receive that data, to detect theunits in which the data were written by the sending process. So, at the sending process aswritten data in 512 byte chunks, but whenever the receiver process will receive the data,that is the opposite team, you get the data put it in a buffer receiver buffer, then thereceiver application will make a read call to read the data from the buffer. And when thereceiver application will made the read call to read the data from the buffer it will againread certain number of bytes. And during that time it may happened that the read, read,read this application is making a read call at 1024 bytes chunks.So, the sender has written it at 512 bytes chunks and the receiver is receiving in that1024 bytes chunks. So, that may widely differ and even the receiver does not know thatat which or a what was the chunk size when the sender has written that to the transmitprocess to the transmission control protocol to the TCP process.(Refer Slide Time: 15:46)OK? So, this is the header structure of the TCP protocol. So, the well known fields arealready there, that you have looked into the source port and the destination port, touniquely identify the application through which you are making a communication.You have this sequence number to uniquely identify each packet you have anacknowledgement number to acknowledging the bytes that you have received. I made amistake while taking, I have told that sequence number for packet rather than thatsequence number for the byte because you are using byte sequence number. So, youshould use the correct term here.Then the header length, the length of header certain flags so, these are the flag bits. So,we will look into the flag bits in detail. Just for the few flag bits like this FIN flag FIN bitlike this FIN bit is used to close connection to finish a connection. So, if this FIN bit isset; that means, it is a connection closure message if this SYN bit is set, SYN bit is forconnection initialization. So, if this SYN bit is set; that means, it is a SYN message forconnection initiation. If this ACK bit is set; that means, it is an acknowledgementmessage which is sending this acknowledgement number about the up to which byteshave been acknowledged by the receiver.
Transmission Control Protocol - Part 2
Then you have this window size. This window size is the receiver advertised windowsize for sliding window protocol for dynamic buffer management. So, with this windowsize, the receiver is announcing that what is the available buffer space in the receiverside; this is 16-bit window size.So, we have 32-bit sequence number 32-bit acknowledgement number, 16 bit windowsize. Certain checksum to check that the correctness of the received data, urgent pointerwe will discuss about this urgent pointer later on; in brief like if you want to send somemessage urgently by bypassing the queue, because if you look into the transmit queue,trans or that transport layer queue.That transport layer queue is FIFO thing First In First Out queue. So, whatever byte hasbeen came first, it will send that byte first. So, if you set the urgent pointer, the urgentpointer says that well if you are sending some data from the application by setting theurgent pointer; that means, whatever data you are sending from the application layer bysetting the urgent pointer, you can do that with the help of socket programming, we willlook into that. If you do that then it will first create that segment and segment then send itout with the urgent bit set to one. It indicates that this particular data is urgent that shouldbe should not wait inside the queue for this first come first serve or first in first outbehavior.Then you have some optional fields. And finally, the data which is coming from theupper layer; that means, the pay load for this packet.(Refer Slide Time: 18:37)Well we have looked into that. The TCP sequence number and acknowledgement numberit uses 32 bits sequence number and 32 bit acknowledgement number.So, every byte on a TCP connection has it is own 32 bit sequence number. So, because itis a byte stream oriented protocol that you have seen. So, TCP it uses sliding windowbased flow control. So, the acknowledgement number, it contains the next expected bytein order which acknowledges the cumulative bytes that been received by the receiver.So, the example is like that. If you receive an acknowledgement number 3 1 2 4 5; thatmeans, that the receiver has correctly received all the bytes up to 3, 1, 2, 4, 4 and it isexpecting the byte 3, 1, 2, 4, 5. So, that way it is the cumulative acknowledgementnumber. So, once you are getting an acknowledgement number, it means that all thebytes before that number immediately before that number, that has been receivedcorrectly by the receiver and it is expecting that particular bytes.So, it is expecting byte 3, 1, 2, 4, 5 and it has received everything correctly up to byte 3,1, 2, 4, 4.(Refer Slide Time: 19:42)So, we looked into this earlier. That in TCP this message boundary we call it has asegment. So, the sending and the receiving TCP entities they exchange the data in theform of segment. In general, a segment consists of a fixed 20-byte header plus anoptional part. So, the header format that we have looked earlier the TCP is segmentheader followed by 0 or more data bits. So, if it is a connection message or connectionclosure message like the SYN message or the FIN message, you do not have any data,but if it is a data message you may have additional data which is along with thatsegment.(Refer Slide Time: 20:22)Now, how let us see how this TCP segments are being formed and as you have seenearlier, that it is not necessary that all the segments will be of equal size. Here it will belittle clear to you that why all the segments are not of equal size in TCP. So, TCP it canaccumulate data from several write calls into one segment. Or split data from one writecall into multiple segments.So, this write call with this write system call you’re sending a chunk of data from theapplication to the transport layer. Now whenever the TCP is running, TCP say even ifyou have send some just think of you have sent 1024 byte data you are sending 1024byte data as a single chunk from application layer to the transport layer with the help ofthis write system call.It may happened that, the TCP may break that 1024 chunk into two 512 byte chunk, andsend 2 segments based on the need - the need, I will discuss a couple of minute later. Orit can combine thousand two 1024 byte chunk together, and create a single segment of2048 byte and send it to one go.Now, how this segments are been created? That the segment size it is restricted by 2parameters. The first parameter is the IP payload; the amount of data that you can putinside the IP fragment, whenever it is going to the network layer. That is restricted to65515 bytes. So, your segment size cannot be more than that. The second parameter isthe maximum transmission unit of the link.So, what is maximum transmission unit? That means, whenever you are considering andnet multiple network link from say source to destination, this links have a maximumtransmission unit. So, that comes from the concept of data link layer, how this maximumtransmission unit from data link layer comes into practice. We will discuss that in detailswhen we discuss about the data link layer.But for the time being, just take it as an example, or take it as an given postulate that fordifferent technology the maximum transmission unit is different. So, for example, if thislink is the Wi-Fi link, you have one MTU, if this is an Ethernet link or a WAN link youwill have another MTU. If this is an optical fiber link, you will have another MTUMaximum Transmission Unit. So, the maximum transmission unit is basically that at asingle go, what is the amount of data or what is bit should be the amount of the data thatyou can put inside the packet.(Refer Slide Time: 23:10)So, what TCP does? TCP get uses this write calls from the application to write the data inthe TCP sender buffer. So, here in this example that the application makes a write call towrite data in the transport buffer, and the sender it maintains a dynamic window based onthe flow control and the congestion control algorithm.So, ideally your sending rate was minimum of network rate and receiver advertised rate.So, whenever we convert this in the window form, your sender window size will beminimum of one window size which will be given by the congestion control protocol.So, earlier we are talking about that in case of congestion control, you increase thenetwork rate from a low rate to very high rate using this additive increase principle.So, to increase that rate, it is just like your increasing the window, window size. So, sizeif you are increasing the window size; that means, at the same instance of time you willbe able send more data. So, you will be able to increase the rate. So, this congestionwindow keeps a indication that well if your window size is 1 so, you can send 1 byte ofdata if your window size is 2, you can send 2 bytes of data simultaneously, if yourwindow size is 4, you can send 4 bytes of data simultaneously.So, you have this congestion window and the receiver advertised window size minimumof that. So, you have this sender window size. So, this sender window is dynamicallytriggered, dynamically updated based on the receiver advertise window size and thecongestion window size, that you are gradually increasing in the additive increase space,and whenever a congestion is deducted you are dropping it again to small value or aminimum value.So, this flow and congestion control algorithm, it will use this window size and based onthat, your segment will be created.(Refer Slide Time: 25:07)So, this is the algorithm for creating a segment. So, today’s implementation of TCP, ituses this path MTU discovery a protocol which is there in the internet control messageprotocol path, as a path of the internet control message protocol which is implemented atthe network layer.So, what it does? Is it tries to estimates that what is the MTU of all the links in the path.So, by getting the information about all the MTUs of the path, of the link in the path so,as an example if it happens that well, so, these are the links. So, this is your source andthis is your destination. So, this link support 512 byte this supports 1KB, this supports1KB and this supports say 256 byte. So, if that is the case; that means, ideally you shouldnot send data more than 256 byte in this entire end to end path.So, that is the task which is done by this path MTU discovery mechanism inside theICMP protocol Internet Control Messaging Protocol. And it sets up its maximumsegment size during the connection establishment. So, during the connectionestablishment, by exchanging this message at the network layer by getting this feedbackfrom the network layer it is sets up the maximum segment size.This maximum segment size sometime depends on other parameters, like the bufferimplementation of what is the amount of the data that your buffer can hold at one go.Now the sender it checks the window after receiving an ACK, because whenever you arereceiving an ACK, with that you have this currently receiver advertised window size,which will tell you that what how much of the data the receiver can hold.So, the challenges which is there in the TCP design, and from here we will look into thedesign details design in details. First of all this segments are constructed dynamically.So, retransmission that do not guarantee that the retransmission of the same segment.So, that we have seen earlier, that the earlier you had one segment of 50 bytes anothersegment of 150 bytes and whenever you are making a retransmission you are makingtwo retransmission of 100 bytes each. So, retransmission may content additional data orless data or rearrangement of the segments. And sometime these segments may be out oforder. Because TCP it does not determine the path, the network layer is determining thepath. And the network layer it may happen that for one segment, one packet which iscoming from the application the network layer packet, it decides one path for anotherpacket it decides another path. Because of this load balancing or many other mechanismin the routing protocol. And because of that this segments, you may receive the segmentsout of order a TCP. So, this TCP receiver it should handle the out of order the segment ina proper way so, that data wastage is minimized.So, if you are applying this go back N ARQ and if you just think of that well, if I amreceiving something out of order I will not put it in the buffer because anyway the senderwill retransmit the entire thing all together; that is not a wise idea. Why? Because smallexample, because it may happen that at the this is a receiver this is a sender, the receiverside say you have received this much of data and then you have received this much ofdata.Ok, so, you have received from say 100 to 120, then 121 to 150, you have not receivedthen from 151 to some 500 byte you have received. Now at this stage whenever thesender gets a time out, the sender will try to retransmit this byte along with all the otherbytes which are there in the sender buffer. So, this is the sender buffer we will send that,retransmit that data.Now, we have this window size field in the TCP segment header. So, this window sizefield is used for flow control algorithm in TCP. It uses a variable size sliding windowprotocol, the dynamic buffering that we have looked into earlier. So, this window sizefield it tells that how many bytes the receiver can receive, based on the current free sizeat it is buffer space. And as we have seen earlier that a window size 0 means, the receiverdoes not have a sufficient buffer space.So, the sender should stall transmitting further data until it gets a good amount orsufficient or sufficient amount of window size advertisement. Now TCPacknowledgement; so, the final TCP acknowledgement it is a combination of theacknowledgement number and the advertised window size, based on that the sender willtune its parameter. So, that is the basic things about the TCP protocol.So, in the next class, we will go to the details of this sliding window based flow controlalgorithm which is adopted as the part of the TCP.Thank you all for attending this class.