In this lesson students develop a protocol for reliably sending a message over an unreliable internet. For this lesson, we will be using a simulation similar to the one in the previous lesson. Messages will be restricted to no more than 8 characters each, and messages get dropped messages with some probability on every hop (i.e. you will drop (not deliver) every 4th or 5th message that is sent through the network simulation).
Students are given time to experiment and develop their own protocol, possibly testing or demonstrating their protocol to their peers. At the conclusion of the lesson, students watch a short video explaining how these challenges are addressed in the real world with TCP - the Transmission Control Protocol.
- Packets: Small chunks of information that have been carefully formed from larger chunks of information.
- TCP: Transmission Control Protocol - provides reliable, ordered, and error-checked delivery of a stream of packets on the internet. TCP is tightly linked with IP and usually seen as TCP/IP in writing.
Students will be able to:
- Explain why protocols are necessary to overcome the underlying unreliability of the Internet
- Develop a protocol for reliable communication on the Internet
- Justify the need for acknowledgements and packet numbering in TCP
This is a problem-solving lesson. On the real Internet packet sizes are limited, and transmission is unreliable. In this lesson, we will restrict the packet-size to be very small - 16-bits for the to and from addresses plus only 8 ASCII characters for the message. Also, during the simulation you will drop packets regularly. In a set of 10 messages you should drop one or two messages. You may need to justify these restrictions to students, acknowledging that, yes, this is a simulation, but these types of constraints are a very real problem on the internet.
The problem students have to solve is how to use the 8-ASCII-characters-worth of data to include both a piece of the message they are trying to send, as well as information about how many messages (packets) there are in the whole message, and which number the current packet is.
Students should invent or at least appreciate the need for something like the Transmission Control Protocol TCP. TCP was designed to overcome the inherent unreliability of the Internet. In order to constrain the extent of these errors, larger messages are divided into many packets which are individually routed to their recipient. The receiving computer will send an acknowledgement confirming the receipt of that packet. If the sending computer does not receive an acknowledgement, it will resend the packet until all packets have been acknowledged.
Since packets may arrive out of order, additional data must be included to indicate the order in which the packets should be arranged. Thus, while individual packets cannot be guaranteed to arrive, eventually an entire message can be accurately reconstructed.
Prompt: Your friend sent you a message on the Internet, but you never received it. Based on what you already know about routers and the physical Internet, list what reasons might explain this fact.
Discuss: In groups or as a class, students should share their lists. Use this opportunity to review the layers of the Internet already covered and potential flaws that could lead to a message getting dropped. Some example points of discussion:
- Wires are cut
- Interference on a radio channel
- Router malfunctions or cannot keep up with traffic being directed to it
Build on prior knowledge of the structure of the Internet to reflect on the
unreliability of the Internet.
Introduce the use of packets.
Motivate the need for protocols to ensure reliability when sending messages across the Internet.
Transitional Remarks: When we communicate on the Internet, we are not just sending short text messages as we did in the previous lesson. We also use the Internet to exchange documents, videos, music, and scientific data, and these files can easily grow to enormous size. All of this would not be a problem if the Internet were perfectly reliable, but in reality, errors sometimes occur. Wires can be cut, routers can be overwhelmed with traffic, and interference with electric or radio signals can cause messages to become corrupted. The response to this problem is to split large messages into smaller pieces of information called packets. It turns out that splitting up a message into packets provides many benefits. If a faster route opens up halfway through transmitting a large file, it is easy to reroute later packets in the transmission through that route. Splitting up a message into smaller chunks doesn’t solve all the problems of unreliability on the Internet. Packets can still be dropped or arrive out of order. Today’s challenge is to develop a protocol to reliably send messages even though the network itself is unreliable.
Students should be placed in groups again for this activity using the same "IP address" that they were assigned in the previous lesson. The teacher will again act as the "router", delivering the messages (packets) to their final destination. The simulation we will be doing today has been structured to simulate the unreliability of the Internet.
- Students will only be allowed to send packets containing 8 characters of text! (If you notice more than 8 characters coming through in the packets, delete anything past the 8 allowed characters).
- However, they may construct multiple packets prior to sending them, by using separate index cards, text messages, or email messages. Each message should be sent and distributed through the teacher for this simulation.
- Every message has a small chance of being dropped on each "hop" it makes between routers.
Packets: Information travelling across the Internet is not sent all at once. Instead, it is broken into smaller chunks of data called packets. There are many reasons this is done:
- Limit Data Loss: The Internet is not actually perfectly reliable. Even in the modern day a small percentage of packets (2% is quite common) are lost on transmission. We would prefer to only have to resend small chunks of data rather than the entire message.
- Improve Speed: Once a message is broken into packets, those packets do not have to travel from sender to receiver over the same path. If a faster route opens up mid-transmission, the next packets can switch paths.
- Efficient Network Usage: The total traffic across the network can be more easily balanced across routers if messages have been divided into smaller, more manageable chunks.
Challenge: Develop a protocol for reliably sending a message across an unreliable network. This simulation is modeled after some actual constraints of the Internet - Messages must be divided into packets which may contain at most eight (8) ASCII characters. Messages should be long enough to require at least 10 packets. Packets may not arrive in the order sent. Packets may also be dropped while in transmission.
Directions: With your group, practice sending messages given these new constraints. Once you are comfortable with the challenge, iteratively design a protocol that can reliably send a message to a partner.
- All communication can only be done through the messages routed through the simulated network by the teacher.
- You must send a message that spans at least 10 packets (i.e. an 80 character ASCII message).
- The protocol should account for the possibility that the characters might be entirely random (i.e. not necessarily English - do not count on human intuition to reconstruct the message. The message is not known beforehand).
- The sender and receiver must be confident the full message was successfully transmitted and reconstructed.
In student solutions you should primarily be looking for:
1. Some way to confirm receipt of a packet/message
2. Some way to define the ordering of packets
This activity is designed to provide students a realistic encounter with the actual challenges of the Internet. It is OK if their solution does not perfectly match TCP, the actual solution to this problem.
The Focus: Should be on the protocol for the recipient to acknowledge or re-request missing packets. That is the real challenging part, and other parts of the protocol that emenate from it.
Suggested Message Format: To come up with a non-english message you could have students send a message as ASCII art. For example they could treat the message as a grid and draw something with ASCII characters.
Throughout this simulation, students should recognize:
- Packets are dropped with some frequency
- Packets of more than 8 characters are truncated to just the first 8 characters
- Packets sometimes arrive out of order
If students do not immediately recognize these points, draw them out in subsequent conversations.
The real problem to solve is to think about what the receipient of the messages should do to inform the sender of what's missing and needs to be re-sent. It's tricky because any message the recipient sends back to the sender also stands a chance of being dropped or lost. Your protocol needs to overcome this unreliability for both the sender or receiver. Provide students time to work on their protocol, iteratively testing their work and recording their final protocol.
Provide students an opportunity to either present their protocols in written or auditory form, then test them out by sending a randomly generated message. The goal of this share-out would be to identify the main components of the protocols that groups developed in common.
A Simple Solution
Sender: The simplest solution is to develop something akin to TCP, in which you use part of the message to indicate the the packet number and how many there are total. For example:
- Message 1: 14 Hi
- Message 2: 24 Th
- Message 3: 34 er
- Message 4: 44 e!
Receiver: Should know how many messages there are and can request a resend of any that are missing. For example if you received messages 1, 2, and 4. You could send a message back, something like one of these:
- req: 3
- need 3
- send 3
The way the real TCP works is this: every once in awhile TCP sends back a "cumulative acknowldegement" of how many in-order packets it has received. For example, in an 8-packet message if you received packets:
1 2 _ 4 5 6 _ 8
Then you would send back a message like:
- ack 3
This would indicate to the sender that next packet you need is packet 3. The sender would send 3, and once you got it, your next message would be:
- ack 7
Because you received packets 4, 5, and 6 already.
We're going to watch a short video that talks a little more about the way this protocol and others help us ensure the reliability of the Internet.
Connect Activity to TCP: Either say these points or draw them out through discussion
- The challenges we encountered in today's activity very closely mirror those that exist on the actual Internet.
- The response was the development of a protocol called the Transmission Control Protocol, or more simply, TCP.
- TCP divides larger messages into smaller packets which have ordering information added to their header.
- When a packet arrives at a destination computer, an acknowledgement is sent to the sender, letting them know they don't need to resend that packet.
- Once all the packets have arrived, the ordering information in the headers of the packets allows them to be reordered to create the original message.
1. Pick the two statements about packets and routing on the Internet which are true.
- A. Packets travelling across the Internet take a standardized amount of time and so can be counted on to arrive in the order they were sent
- B. TCP ensures messages can be reliably transmitted across the Internet
- C. TCP depends on the infrastructure of the Internet to be reliable enough to ensure no packets are lost in transmission
- D. TCP must account for the fact that packets may not arrive at a destination computer in the intended order
2. Which of the following is NOT true about packets?
- A. Packets are numbered so if they arrive out of order the message can be reassembled.
- B. A message sent across the Internet can always be contained in a single packet
- C. Packets are routed on different paths from sender to receiver.
- D. The receiver computer must confirm to the sending computer that each packet was received.
3. Match the Definition with the Term
- 1. protocol
- 2. packet
- 3. The Internet Protocol (IP)
- 4. IPv4 packet
- A. A packet of data that uses 32-bit addresses
- B. The required structure of a packet to be sent on the internet
- C. A well-known set of rules and standards used to communicate
- D. A chunk of information that gets sent on the internet
- Watch the following video and discuss questions that arise about how a packet travels from one person to another.
- Watch the following video. Note: Headphones are recommended; this one has some dramatic music!
- Protocols are developed by the Internet Engineering Task Force (among other groups), who publish Requests for Comment (or RFCs) detailing the components of the protocol. If students wish, they may have a look at the one of the actual RFCs for TCP below. RFCs exist for many of the protocols covered in this course.
- IETF Requests for Comment
- CSTA K-12 Computer Science Standards (2011): CD.L3A:8, CD.L3A:9, CD.L3B:4
- CSTA K-12 Computer Science Standards (2011): CL.L2:3
- Computer Science Principles: 6.2.1 (A, D)
- Computer Science Principles: 6.2.2 (A, B, G)