Lesson 6: Sending Numbers

Overview

In this lesson students will return to the Internet Simulator in order to send a simple line drawing to a classmate. Students will be presented a grid on which they will draw an image (connecting 3-7 dots with straight lines). They must develop a protocol which will allow them to send any image they might create on their grids, paying particular attention to how many bits are used to represent each binary number. Students will therefore have additional practice encoding and decoding binary numbers and develop further intuitions about the properties of binary numbers in a hands-on way. The lesson concludes by testing protocols using a teacher-supplied test-image to transmit.

Purpose

The main purpose of this lesson is to reveal that just because we now know how binary numbers work, there are still challenges of information representation and communication. We use the Internet Simulator to enforce some of the constraints imposed by real computers and systems. In particular we are interested in developing a more robust protocol for sending a list of numbers over the internet.

Students will need to make choices about how to structure their messages in terms of number of bits to use for each number and even how to communicate the beginning and end of the list. While the binary number system can be used to represent any value we wish, in practice the range of values we are able to represent is limited by the number of bits we use. Thus, protocols for exchanging binary information must specify in advance how many bits will form a single number among other things. Without knowing this information the receivers of a message have no way of determining how to break up an incoming stream of bits into individual numbers; it will just appear to be a random string of 0s and 1s.

Agenda

Getting Started (5 mins)

Activity (35 mins)

Wrap-up (10 mins)

Assessment

Extended Learning

View on Code Studio

Objectives

Students will be able to:

  • Calculate the range of values that can be represented using binary numbers of a given size in bits.
  • Invent a simple communication protocol for sending a list of numbers that represent coordinates on a cartesian grid.
  • Use the Internet Simulator to send the list of points that make up the drawing to a friend.

Preparation

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Students

Vocabulary

  • Protocol - A set of rules governing the exchange or transmission of data between devices.

Teaching Guide

Getting Started (5 mins)

Review binary numbers.

Discussion Goal

Students will likely need more time to review the binary number system if they have not seen it prior to this class. Provide students an opportunity to review key topics from yesterday, as they will be applying them in today’s lesson.

Teaching Tips

Binary review should take about 5 minutes. Do not overly emphasize binary review here if you spent enough time with binary in the previous lessons. As long as students have a reasonable facility with the decimal equivalents of 5- or 6-bit numbers, that’s enough to do the main activity.

Review properties of binary numbers covered in the previous lesson, especially the relationship between the powers of 2 and the number of bits you need to encode a particular number.

Here are a few sample questions you can throw out:

  • "How many more numbers can be represented with 4 bits as opposed to 3?"
    • Twice as many. Every time a bit is added the number of values we can represent doubles
  • "What is the highest value I can count to using 3 bits? What about with 4?"
    • With 3 bits, 7. With 4 bits, 15. In general the answer is 2^(number of bits) - 1
  • "Justify the following claim: Regardless of the number of bits in our binary number system, the first value we represent is 0."
    • This is actually the case in any number system that uses place value. The smallest value we can represent is composed of all 0s and is exactly 0.

Remarks

Today we're going to combine what we've learned about communication protocols and binary numbers. You and a partner will invent a protocol that allows you to send a list of numbers to represent a drawing. To help us we'll use a new version of the Internet Simulator.

Activity (35 mins)

Use a discovery-based method

(This tip first appeared in Unit 1 Lesson 3 introducing the "A/B" version of the internet simulator. The same principles apply here.)

Discovery-based introduction of tools in nutshell:

  • Get students into/connected to the tool
  • Give students working in partners a fixed amount of time (5 minutes or so) to poke around and see if they can figure out what it does and doesn't do -- typically this might be presented as a mystery worth investigating
  • Ask the group to report what they found
  • Teacher fill in any gaps or explanations of how the tool works afterwards

Familiarize yourself with the Internet Simulator?

If you are using this version of the Internet Simulator for the first time you should watch the student video: Internet Simulator - Part 2 - Video

Introduce the Internet Simulator

We encourage you to use a "discovery-based introduction" to this and all other tools in the Code.org curriculum. (See teaching tip at right).

Remarks

  • Today we will again use the Internet Simulator to explore some challenges of sending numbers on the Internet.
  • The tool has changed from the last time you saw it! Let's find out what's different.

Demonstrate/Remind students how to connect to a partner in the widget but explain nothing else.

Give students the following 5-minute discovery challenge:

  • "Your job is to explore this tool with a partner - click all the buttons, type in the text areas what you can. You cannot break it so don't worry."
  • "What's different now? There is a bit of a mystery in what the tool does...and doesn't do. Can you figure it out?"
  • "You and your partner have 5 minutes to poke around and see what you can find."

After 5 minutes bring the group back together and poll the group to see what they found.

Clarify any misconceptions about the tool at this point and then move on with the challenge.

  • The major change is in how you send and receive messages:
    • You no longer have to coordinate setting and reading the wire with your partner.
    • Now the simulator is a two-way street, and everything you send will be recieved by your partner automatically.
    • You send a full sequence of symbols all at once, rather than one symbol at a time.
  • Now the binary sends 0’s and 1’s instead of A’s and B’s,
  • It is possible to see the decimal interpretation of the binary

Teaching Tip

It is your choice whether to show the video here or not. Students may also watch it on their own once the activity is started if you prefer that approach.

Video: New Version of the Internet Simulator

If it would be helpful, show the video: Internet Simulator - Part 2 - Video which explains and shows how the new version of the Internet simulator works.

Develop a Number Sending Protocol.

Distribute:

Teaching Tips

While students are creating their protocol, encourage by asking:

  • What order will the points be sent in?
  • How does the recipient know when one number ends and the next begins?

Keep the focus on what’s required of a protocol. How many bits do you need to represent the numbers you need to represent the drawing, or coordinates? You want to be efficient but also support different kinds (sizes) of images.

To test protocols, direct groups to trade protocols and see if they can send an image using the alternate protocol. Students should give advice to each other to make suggestions for improvement.

Challenge: (from the activity guide)

Groups must develop a protocol or set of rules for communicating a drawing to their partners using only bits.

Line drawing

Challenge Rules: (from the activity guide)

  • The image will be a line drawing created by connecting points on a grid, like the one seen here.
  • The parties can discuss and agree on a protocol ahead of time, but the image exchange must happen without communication between the two parties, other than through using the Internet Simulator.
  • You can only send a single message through the Internet Simulator to describe the whole image.

During the Acitivity

  • Give students time to develop their protocols and practice encoding and decoding their images into bits.
  • Students should be encouraged to make a simple drawing. A geometric shape, or the first letter of their name is a good option. A shape that can be drawn with about 3-5 points is a good goal. (The 5-pointed star example is a good one, and is shown in the activity guide)
  • Students have been provided three different-sized graphs, on which they could scale their initial drawing to be different sizes or draw different images. Either way, it may necessitate the creation of different protocols.

Test It Out:

Students should test their protocols with one another under the conditions defined on the sheet. Let them know that there will be a more formal testing of their protocols at the conclusion of the lesson, in which you will provide the image that needs to be transmitted. Are they absolutely sure they’ve accounted for every possible scenario? Does everyone feel comfortable encoding and decoding a message?

Wrap-up (10 mins)

Does it work?

Give students an image as a "test" of their protocol.

  • Make simple line drawings on graph paper for students to send to each other.
  • Give the drawing to one partner and ask him/her to use the protocol to communicate it to the other partner.
  • The other partner must draw what she receives on a blank grid.
  • Compare the results to see if it came out right.
    • If it didn’t, have students write a sentence or two about what went wrong, if the problem was preventable, and whether they need to change their protocol.
  • Use the rubric to assess.

Assessment

Rubric: You may assess the outcome of the challenge run at the conclusion of the activity. Assessment questions appear both on the rubric and in Code Studio.

Additional Questions:

  • Develop a protocol that allows the user to send a calendar date (mm/dd). What is the minimum number of bits necessary?
    • Answer: The minimum number is 9 bits.
  • Develop a protocol that allows the user to send a time (use 24hr military time hh:mm:ss). What is the minimum number of bits necessary?
    • Answer: The minimum number is 17 bits.

Extended Learning

  • Develop a protocol designed for a graph that is not square, e.g. 50 * 200. How does this alter the format of your protocol?
  • Develop a protocol that can communicate locations on the surface of the earth. Longitude and latitude might be helpful tools to use.
  • The “Scalable Vector Graphics” (SVG) image file format represents images as a text-based protocol. It can be used with HTML or as a standalone file. Check it out on W3Schools or Wikipedia.
View on Code Studio

Sending Numbers Activity

Challenge: Develop a protocol or set of rules for communicating a drawing to your partners using only bits.

Challenge Rules: The image will be a line drawing created by connecting points on a grid, like the one seen here. You can discuss and agree on a protocol ahead of time, but the image exchange must happen without communication between the two parties other than through using the Internet Simulator.

Things to Consider: - How will your points be formatted? - How does the recipient know when one number ends and the next begins?

Your Protocol: Write the steps of your protocol on the worksheet provided by your teacher.

  • Check Your Understanding
  • 3
  • 4
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Complete the Sending Numbers Rubric (on the second page of the Sending Numbers activity guide) and then respond to the following prompt.

What problems arose in your efforts to create a working protocol? How did you think about the problem(s) in order to solve it?

View on Code Studio

Teaching Tip

14 bits because you need 7 bits each for the x and y coordinates. 7 bits lets you encode 128 different numbers (0-127) so that is enough to span a 96 cell grid. 6 bits each would only let you encode 64 different numbers.

Student Instructions

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2011)

CT - Computational Thinking
  • CT.L2:14 - Examine connections between elements of mathematics and computer science including binary numbers, logic, sets and functions.
  • CT.L2:7 - Represent data in a variety of ways including text, sounds, pictures and numbers.
  • CT.L2:8 - Use visual representations of problem states, structures and data (e.g., graphs, charts, network diagrams, flowcharts).
  • CT.L2:9 - Interact with content-specific models and simulations (e.g., ecosystems, epidemics, molecular dynamics) to support learning and research.

Computer Science Principles

2.1 - A variety of abstractions built upon binary sequences can be used to represent all digital data.
2.1.1 - Describe the variety of abstractions used to represent data. [P3]
  • 2.1.1A - Digital data is represented by abstractions at different levels.
  • 2.1.1B - At the lowest level, all digital data are represented by bits.
  • 2.1.1C - At a higher level, bits are grouped to represent abstractions, including but not limited to numbers, characters, and color.
  • 2.1.1D - Number bases, including binary, decimal, and hexadecimal, are used to represent and investigate digital data.
  • 2.1.1E - At one of the lowest levels of abstraction, digital data is represented in binary (base 2) using only combinations of the digits zero and one.
  • 2.1.1G - Numbers can be converted from any base to any other base.
2.1.2 - Explain how binary sequences are used to represent digital data. [P5]
  • 2.1.2A - A finite representation is used to model the infinite mathematical concept of a number.
  • 2.1.2B - In many programming languages, the fixed number of bits used to represent characters or integers limits the range of integer values and mathematical operations; this limitation can result in overflow or other errors.
  • 2.1.2C - In many programming languages, the fixed number of bits used to represent real numbers (as floating point numbers) limits the range of floating point values and mathematical operations; this limitation can result in round
  • 2.1.2D - The interpretation of a binary sequence depends on how it is used.
  • 2.1.2E - A sequence of bits may represent instructions or data.
  • 2.1.2F - A sequence of bits may represent different types of data in different contexts.
2.3 - Models and simulations use abstraction to generate new understanding and knowledge.
2.3.1 - Use models and simulations to represent phenomena. [P3]
  • 2.3.1A - Models and simulations are simplified representations of more complex objects or phenomena.
  • 2.3.1B - Models may use different abstractions or levels of abstraction depending on the objects or phenomena being posed.
  • 2.3.1C - Models often omit unnecessary features of the objects or phenomena that are being modeled.
  • 2.3.1D - Simulations mimic real world events without the cost or danger of building and testing the phenomena in the real world.
2.3.2 - Use models and simulations to formulate, refine, and test hypotheses. [P3]
  • 2.3.2A - Models and simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.
  • 2.3.2B - Hypotheses are formulated to explain the objects or phenomena being modeled.
  • 2.3.2C - Hypotheses are refined by examining the insights that models and simulations provide into the objects or phenomena.
  • 2.3.2D - The results of simulations may generate new knowledge and new hypotheses related to the phenomena being modeled.
  • 2.3.2E - Simulations allow hypotheses to be tested without the constraints of the real world.
3.1 - People use computer programs to process information to gain insight and knowledge.
3.1.3 - Explain the insight and knowledge gained from digitally processed data by using appropriate visualizations, notations, and precise language. [P5]
  • 3.1.3A - Visualization tools and software can communicate information about data.
  • 3.1.3B - Tables, diagrams, and textual displays can be used in communicating insight and knowledge gained from data.
  • 3.1.3D - Transforming information can be effective in communicating knowledge gained from data.
  • 3.1.3E - Interactivity with data is an aspect of communicating.
6.2 - Characteristics of the Internet influence the systems built on it.
6.2.2 - Explain how the characteristics of the Internet influence the systems built on it. [P4]
  • 6.2.2D - Interfaces and protocols enable widespread use of the Internet.
  • 6.2.2G - Standards for packets and routing include transmission control protocol/Internet protocol (TCP/IP).
  • 6.2.2H - Standards for sharing information and communicating between browsers and servers on the Web include HTTP and secure sockets layer/transport layer security (SSL/TLS).

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 3A-AP-21 - Evaluate and refine computational artifacts to make them more usable and accessible.
DA - Data & Analysis
  • 3A-DA-09 - Translate between different bit representations of real-world phenomena, such as characters, numbers, and images.
NI - Networks & the Internet
  • 2-NI-04 - Model the role of protocols in transmitting data across networks and the Internet.