6.4. IP Addresses and Domain Names

Time Estimate: 45 minutes

6.4.1. Introduction and Goals

IP Addresses and Domain Names

In this lesson, you will learn about IP addresses and domain names. We will use a networking simulation app to explore how the Domain Name System (DNS) is used to look up the IP addresses of domain names such as google.com.

Learning Objectives: I will learn to
  • describe how the DNS works and helps users connect to web servers on the Internet
Language Objectives: I will be able to
  • use target vocabulary, such as IP Address, domain name, and DNS while describing how networks connect, with the support of concept definitions and vocabulary notes from this lesson

6.4.2. Learning Activities


Before moving on to the activity below, try finding your IP address by googling "what's my IP address". Try to find another IP address for a domain name that you know, for example google.com at a site like WhoIs Lookup.

Networking Simulation Activities

In this lesson, we will use a DNS simulator app to explore how we communicate on the Internet with IP addresses. Watch the video below about using the Mobile CSP's DNS app.


(Teacher Tube version)

Now that you understand how the app works, you will need to download the widget on to your tablet or Android phone. You can install the Android .apk file for the widget by scanning the QR code below with the AI Companion app or by clicking on this link https://mobile-csp.org/DNSwidgetV13.apk in your Android device's browser. If you are using the emulator or iOS, download this .aia file and import into App Inventor and then connect.

APK file for DNS Widget

Troubleshooting:

  • Do not connect using the default Class Code 0. This might result in an error about the second argument of the for each list not being a list. You should get a 6 digit Class Code from your teacher and type it in. Your teacher should click on the NEW CLASS CODE button to get this code and give it to the whole class. Everyone in the class should use the same Class Code. Type in your name's first 3 or 4 letters in the Login Id before clicking on Login.
  • If you are getting a TimeOut Exception error, CloudDB (which this app uses) might be down or too busy. You can use an older version of the app, v12, which uses TinyWebDB instead by typing this url on your device and installing it: https://mobile-csp.org/DNSwidgetV12.apk. Or importing the following aia into App Inventor and building it: v12 aia file. The TinyWebDB server might also have traffic congestion problems. You can also try a different TinyWebDB server - the default URL in v12 is http://westhilltinywebdb.appspot.com and you can replace it with http://tinywebdb.appinventor.mit.edu to try a different TinyWebDB server.

Next, get together with two of your friends in class and do the following activities. (If you are working alone, you may have to skip some of the exercises listed but can still do a majority of the tasks described here.)

Activity 1 : Using the DNS to Retrieve and Use IP Addresses

  1. After your teacher has assigned you a class code, type that code into the class code textbox on your login screen. Your teacher will receive this code by clicking on the NEW CLASS CODE button on their own app. Only the teacher should click this button. The students in the class should all enter the same code.
  2. If you are working on this exercise alone, you should press the "Assign BOT" button a dozen times before you log in to set up about a dozen or so robot users (BOTS) so you can practice looking up their IP addresses. If you are working on this exercise as part of a class, you do not need to create any BOTS.
  3. Choose a short login name for yourself, enter it in the login box, and press the LOGIN button. An example of a good login would be three or four letters such as jim or mimi. Note that the system will append a number to your name when creating your login ID, to reduce the likelihood of you having the same login as someone else in the class. (Remember that your teacher will be checking your work at the end of this exercise, so do not use anything inappropriate for your login credentials).
  4. Once the app confirms that you have successfully logged into the system, send a message to the DNS asking it for the IP address for Amazon in this simulation. To do this, enter the IP Address of the DNS seen at the top into the "To:" field. In the message field, enter "get amazon". Then press the SEND button. NOTE: When you type commands or login IDs into the Mobile CSP DNS widget, it does not matter if you use upper or lower case characters.
  5. Using the IP Address you have discovered for Amazon, send Amazon a message to buy something. In the "TO" field of the message you will need to enter Amazon's IP Address. In the message body, you will need to enter "buy X" where X is the item you wish to purchase. Then press the "SEND" button.
  6. Repeat the previous step to purchase at least two more items.
  7. Once you have purchased three or more items, it is now time for you to contact one of your friends to brag about your recent purchases. APK file for DNS Widget
    • Locate someone on the same router as you.
    • In the network diagram shown, the user (jill30) resides on Router #7, along with another user, usha66, whose IP Address is not known to jill30.
    • These two users are not the only ones on this network. Pressing the PEERs button will reveal all the login IDs on this network.
    • If there is no other user on your router on the network diagram on your tablet's screen, you may have to skip this part of the exercise.
    • Notice that your friend's IP address is initially hidden from you (marked with a "?". Ask the DNS what the IP address is of the person on your router you wish to contact.
    • After receiving the answer, notice that the IP address is now visible to you on your tablet's screen.
    • Using this newly discovered address, send a message to this person, letting them know what items you bought from Amazon. Ask the person to send you a reply. NOTE: If the DNS responds with "Invalid Address" to your request, it is likely that you have mistyped your friend's login ID.
  8. Of course, on the Internet, we can communicate with anyone connected to the network, not just those on our router. Now click the "PEERS" button on your screen. It will bring up a LISTPICKER which will display the login IDs of everyone in your class who is also on your network. Locate one of your friends in class who is on the network but not on your router in this list and select this person. Note that the app has filled in the message fields with the DNS address in the "TO" field and an appropriate "get" request in the message field. Simply press the "SEND" button to ask the DNS to fetch the address of your friend.
  9. Once you have your friend's address, converse with them back and forth with a few messages describing your recent purchases. Remember that all your messages are being logged and will be reviewed by your instructor at the end of this exercise.
  10. After you have finished these exercises, raise your hand to show your instructor your message log. Once your teacher signs off on your activity, take a screenshot of your message log to submit in your portfolio.

Activity 2 - The Lost Messages Problem

In this POGIL activity, you will work in groups of three to test what happens when two people send simultaneous messages to a recipient using the Mobile CSP DNS Simulator app. Here are the roles.
  • Recipient. The recipient will lead this activity and will receive messages from the other group members and record the results
  • Sender #1. Sender #1 will send one of the messages to the recipient
  • Sender #2. Sender #2 will send one of the messages to the recipient

Activity

Repeat the following activity three or more times. Have the two senders enter the IP address of the recipient and a unique message -- so that the recipient will be able to easily distinguish the two messages. Now, by coordinating verbally, have both senders press the app’s SEND button at the same time. For each trial, record the following results.

Trial #Number of Messages ReceivedMessage received
11Hello

What you should observe

If you repeat this experiment enough times, you should observe that some messages are being lost -- that is, they are not being received by the recipient. Is that what you observed?

What explains this behavior

According to its current design, the app is using a simple TinyWebDB mailbox variable to store the recipient’s messages. Initially, this variable is given the value EMPTY_MAIL_BOX to signify that there are no messages waiting for that recipient. When the recipient receives a message, it is put into the recipient’s mailbox. A typical message might be sender1:7.13:hello. This means that the message “hello” was sent by “sender1” at IP address “7.13”. When the recipient retrieves the message from mailbox, it replaces it with EMPTY_MAIL_BOX to signify that the mailbox is empty again. In pseudocode, this is how this algorithm works.

Recipient
    mailbox ← EMPTY_MAIL_BOX
    Repeat every 3 seconds
    {
       IF (mailbox is not EMPTY_MAIL_BOX)
       {
             Retrieve the message
             mailbox ← EMPTY_MAIL_BOX
       }
    }       
Sender1
recipient’s mailbox ← "sender1:7.13:hello"

If the recipient only checks the mailbox every 3 seconds, what happens if 2 messages are sent in between the checks? If the message is stored in a single variable, the mailbox, what happens to the first value in a variable if it's reassigned a second value, for example:

mailbox ← x
mailbox ← y

Discussion Questions

  1. Lost Messages. Explain why and how this design could lead to messages being lost when Sender1 and Sender2 send their messages at the same time. Can you devise a sequence of events that shows that the recipient receives the message from Sender2 but not Sender1?
  2. (Portfolio) Simple variable vs. a list variable. The current design uses a simple variable to store a string, either a message “sender1:7.13:hello” or “EMPTY_MAIL_BOX”. Discuss why and how a list variable would be a better choice for storing the recipient’s messages.
  3. (Portfolio) List handling algorithm. Using the following commands to insert and remove messages (msg) into a list mailbox, design pseudocode algorithms for the sender and receiver. Choose one insert and one remove command from the list below and put them in the pseudocode below.
    • Insert_at_end_of_list(msg)
    • Insert_at_front_of_list(msg)
    • Remove_msg_at_end_of_list
    • Remove_msg_at_front_of_list
    Recipient
        mailbox ← empty list
        Repeat every 3 seconds
        {
           Repeat until mailbox is empty list
           {
                  Remove_________________
           }
        }
    Sender1
    recipient's mailbox ← Insert___________________( "sender1:7.13:hello")

    Discuss your group’s algorithm in a class discussion until consensus is reached on an appropriate algorithm for this problem. Can you defend your solution to this problem by giving an non-computer analogy of a how a similar, related problem would be handled by your solution?

6.4.3. Summary

In this lesson, you learned how to:

6.4.4. Self-Check

Here is a table of some of the technical terms discussed in this lesson. Hover over the terms to review the definitions.

host
router
IP address
IPv4
IPv6
Scalability
domain name
DNS

Sample AP CSP Exam Question


6.4.5. Reflection: For Your Portfolio

Answer the following portfolio reflection questions as directed by your instructor. Questions are also available in this Google Doc where you may use File/Make a Copy to make your own editable copy.

You have attempted of activities on this page