Reliable Transmission on Unreliable Networks: TCP

BH: Yucky video. Otherwise okay. We should get TCP out of the TIF -- it's the only real activity!

MF: Brian wants to make improvements to this project--can that become an optional project? We don't have any for U4.

On this page, you will learn the system for ensuring that communication is reliable on the Internet.

What you will do: You will watch a video, read, and explore a simulation of unreliable IP transmissions.

What you will learn: You will learn about how the Internet sends data reliably by using protocols.

On your own: You can code your own Transmission Control Protocol.

Computers, servers, and routers are fairly reliable, but every once in a while a packet will be lost, and devices on the Internet need to tolerate these faults. One way to tolerate faults is not to care. (If you lose one frame of video, it doesn't matter.) Another way (called TCP) is to keep sending packets until they are acknowledged as having been received correctly. TCP (Transmission Control Protocol) guarantees reliable data transmission by keeping track of which packets have been received successfully, resending any that have been lost or damaged, and specifying the order for reassembling the data on the other end.

TCP/IP is a pair of protocols that provide an abstraction. IP lets your computer pretend it has a direct connection to another computer. TCP lets your computer pretend it has a reliable connection to the other computer.


Set Up Your Headphones or Speakers
If your connection blocks YouTube, watch the video here.

The TCP/IP end-to-end design of the Internet is an abstraction:

The routers don't know anything about the messages they carry; all they care about is transmitting them. The computers that send and receive the messages are the only ones concerned with what the messages mean.

  1. Click here to load a starter project. Then save it.
    This project provides a simulation of unreliable data transmission by Internet Protocol.
    • Click the green flag to initialize the incoming transmission variables before each experiment.
    • Click either character to enter a message for it to send to the other one.
  2. In this simulation, the complete message is a string of text that is divided into packets of one letter each. In reality, the packet length is not so strictly limited and messages are usually much longer.
    picture of TCP project stage
  3. Talk with Your Partner Compare the result with what you sent. What problems do you see?

TCP works by including additional information along with each packet so that the receiving computer can keep track of how many packets it has received, re-request any missing packets, and reorder the packets to reconstruct the original message. In this simulation, a packet either arrives correctly (even if it's out of order) or it doesn't arrive at all. But on the Internet, it's possible for a packet to arrive with erroneous data, so the real TCP has to check for errors and request re-transmission of packets with errors too.

  1. Read Blown to Bits pages 306-309.
Tough Stuff
  1. Build a simple TCP. Resolve the unreliability so that messages are received reliably despite the limitations of IP packets. You'll need to change the definitions of:
    • internet transmit () to ()
    • read internet data with ()
    Do not change the definition of send IP packet () to (sprite). That block simulates the unreliable network. You could "solve" the problem by rewriting this block to simulate a perfect network instead of an imperfect one, but that misses the point.
    To solve this problem, you'll need a way to keep track of the order of the data and a way to re-request missing packets:
    • First, solve the problem of packets arriving out of order. You can include extra header information in addition to the packet data in order to help the receiver reconstruct the message. This will require cooperation by both sender and receiver (that is, changes to both gray blocks).
    • Then, solve the problem of packets not arriving at all. That is, make the transmission reliable even though IP is unreliable. This, too, will require changing both sender and receiver.