What happens when you press "Go" in your browser?
Web 200:Anatomy of a Request@johndbritton
View Slide
How does this...
[enter]
...become this...
...on the internet?
Internet, how does it work?
• Driving a car • Shipping containersIt’s all about abstraction
Major players• HTTP • URI • Browser • Web server • DNS • Operating system • Interface • Network • Router !!• ... among others
OSI Model• 7 Layers • We won’t covereverything • Really boring • Required if you wantsome bogus certificates • Actually a useful concept
HTTPThe language browsers speak
Client server model• Web page is a document • User inputs http://example.com • The client (browser) makes a GETrequest • The server sends a response • The browser renders the page
URI• http://github.com/johndbritton • http - protocol • github.com - domain • /johndbritton - resource
RequestGET /johndbritton
Response ...
More RequestsGET /style.css GET /jquery.js GET /image.jpg GET /image2.jpg ...
More Responses(you get the idea)
Rendering• HTML - Structure • CSS - Style • Javascript - Behavior
Telnet, Inspector, JSFiddleLet’s try them out
Browser - ONLY HTTPDoesn’t care about anything else
HTTP: methods / verbs• GET • POST • PUT • DELETE • more: HEAD, PATCH, TRACE, OPTIONS,CONNECT
HTTP: responses• 1xx - informational • 2xx - success • 3xx - redirect • 4xx - error • 5xx - server error
The webserverIt speaks HTTP too
Two types of webapp• Static • Receive a request • Find a file on disk • Respond withcontents of the file• Dynamic • Receive a request • Run application logic • Return a dynamicallygenerated response
DNS: name resolutionWhere do requests go?
github.com207.97.227.239
Lookups are cachedfor improved performance
Possible cache hits• Local machine • Home router • ISP • Upstream provider
No cache - worst case• 13 Root nameservers • TLD nameserver • Authoritative nameserver • A record • IP address
dig github.com; <<>> DiG 9.8.3-P1 <<>> github.com ... github.com. 2 IN A 207.97.227.239
Making a connection• Resolve name • Open a connection • Speak HTTP
Networkcollection of nodes that can communicate directly
Interfaceconnection from node to communication medium
IP address0.0.0.0 - 255.255.255.255
Why 255?• 0 - 255 • binary, 8 bits • 00000000 - 11111111 • 00000000.00000000.00000000.00000000 • 11111111.11111111.11111111.11111111
Network addresses• a.b.c.d/n (n = network mask / subnet) • Private (non routable) networks • 10.0.0.0/8 • 172.16.0.0/12 • 192.168.0.0/16
Special addresses• 192.268.1.0/24 - network with subnet • 192.168.1.0 - network address • 192.168.1.255 - broadcast address
Network settings• Auto-configured via DHCP • IP: 192.168.1.101 • Subnet Mask: 255.255.255.0 (/24) • Router: 192.168.1.1 • DNS Servers: 192.168.1.1
Network hardware• Hub - Dumb • Switch - Smarter • Router - Smartest
Network protocols• Transport - chunks ofdata • TCP • UDP• Routing - • RIP • OSPF
Transport• OS segments data, packages it up intopackets • TCP • Reliable - resend on transmission failure • UDP • Unreliable - send once
Routing• Routers connect networks, handle packetsand don’t care what’s inside • RIP • Distance vector (hop count) • OSPF • Open shortest path first (link weight)
whatismyipaddress.com166.137.88.161github.com207.97.227.239
NATNetwork address translation
ifconfig192.168.1.101whatismyipaddress.com166.137.88.161github.com207.97.227.239
traceroute, nmap,wiresharkif we have time