Networking for Web Development

Dr. Greg Bernstein

September 29th, 2019

Networking Introduction


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


The N2 Problem 1

We have N computers that wish to communicate:

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

The N2 Problem 2

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

Solution: Share Channels!

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

Widely Used

The concepts behind packet switching are widely applicable:

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

Packet Switching

  • 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

A container “switch”, and container “link”

Ethernet Packet

From IEEE 802.3 Standard:

Ethernet Packet

  • 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 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)

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

Diagram from the Internet

IPv4 Packet

  • 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–, 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)

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

TCP Packet Header

Transport Control Protocol (TCP) packet header

Some Well Known TCP Ports

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

Some Well Known TCP 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!