The internet, DNS and the cloud

The internet and the web, DNS, web servers and hosting, and the cloud.

F10.6NetworksGCSE20 min

Covers OCR J277 1.3.1 Networks and topologies · Edexcel 1CP2 4.1.3 How the internet is structured

Do this lesson in the simulator

The internet is a worldwide network of networks, joined by routers. The World Wide Web is one service that runs on it: web pages, linked together and fetched with a browser. Email, video calls, online games and the BugBot lessons all use the internet too. This lesson follows what happens when you type a web address, and looks at hosting and the cloud.

The internet drawn as networks joined by routers, with four services on top of it: the World Wide Web, email, video calls and online gamesservices thatrun on itWorld Wide Webemailvideo callsonline gamesthe internetthe network:hardwarenetworknetworknetworkcircles: routers
The internet is the hardware: networks all over the world, joined by routers. The web is one of the services that use it, alongside email, calls and games, so the two words do not mean the same thing.

DNS: names to addresses

Routers deliver packets using IP addresses, but people remember names like www.bugbotlab.com. The Domain Name System (DNS) turns names into IP addresses:

  1. You type a web address, a URL, into the browser.
  2. The browser asks a DNS server for the IP address of that domain name.
  3. The DNS server looks the name up. If it does not know it, it asks other DNS servers.
  4. It sends the IP address back to the browser.
  5. The browser sends its request to the web server at that IP address.

Without DNS, you would need to remember a number for every website.

The browser asks a DNS server for the IP address of www.bugbotlab.com; the DNS server asks another DNS server, sends the address back, and the browser then requests the page from the web server at that addressbrowserDNS serveranotherDNS serverwebserver1you type www.bugbotlab.com2of www.bugbotlab.com?what is the IP address3looks it up; if it doesnot know, it asksdo you know it?its IP address4the IP address5request the page, sent to that IP addressthe web page
The numbers match the five steps above. The dashed part only happens when the first DNS server does not already know the name. Only after the lookup does the browser contact the web server itself.

Web servers and clients

A web server stores websites and sends pages to clients when they ask. A web browser is the client: it requests pages, receives them, and displays them. This is client-server, from lesson F10.1.

Hosting means storing a website on a server that is always connected to the internet, usually rented from a hosting company, so anyone can reach it at any time.

The cloud

The cloud means using remote servers over the internet to store files, run software, or do processing, instead of your own computer. The lesson you are reading comes from the cloud, and so does your saved work.

Advantages Disadvantages
reach files and software from any device, anywhere needs an internet connection
no need to buy and look after your own servers ongoing cost, often a subscription
storage and processing can grow as needed data is held by another company, maybe in another country
the provider handles backups and security updates if the provider has an outage, you cannot work

A DNS server on the mat

The robots on this mat have addresses, and a DNS robot knows them. Ask it for the address of scout.bot:

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

send("lookup scout.bot")
for tick in range(10):
    wait(0.1)
    for sender, text in messages():
        print(sender, "says:", text)

Run this in the simulator

Messages on the mat are addressed as to <address>: <message>. Only the robot with that address answers.

Task: look it up

Two robots are on the mat: scout.bot and rover.bot. Look up scout.bot with the DNS robot, then take the IP address from its reply. Send to <address>: where and the Scout answers at <x>,<y>. Drive to about 13 cm in front of it, into the green square, without touching anything. The helpers ask, numbers_in, go_to and near are ready to use.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
import math

def ask(question, seconds=1.0):
    # send a question and return the first reply that arrives within `seconds`, or None
    send(question)
    for tick in range(int(seconds * 10)):
        wait(0.1)
        for sender, text in messages():
            return text
    return None

def numbers_in(text):
    # every number in a message, as floats: "at 25,55" -> [25.0, 55.0]
    out = []
    for word in text.replace(",", " ").split():
        try:
            out.append(float(word))
        except ValueError:
            pass
    return out

def wrapped(h):
    return (h + 180) % 360 - 180

def go_to(x, y, speed=60):
    # one step of driving towards (x, y), measured from the start; call it in a loop
    px, py = position()
    a = math.radians(wrapped(math.degrees(math.atan2(x - px, y - py)) - heading()))
    drive(speed * math.cos(a), speed * math.sin(a), wrapped(0 - heading()) * 3)

def near(x, y, cm=4):
    px, py = position()
    return math.hypot(x - px, y - py) < cm

Challenges

  1. Keep a DNS cache: a dictionary of names you have already looked up, so you only ask once.
  2. Look up rover.bot too, and print both robots' positions.
  3. Why does a DNS server ask other DNS servers rather than knowing every name itself?