CIS131 Chapter 09
From Cis131
Summary - Choosing Shipping Options When Transporting the Goods over the (Network) Roadway
In this chapter we will list the main features of TCP, explain the TCP error recovery process, and explain why a computer needs to use multiple TCP port numbers. We will also learn the well known TCP port numbers and explain segmentation.
Hello, I'm at Your Service
The transport layer is the layer below the application layer. In Chapter 8 we learned how some common types of communication take place in the application layer. We saw that HTTP sends an HTTP GET command. That command is sent to the transport layer, we are going to look at what happens at this layer.
Full Service Shipping
The transport protocols are built into the OS (Operating System) which is different then the application layer protocols, which are implemented by the applications. The two transport protocols are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). We will be focusing on TCP instead of UDP, TCP provides a higher lever of service then UDP.
Shipping Basics: Controlling Shipments Using Shipping Labels
In Chapter 5 we learned about encapsulation, with TCP a header is added using the same method. The application sends the data to the transport layer, the transport layer adds a TCP header to the data. The TCP header and the data behind it are called a TCP segment. TCP doesn't have to know anything about the data sent by the application, it just delivers the information. Let's take a look at the big picture up to this point.

We can see the TCP header is added, and we see the segment is then sent to the Internetwork layer. We will learn what happens there in Chapter 10. We have already learned in Chapter 5 what happens at the Data Link layer with the frame header and trailer. We looked at the frame header and trailer in detail. In this chapter will will look at the TCP header in detail. Also we have already discussed the encoding that happens at the physical layer.
Purchasing Insurance for Your (Network) Shipment
In Chapter 3 we learned that TCP uses sequence numbers to perform error recovery. We also learned in Chapter 5 that the FCS (Frame Check Sequence) in the frame trailer is used to performed error detection. We have already looked at how error detection is performed, now we will focus on error recovery.
The Mechanics of Delivery Confirmation
The TCP header has many fields as you can see from the diagram on the right. The two that are used for error recovery are the sequence number and the acknowledgement number fields. When two computer are talking the data that is sent is broken down into multiple segments. Each segment has a TCP header with a sequence number. When data is sent from one computer to another the receiving responds with an acknowledgement number of the next segment it is expecting to receive. This is referred to as forward acknowledgement.

Lose All You Want - We'll Make More
If their is an error in the data as it travels from one computer to another then the error will be detected at the data link layer and the frame will be discarded. If this happens the receiving computer will notice it didn't receive the segment. It will ask the sending computer to resend the data by including the missing sequence number in the acknowledgement field. This is outlined below.

Big Box, Small Truck - What Do You Do?
The data that is sent over the network is broken down into smaller chunks of data called segments. The maximum size of a segment is called the MSS (Maximum Segment Size) and is usually 1480 bytes including TCP header. If you have data that is larger then 1480 bytes it needs to be split into multiple segments. In the diagram above we see that three segments were sent before the acknowledgement was sent. The number of segments that a network device will receive before an acknowledgement is sent is defined in the window field.
Why Three Smaller Segments Is Better Than One Big Segment
The reason we want to split our data into smaller segments is incase we have errors in the transmissions on the line we won't have to resend all the data again. If we have a 200MB file that we are sending with out segmentation if one bit is bad the whole file would have to be resent. If the same file is broken down into segments only the one segment has to be transmitted.
My Little White Lie About Acknowledgments
Here is how the sequence numbers really work. The sequence number identifies the first byte in the data portion of the segment. Below we can see how this works using a data size of 1000 Bytes.

Delivering the Package to the Right Person, Not Just the Right Address
In the TCP header we see a source port and a destination port. The ports are used to know which application to send the data too. You may run more then one application at a time that is using TCP. If this is the case the computer needs to know where to sent it.
The Chicken, the Egg, and the Destination Port of the First Segment
Each instance of an application that requires TCP is given a TCP port. This port is placed in the source port field of the TCP header when data is sent. The computer replies with the port number in the destination port. The destination ports for the client side applications are dynamically assigned port numbers, or ephemeral port numbers. There are a bunch of well known ports such as port 80 for web servers.

Starting Off on the Right Foot Using a TCP Connection
When two computers communicate a process called TCP connection establishment takes place. This sets up the values for the fields in the TCP header that each side agrees on. Once complete a TCP connection is created which is the rules the two sides agreed to use.

