Networking for Web Development

Dr. Greg Bernstein

Updated March 18th, 2021

Networking Introduction

Why Networking

You need to understand networking for?

  1. Front End Development

  2. Back End Development

  3. Front and Back End Development

  4. Only as a specialist

Motivation

To create and run webservers we need to know about:

  • Multiplexing and Switching concepts (including ports)
  • Network Addresses (IP and Ethernet)
  • Basic network protocol functions
  • Names versus addresses and URLs (separate slides)

We Will Use HTTP(S)

Need a bit of understanding of what it is built on and why

Network Layers

Multiplexing

Fiber Optic Cable

How much cable do we need to communicate?

  1. A lot

  2. A moderate amount

  3. Depends on cost and capacity

  4. That’s a question for a different course

The N2 Problem 1

We have N computers that wish to communicate:

N squared problem

How many one directional channels do we need for them to communicate?

The N2 Problem 2

We need N(N-1) one directional channels!

N squared problem with links

Solution: Share Channels!

Sharing

How to Share Channels?

What do we need to share channels?

  1. Encryption

  2. Ports

  3. Addresses

  4. A way to identify different blocks of info

How to Share?

  • Need a way to identify which information is intended for which recipient?

  • Many methods exist: time division multiplexing, wavelength division multiplexing, etc.

  • We will only be concerned with packet switching

Packet Switching

Older Technology?

Which is older packet switching, e.g., internet, or circuit switching (old telephone network)?

  1. Packet Switching

  2. Circuit Switching

  3. It depends what you mean by Packet Switching

  4. How Should I know

Widely Used

The concepts behind packet switching are widely applicable:

  • Classical “snail” mail
  • Overnight delivery services
  • Package delivery services
  • Container shipping

Packet Switching 1

  • Every packet is a distinct unit of information, physical box, letter, package
  • Every packet is associated with a destination and return address or identifier
  • Additional information maybe associated with the packet to help it get to where it is going or to achieve some service functionality.

Packet Switching 2

A container “switch”, and container “link”

Ethernet

Are you currently using Ethernet?

  1. Right now

  2. At Home

  3. I never touch the stuff

  4. How Should I know

Ethernet Packet 1

From IEEE 802.3 Standard: Frame

Ethernet Packet 2

  • Destination and Source addresses
  • Client data
  • Length/Type
  • Misc. overhead: preamble, SFD, PAD, FCS

What Happens on Reception?

  • The receiving computer checks that the destination address matches their Ethernet (MAC) address and checks to see if the packet has errors
  • Gives the packet (without preamble and padding stuff) to the next layer of protocol processing as indicated by the Type field.
  • This is multiplexing within the same Ethernet destination.

Ethernet Addresses 1

  • Unique address given to every ethernet end system. Known as MAC addresses. These are allocated in blocks to device manufacturers by the IEEE.

  • These are more like unique identifiers than what we might think of as “addresses”.

Ethernet Addresses 2

From Wikipedia MAC addresses:

Example Ethernet Network

Multiple switch wired Ethernet network:

Ethernet Net

Ethernet Switching

  • Ethernet Switches construct a table to tell them on which port to send a packet with a given destination address.

  • Every destination on the Ethernet network needs a table entry and there is no way to summarize the information since Ethernet addresses are given out based on manufacturers and not “network location”.

  • Ethernet by itself cannot scale to create a world wide Internet ==> this is why we have the Internet Protocol (IP)

Network Layer (IP)

Cell Phones and IP

Does your cell phone use IP?

  1. Only when I’m talking

  2. Only when I’m surfing the web

  3. Depends on the app

  4. How should I know

The Internet Protocol

  • There are two flavors of the Internet Protocol: IPv4 and IPv6

  • IPv6 is the newer version, however IPv4 is still widely used and simpler to understand at first.

  • We will only talk about and use IPv4 in this class.

IPv4 Packet 1

Diagram from the Internet

IPv4 packet

IPv4 Packet 2

  • Destination and Source addresses
  • Protocol, Total Length
  • Misc.: Version, Header Length, TOS, ID, Flags, Frag, TTL, HCS, Options, Pad

Who is the packet for?

  • The Destination Address

  • But Who at the destination? This is what the protocol field in the header is for.

Standard Protocols supported by IP

  • Large list at Wikipedia: IP Protocol Numbers

  • Transmission Control Protocol (TCP) Hex 0x06, Decimal 6

  • User Datagram Protocol (UDP) Hex 0x11, Decimal 17

IP Addresses

Differences with Ethernet Addresses

  • Your computers Ethernet adapter comes with a manufacturer assigned Ethernet address

  • Your computer does not come with an IP address for networking purposes, but is given one by the network.

  • There are different types of IP addresses for different contexts.

IPv4 Address Types

See Wikipedia: IPv4

  • Public IP Addresses: Your ISP would give one to your entire house or apartment.

  • Private IP Addresses: You get one of these from your home router or from the campus network.

  • Loopback (Machine Local) Addresses: Used within a machine, the range of addresses you can use is 127.0.0.0–127.255.255.255, i.e., over 16 million addresses. We will use these during webserver development.

The IP Allocation Method

  • Unique addresses assigned in a hierarchical manner starting with IANA, then allocated to regional authorities, down to ISPs.

  • Hierarchical, location based allocation of addresses allows for “summary routing”, that is routing based on only part of the IP address.

  • This drastically reduces the size of the forwarding table in IP based packet switches (known as “routers”, but this term is over used.)

IP Address Authorities

Figure from IANA (Internet Assign Number Authority)

IANA

They Know Where You Are!

  • One can infer approximate location from a public IP address.
  • I use the open source GeoLite2 database to find out where the visitors to my website have come from.
  • If you need anonymity use Tor

Transport Layer

Transport Layer Functionality

The transport layer provides extra functionality over the network layer

  • TCP and UDP both provide multiplexing via source and destination port numbers. This allows multiple “conversations” between the same pair of IP addresses.

  • TCP also provides for reliable delivery of byte streams. This greatly increases its complexity over UDP.

UDP Packet Header

User Datagram Protocol (UDP) packet header

UDP

Ports Question

Under which situation must we use both source and destination UDP/TCP ports?

  1. Always, can’t tell packets apart otherwise

  2. When two different computers talk to a process on a computer listening on a specific destination port

  3. When two different processes on the same computer need to talk to a process on another computer listening on a specific destination port

  4. Never, ports are over rated

Limits on Packet Size

  • Physical layer properties put limits on the size of packets
  • This limit is called the Maximum Transmission Unit
  • Some MTUs in bytes: Ethernet ~ 1500, WiFi ~ 2304, Ethernet Jumbo ~ 9216

How can you send an image?

Image sizes can be much greater than the MTU. How can you send it?

  1. Don’t, images are not necessary

  2. Just send as much as will fit in the MTU

  3. Break it into smaller pieces for transmission and reassemble at the other side

  4. Only use text

How can you deal with lost packets?

If you chose to break your image into smaller pieces, how should you handle a “lost” piece?

  1. Not worry about it

  2. Send every piece twice to make sure it gets there

  3. Give each piece a number and have the receiver acknowledge that it got the piece

  4. Errors never occur in packet networks since they are digital

TCP Packet Header

Transport Control Protocol (TCP) packet header

TCP

Some Well Known TCP Ports 1

These are where servers/services listen, i.e., destination ports

  • 80: Hypertext Transfer Protocol (HTTP)
  • 443: Hypertext Transfer Protocol over TLS/SSL (HTTPS)
  • 53 Domain Name System (DNS)

Some Well Known TCP Ports 2

These are where servers/services listen, i.e., destination ports

  • 20: File Transfer Protocol (FTP) data transfer
  • 21: File Transfer Protocol (FTP) control (command)
  • 22: Secure Shell (SSH), secure logins
  • 25: Simple Mail Transfer Protocol (SMTP)

Why should I care?

  • When we work with multiple servers on our own machine we need to make sure the ports don’t collide

  • Development servers frequently use non-standard ports

  • Other types of services such as database servers, Redis, etc… will be accessed via non-standard ports.

Domain Name System

Names versus Addresses

The Domain Name System (DNS) is used to resolve domain names into IP addresses.

From Wikipedia DNS: The Domain Name System (DNS) is a hierarchical decentralized naming system for computers, services, or other resources connected to the Internet or a private network.

Domain Registrars

Buyer Beware!

Domain Registrar Example

I can get a domain for CS3520 or any other class!

Domain Registrar
// reveal.js plugins