Networking for Web Development

Dr. Greg Bernstein

February 25th, 2020

Networking Introduction

Why

You need to understand networking for:

Front End Development

Back End Development

Front and Back End Development

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

Multiplexing

Fiber Optic Cable

How much cable do we need to communicate?

A lot

A moderate amount

Depends on cost and capacity

That’s a question for a different course

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 Channel?

What do we need to share channels?

Encryption

Ports

Addresses

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

Packet Switching

Circuit Switching

It depends what you mean by Packet Switching

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

  • 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

Are you currently using Ethernet

Right now

At Home

I never touch the stuff

How Should I know

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)

Cell Phones and IP

Does your cell phone use IP?

Only when I’m talking

Only when I’m surfing the web

Depends on the app

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

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

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

Ports Question

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

Always, can’t tell packets apart otherwise

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

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

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?

Don’t, images are not necessary

Just send as much as will fit in the MTU

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

Only use text

How can you deal with lost packets?

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

Not worry about it

Send every piece twice to make sure it gets there

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

Errors don’t occur in packet networks

TCP Packet Header

Transport Control Protocol (TCP) packet header

Some Well Known TCP Ports

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

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!