1 of 34

How the Internet Works

2 of 34

What happens when you type www.google.com into your browser?

3 of 34

What is the Internet, really?

A global network of billions of connected devices that communicate with each other and transfer data to one another.

4 of 34

Things to learn

How are the devices on the internet physically connected to each other?

How is information physically transmitted from device to device?

How does one device find another it’s trying to communicate with?

What methods do they use to communicate?

How can we send data reliably even when the network is unreliable?

5 of 34

Servers & Load Balancing

  • In theory, whenever a computer shares resources with client machines, it is considered a server.
  • So your computer could act as a server and respond to 1, 10, or 100 requests for files; but how would a site like Amazon or Facebook respond to 10,000 requests in the same second? The answer: load balancing on multiple servers.

Narrated by Nicolas Cage (just kidding).

6 of 34

Wires, Cables & Wifi

  • How are devices on the internet connected to each other?
  • How is information physically transmitted from device to device?

Watch the video and then go through the summary slides after, or come back to the video later.

`://www.youtube.com/watch?v=ZhEf7e4kopM

7 of 34

Wires, Cables & Wifi (Summary)

  • Internet uses binary format to communicate (1’s and 0’s).
  • A bit is a 1 or 0.
  • Bit rate = how many bits can be sent per second.
  • Latency = time it takes for a bit to travel from one place to another.
  • Bandwidth = bits/second.

8 of 34

Wires, Cables & Wifi (Summary)

Computers can be connected to each other through multiple ways.�Each way can transmit binary data (1’s and 0’s)

  • Fiber optic cables
    • Signal is sent via light through the cables
    • Light on = 1; Light off = 0
  • Copper wire
    • Signal sent via electricity
    • 5 volts = 1; 0 volts = 0
  • Radio waves
    • Wifi
    • Short distances
    • 1’s and 0’s represented as different wave patterns

9 of 34

IP Addresses & DNS

  • How does one device find another it’s trying to communicate with?

Watch the video and then go through the summary slides after, or come back to the video later.

https://www.youtube.com/watch?v=5o8CwafCxnU

10 of 34

IP Addresses & DNS (Summary)

Agreed-upon protocols.

IP Address (Internet Protocol).

  • Address of a device on the internet.

DNS (Domain Name System).

  • Associates names with IP addresses.
  • Network of DNS servers.

11 of 34

IP Addresses

  • Every device must have its own unique IP address.
    • Very much like your home address, except it’s for your computer.
  • IPv4 was the first format for noting IP addresses.
    • 32 bits in an address = 2^32 possible addresses = 4.2 billion.
    • We ran out of numbers!
    • Takes the form 123.45.0.200.
      • All sections can be a number 0-255.
  • Now, we use IPv6, which has 2^128 possible addresses = 340,282,366,920,938,463,463,374,607,431,768,211,456 possibilities!
    • That’s way more possibilities than there are grains of sand on Earth.
    • Takes the form 2001:0000:3238:DFE1:0063:0000:0000:FEFB.

12 of 34

IP Addresses (optional video)

13 of 34

localhost - a special IP address

  • In addition to a computer’s unique IP address, the computer can also reach itself at a special IP address called “localhost”.
    • 127.0.0.1.
  • Localhost always means “this computer that I’m on right now”.
    • It’s always 127.0.0.1 for every computer; it’s not unique.
  • Localhost is usually used for local development of web pages (local means “on your own computer”).
  • For example, your about page can be accessed from your local server:
    • http://127.0.0.1:3000/about.
    • http://localhost:3000/about
    • 3000 is the port - more on those later!

14 of 34

Discover your IP address

15 of 34

Packets, Routing & Reliability

  • How is information sent from one computer to another?
  • How can we send data reliably even if there are problems with computers on the network?

Watch the video and then go through the summary slides after, or come back to the video later.

https://www.youtube.com/watch?v=AYdF7b3nMto

16 of 34

Packets, Routing & Reliability (Summary)

  • Data to be sent is broken up into “packets”.
  • Packets can take different routes to the same destination.
  • Routers are computers that direct packets + choose the route to send the data.
  • Fault-tolerant -- even if some computers/wires are broken, there will be a path.
  • TCP (Transmission Control Protocol).
    • Protocol that defines format of packets and ensures that all packets are received correctly.
  • Scalable system.

17 of 34

HTTP & HTML

  • How do computers request data from one another? What is in the packets?
  • How do we send data securely?

Watch the video and then go through the summary slides after, or come back to the video later.

https://www.youtube.com/watch?v=kBXQZMmiA4s

18 of 34

HTTP & HTML (Summary)

We’ll spend more time on this one because it is most directly related to your work as web developers.

19 of 34

http vs https

  • HTTP = Hypertext Transfer Protocol.
    • Language computers use to request documents.
    • Rarely used anymore. Only used by websites that only serve information and do not collect or transmit user data.
    • http://www.myblog.com.
  • HTTPS = HTTP Secure.
    • Used by almost all production websites. Vital for websites that collect or transmit user data (banks, retail websites, etc.).
    • https://www.chase.com.
  • HTTP is being phased out in favor of putting all websites on HTTPS.

20 of 34

HTTPS

  • HTTPS is secure because it encrypts data.
  • SSL.
  • TLS.
  • Certificates.

21 of 34

Host names

  • example.com
  • google.com
  • etsy.com
  • techtonica.org
  • usa.gov

These custom domain names get converted to IP addresses whenever you make a request to visit one of these websites.

22 of 34

URL

Uniform Resource Locator.

Address of page you’re requesting.

Example URL: http://www.example.com/index.html

Consists of:

  • protocol ( http ).
  • hostname ( www.example.com ).
  • file name ( index.html ).

23 of 34

Ports

  • Every server has 65,535 unique ports that can take in requests.
  • Services tend to have a default port.
    • HTTP is on port 80.
    • HTTPS is on port 443.
    • Express is on 3000.
      • localhost:3000/about

24 of 34

Browsers, Clients and Servers

25 of 34

Browsers

  • The application you open on your computer or smartphone in order to type in a URL.

26 of 34

Clients

  • Any device or computer that is connecting to the Internet.
  • A client makes HTTP requests in order to view web pages.

27 of 34

Servers

  • Computers whose main job is to host (store) the code required to create websites.

28 of 34

Requests and Responses

29 of 34

Requests

  • Sent by the client to the server.
  • The client (your Browser) can “request” information from the server.
    • Usually, it’s requesting the HTML, CSS and JS of a webpage.
    • Can also be JSON, such as from an API call.
    • This is called a GET request, because the client is “getting” information from the server.
  • The client (your Browser) can also send information to the server that needs to be incorporated into a database or session.
    • This is called a POST request, because the new information is being “posted” or made available.
    • Used for logging in, sending HTML form data, buying things.

30 of 34

Responses

  • Sent by the server back to the client (your Browser).
    • The server sends back the requested HTML, CSS & JS if the client is requesting a web page.
    • The server sends back a JSON object if the client has made an API call.

31 of 34

Responses Include

  • A response code
    • 200 - 299: Success.
    • 300 - 399: Redirection.
    • 400 - 499: Client error (common example is 404: File not found).
    • 500 - 599: Server error.
  • Headers.
    • Any cookies server wants to set.

32 of 34

HTTP Requests & Responses

33 of 34

Summary: Layers

HTTP + DNS - Web files.

TCP/IP + Routers - Packets.

Wires, Cables, Wifi - Binary.

34 of 34

More “How the Internet Works” Resources