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.- describe how the DNS works and helps users connect to web servers on the Internet
- 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.
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
- 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.
- 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.
- 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).
- 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.
- 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.
- Repeat the previous step to purchase at least two more items.
- 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.
- 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.
- 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.
- 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.
- 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
- 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 Received | Message received |
---|---|---|
1 | 1 | Hello |
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
- 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?
- (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.
- (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 |
- is a string of bits that provides a computer's Internet address.
- is used to route data through the Internet
- consists of 32 bits
- consists of 64 bits
- This is challenging, but rewarding! IPv4 addresses consist of 32 bits.
Q-1: An IPv4 address ____________________. Choose all that apply.
- IPv4 is being replaced by IPv6 which can address many more devices.
- Soon new devices will not be able to connected to the internet as addresses run out.
- The internet will be divided into 64 separate networks each assigned a color and internet addresses will be similar to GREEN-11.22.33.44
Q-2: IPv4 was designed to be scalable and change in size and scale to meet new demands. But IPv4 is limited to about 4 billion unique IP addresses. What is planned to fix this as the number of devices on the internet grows beyond this.
- creates IP addresses for clients and servers
- If it were easy, you wouldn’t be learning anything! The DNS is a lookup service. It doesn't create IP addresses.
- divides the Internet up into distinct and separate networks
- If it were easy, you wouldn’t be learning anything! The DNS is a service that pairs domain names (www.trincoll.edu) with IP addresses (157.252.176.180).
- is managed by a centralized server that knows all of the Internet's domain names
- If it were easy, you wouldn’t be learning anything! The DNS is a de-centralized system. DNS servers are distributed around the Internet and they work together to resolve domain names (www.trincoll.edu) into IP addresses (157.252.176.180).
- translates easy-to-remember domain names into IP addresses
- That's right! When we type www.google.com into the address bar, the DNS translates www.google.com into Google's IP address (64.233.160.0) for us. It's much easier for us to remember www.google.com than for us to remember Google's IP address (64.233.160.0)!
Q-3: The Domain Name System __________________.
- The Domain Name Servers (DNS)
- The DNS provides look-ups for IP Addresses but does NOT assign them.
- The Network Service Provider
- The Browser
- The User
Q-4: Which of the following entities is responsible for creating and assigning IP addresses as new users join a network?
Sample AP CSP Exam Question
- about.example.com
- example.co.uk
- example.com.org
- example.org
Q-5: According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?
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.