3/27/17
1
ComputerNetworks
ArvindKrishnamurthy
1
MaterialbasedoncoursesatStanford,Princeton,andMIT
Focusofthecourse
2
???
3/27/17
2
Focusofthecourse(2)• Three“networking”topics:
– Communications– Networking– Distributedsystems
• Ourfocusisonthe“middle”layer
3
But,WhatisNetworking?
4
3/27/17
3
APlethoraofProtocolAcronyms?
5
BGPARP
HTTP
DNS
PPP
OSPF
DHCP
TCP
UDP
SMTP
FTP
SSH
MAC
IPRIP
NAT
CIDR
VLAN VTP
NNTP
POP
IMAP
REDECN
SACK
SNMP
TFTP
TLS
WAPSIP IPX
STUN
RTP
RTSP
RTCP
PIM
IGMPICMP
MPLS
LDP
HIP
LISP
LLDP
BFD
AHeapofHeaderFormats?
6
3/27/17
4
TCP/IPHeaderFormatsinLego
7
ABigBunchofBoxes?
8
Router Switch
FirewallNAT
Loadbalancer
DHCPserver
DNSserver
Bridge
Hub
Repeater
Basestation
ProxyWANaccelerator
GatewayIntrusionDetectionSystem
Packetshaper
RouteReflector
LabelSwitchedRouter Scrubber
Packetsniffer
DeepPacket
Inspection
3/27/17
5
ATonofTools?
9
traceroutenslookup
ping
ipconfigrancid
whois
tcpdump
wiresharkNDT
iperf
dummynet
syslog
tratsnort
bro
arpwatch
mrtg
nmap
ntop
dig
wget
net-snmp
ATonofTools?
10
traceroutenslookup
ping
ipconfigrancid
whois
tcpdump
wiresharkNDT
iperf
dummynet
syslog
tratsnort
bro
arpwatch
mrtg
nmap
ntop
dig
wget
net-snmp
3/27/17
6
TheMainPoint1. TolearnhowtheInternetworks»
– Whatreallyhappenswhenyou“browsetheweb”?
– WhatareTCP/IP,DNS,HTTP,NAT,VPNs,802.11etc.anyway?
2. Tolearnthefundamentalsofcomputernetworks
11
12
WhylearnabouttheInternet?
1. Curiosity»2. Impactonourworld»
3/27/17
7
Fromthisexperimentalnetwork…
13
ARPANET~1970
(a)Dec.1969. (b)July1970. (c)March1971.
14
Tothis!
• Aneverydayinstitutionusedatwork,home,andon-the-go
• Visualizationcontainsmillionsoflinks
Attribution:ByTheOpte Project[CC-BY-2.5],viaWikimediaCommons
Internet~2005
3/27/17
8
15
Question
• Whatdoyouthinkaretheissuesthatonehastotackletogrowfromasmallnetworktoanextremelylargenetwork?
Internet– SocietalImpact• Anenablerofsocietalchange
– Easyaccesstoknowledge– Electroniccommerce– Personalrelationships– Discussionwithoutcensorship
16
3/27/17
9
Internet– Economicimpact• Anengineofeconomicgrowth
– Advertising-sponsoredsearch– “Longtail”onlinestores– Onlinemarketplaces– Crowdsourcing
17
TheMainPoint(2)1. TolearnhowtheInternetworks2. Tolearnthefundamentalsof
computernetworks– Whathardproblemsmustthey
solve?– Whatdesignstrategieshave
provenvaluable?
18
3/27/17
10
19
NotaCourseGoal
• TolearnITjobskills– Howtoconfigureequipment
• e.g.,Ciscocertifications
– Butcoursematerialisrelevant,andweusehands-ontools
CourseMechanics• Course Administration
– Everything you need to know will be on the course web page:
http://www.cs.washington.edu/csep561/
• Teaching Assistants:– Yuchen & Ming
3/27/17
11
21
CourseLogistics
1. Readings2. Weeklyreports:25%3. Projects/Homeworks:75%
• Ingroupsoftwo• Ifyouwanttoworkindividually,thenyoucanjustdo
assignments1and2(withdifferentdeadlines)• Detailsonwebsite
22
AssignmentFramework• Mininet – emulationsystemfromStanford• Allowsyoutocreatenodes,switches,linksallonasinglemachine
• Assignment1:TCPdynamics• Assignment2:Buildasimplerouter• Assignment3:BuildaNAT
3/27/17
13
25
Topics
26
Exercise
• Considerawebobjectfetch“index.html”from“nytimes.com”– Whatareallthestepsinvolvedinperformingthefetch?
3/27/17
14
27
KeyInterfaces• Between(1)appsandnetwork,and(2)networkcomponents– Moreformaltreatmentlateron
host
app
28
KeyInterfaces(2)1. Network-applicationinterfaces
definehowappsusethenetwork– Sockets arewidelyusedinpractice
host
app
3/27/17
15
29
2. Network-networkinterfacesdefinehownodesworktogether– Traceroute canpeekinthenetwork
KeyInterfaces(3)
host
app
PeekinginsidetheNetworkwithTraceroute
3/27/17
16
31
NetworkServiceAPIHidesDetails• Appstalktootherappswithnorealideaofwhatisinsidethenetwork– Thisisgood!Butyoumaybecurious…
host
appapp
host
???
32
Traceroute• Widelyusedcommand-linetooltolethostspeekinsidethenetwork– OnallOSes (tracert onWindows)– DevelopedbyVanJacobson~1987– Usesanetwork-networkinterface(IP)inwayswewillexplainlater
3/27/17
17
Traceroute (2)• Probessuccessivehopstofindnetworkpath
33
...
LocalHost
RemoteHost
Traceroute (3)
34
...
LocalHost Remote
Host
1hop 2hops3hops N-1hops
Nhops
3/27/17
18
UsingTraceroute
35
UsingTraceroute (2)• ISPnamesandplacesareeducatedguesses
36
...
Mycomputer www.uw.edu(www1.cac.washington.edu)
tde3hops
Telefonica4hops
Level36 hops
pnw-gigapop1hop
UW3 hops
NYC SanJose Seattle
UW
Home1 hop
100ms180ms
>200ms
3/27/17
19
Traceroutetoanothercommercialwebserver-bash-3.1$traceroute www.nyse.comtraceroute towww.nyse.com (209.124.184.150),30hopsmax,40bytepackets1acar-hsh-01-vlan75.cac.washington.edu(128.208.2.100)0.327ms 0.353ms 0.392ms2uwcr-hsh-01-vlan3904.cac.washington.edu(205.175.110.17)0.374ms 0.412ms 0.443ms3uwcr-hsh-01-vlan1901.cac.washington.edu(205.175.103.5)0.595ms 0.628ms 0.659ms4uwbr-ads-01-vlan1902.cac.washington.edu(205.175.103.10)0.445ms 0.472ms 0.501ms5ccar1-ads-ge-0-0-0-0.pnw-gigapop.net(209.124.176.32)0.679ms 0.747ms 0.775ms6a209.124.184.150.deploy.akamaitechnologies.com.184.124.209.in-addr.arpa(209.124.184.150)0.621ms 0.456ms 0.419ms
Whatisgoingon?
-bash-3.1$nslookup www.nyse.comName:a789.g.akamai.netAddress:209.124.184.137
TheSocketAPI(§1.3.4,6.1.2-6.1.4)
3/27/17
20
39
Network-ApplicationInterface• Defineshowappsusethenetwork
– Letsappstalktoeachotherviahosts;hidesthedetailsofthenetwork
host
appapp
host
40
MotivatingApplication• Simpleclient-serversetup
request
reply
3/27/17
21
41
MotivatingApplication(2)• Simpleclient-serversetup
– Clientappsendsarequesttoserverapp– Serverappreturnsa(longer)reply
• Thisisthebasisformanyapps!– Filetransfer:sendname,getfile(§6.1.4)– Webbrowsing:sendURL,getpage– Echo:sendmessage,getitback
• Let’sseehowtowritethisapp…
42
SocketAPI• Simpleabstractiontousethenetwork
– ThenetworkserviceAPIusedtowriteallInternetapplications
– PartofallmajorOSes andlanguages;originallyBerkeley(Unix)~1983
• Supportstwokindsofnetworkservices– Streams:reliablysendastreamofbytes»– Datagrams:unreliablysendseparatemessages.(Ignore
fornow.)– Question:whenwouldyouusestreamsvs.datagrams?
3/27/17
22
43
SocketAPI(2)• Sockets letappsattachtothe
localnetworkatdifferentports
Socket,Port#1
Socket,Port#2
SocketAPI(3)
44
Primitive MeaningSOCKET CreateanewcommunicationendpointBIND AssociatealocaladdresswithasocketLISTEN Announcewillingnesstoacceptconnections;givequeuesizeACCEPT PassivelyestablishanincomingconnectionCONNECT ActivelyattempttoestablishaconnectionSEND SendsomedataovertheconnectionRECEIVE ReceivesomedatafromtheconnectionCLOSE Releasetheconnection
3/27/17
23
45
UsingSocketsClient(host1) Server(host2)Time
46
UsingSockets(2)Client(host1) Server(host2)Time
5:connect*
1:socket 2:bind1:socket
3:listen
9:send
6:recv*
4:accept*
7:send8:recv*
10:close 10:close
request
reply
disconnect
connect
*=callblocks
3/27/17
24
47
ClientProgram(outline)socket() //makesocketgetaddrinfo() //serverandportname
//www.example.com:80connect() //connecttoserver[block]…send() //sendrequestrecv() //awaitreply[block]… //dosomethingwithdata!close() //done,disconnect
48
ServerProgram(outline)socket() //makesocketgetaddrinfo() //forportonthishostbind() //associateportwithsocketlisten() //preparetoacceptconnectionsaccept() //waitforaconnection[block]…recv() //waitforrequest…send() //sendthereplyclose() //eventuallydisconnect
3/27/17
25
ProtocolsandLayering(§1.3)
50
NetworksNeedModularity• Thenetworkdoesmuchforapps:
– Makeandbreakconnections– Findapaththroughthenetwork– Transfersinformationreliably– Transfersarbitrarylengthinformation– Sendasfastasthenetworkallows– Sharesbandwidthamongusers– Securesinformationintransit– Letsmanynewhostsbeadded– …
3/27/17
26
51
NetworksNeedModularity• Thenetworkdoesmuchforapps:
– Makeandbreakconnections– Findapaththroughthenetwork– Transfersinformationreliably– Transfersarbitrarylengthinformation– Sendasfastasthenetworkallows– Sharesbandwidthamongusers– Securesinformationintransit– Letsmanynewhostsbeadded– …
Weneedaformofmodularity,tohelpmanagecomplexityandsupportreuse
52
ProtocolsandLayers• Protocols andlayering isthemainstructuringmethodusedtodivideupnetworkfunctionality– Eachinstanceofaprotocoltalksvirtuallytoitspeer usingtheprotocol
– Eachinstanceofaprotocolusesonlytheservicesofthelowerlayer
3/27/17
27
ProtocolsandLayers(2)• Protocolsarehorizontal,layersarevertical
53
X
YY
XInstanceofprotocolX
Peerinstance
Node1 Node2
Lowerlayerinstance(ofprotocolY)
ProtocolX
ServiceprovidedbyProtocolY
Question:whatisanexampleofaprotocolandwhatabstractiondoesitprovide/relyon?
ProtocolsandLayers(3)• Setofprotocolsinuseiscalledaprotocolstack
54
3/27/17
28
55
ProtocolsandLayers(4)• Protocolsyou’veprobablyheardof:
– TCP,IP,802.11,Ethernet,HTTP,SSL,DNS,…andmanymore
• Anexampleprotocolstack– UsedbyawebbrowseronahostthatiswirelesslyconnectedtotheInternet
56
Encapsulation• Encapsulation isthemechanismusedtoeffectprotocollayering– Lowerlayerwrapshigherlayercontent,addingitsowninformationtomakeanewmessagefordelivery
– Likesendingaletterinanenvelope;postalservicedoesn’tlookinside
3/27/17
29
Encapsulation(2)
57
HTTP
TCP
IP
802.11
Encapsulation(3)
58
HTTP
TCP
IP
802.11
HTTP
TCP HTTP
TCP HTTPIP
TCP HTTPIP802.11
HTTP
TCP
IP
802.11(wire)
HTTP
TCP HTTP
TCP HTTPIP
TCP HTTPIP802.11
TCP HTTPIP802.11
3/27/17
30
Encapsulation(4)• Normallydrawmessagelikethis:
– Eachlayeraddsitsownheader
• Moreinvolvedinpractice– Trailersaswellasheaders,encrypt/compresscontents– Segmentation(dividelongmessage)andreassembly
59
802.11 IP TCP HTTP
Firstbitsonthewire Lastbits
60
Demultiplexing• Incomingmessagemustbepassedtotheprotocolsthatituses
??
UDPTCP
ARPIP
Ethernet
SMTP HTTP DNS
3/27/17
31
Demultiplexing (2)• Donewithdemultiplexing keys intheheaders
61
Ethernet IP TCP HTTP
UDPTCP
ARPIP
Ethernet
SMTP HTTP
Ethertype value
IPprotocolfield
TCPportnumber
HostIncomingmessage
DNS
62
Protocols• Whataretheimplicationsofprotocolsandlayering?– Arethereanydownsidestoprotocols/layering?– Arethereanyperformancecosts?
3/27/17
32
AdvantageofLayering• Usinginformationhidingtoconnectdifferentsystems
63
HTTP
TCPIP
802.11
Browser
HTTP
TCP
IPEthernet
Server
64
Guidance• Whatfunctionalityshouldweimplementatwhichlayer?– Thisisakeydesignquestion– Referencemodels provideframeworksthatguideus»
3/27/17
33
OSI“7layer”ReferenceModel• Aprincipled,internationalstandard,toconnectsystems
– Influential,butnotusedinpractice.(Woops)
65
– Providesfunctionsneededbyusers– Convertsdifferentrepresentations– Managestaskdialogs– Providesend-to-enddelivery– Sendspacketsovermultiplelinks– Sendsframesofinformation– Sendsbitsassignals
InternetReferenceModel• Afourlayermodelbasedonexperience;omitssomeOSIlayersandusestheIPasthenetworklayer.
66
4.Application – Programsthatusenetworkservice
3.Transport – Providesend-to-enddatadelivery
2.Internet – Sendpacketsovermultiplenetworks
1.Link – Sendframesoveralink
3/27/17
34
InternetReferenceModel(2)• Whatareexamplesofcommonprotocolsineachlayer?
67
4.Application3.Transport
2.Internet
1.Link
InternetReferenceModel(3)• IPisthe“narrowwaist”oftheInternet
– Supportsmanydifferentlinksbelowandappsabove
68
4.Application3.Transport
2.Internet
1.Link Ethernet802.11
IP
TCP UDP
HTTPSMTP RTP DNS
3GDSLCable
3/27/17
35
IPSuite:EndHostsvs.Routers
69
HTTP
TCP
IP
Ethernetinterface
HTTP
TCP
IP
Ethernetinterface
IP IP
Ethernetinterface
Ethernetinterface
SONETinterface
SONETinterface
host host
router router
HTTP message
TCP segment
IP packet IP packetIP packet
70
Layer-basedNames(2)• Fordevicesinthenetwork:
Network
LinkNetwork
Link
Link Link
Physical PhysicalRepeater
Switch(orbridge)
Router
3/27/17
36
71
Layer-basedNames(3)• Fordevicesinthenetwork:
Proxyormiddleboxorgateway
Network
LinkNetwork
Link
AppTransport
AppTransport
Buttheyalllooklikethis!
72
ANoteAboutLayers• Theyareguidelines,notstrict
– Mayhavemultipleprotocolsworkingtogetherinonelayer
– Maybedifficulttoassignaspecificprotocoltoalayer
3/27/17
37
Best-EffortPacket-DeliveryService
Host-NetworkDivisionofLabor• Packetswitching
– Dividemessagesintoasequenceofpackets– Headerswithsourceanddestinationaddress
• Best-effortdelivery– Packetsmaybelost– Packetsmaybecorrupted– Packetsmaybedeliveredoutoforder
host host
network
3/27/17
38
Host-NetworkInterface:WhyPackets?
• Datatrafficisbursty– Loggingintoremotemachines– Exchanginge-mailmessages
• Don’twanttowastebandwidth– Notrafficexchangedduringidleperiods
• Bettertoallowmultiplexing– Differenttransfersshareaccesstosamelinks
• Packetscanbedeliveredbymostanything– RFC1149:IPDatagramsoverAvianCarriers
Host-NetworkInterface:WhyBest-Effort?
• Neverhavingtosayyou’resorry…– Don’treservebandwidthandmemory– Don’tdoerrordetection&correction– Don’trememberfromonepackettonext
• Easiertosurvivefailures– Transientdisruptionsareokayduringfailover
• Canrunonnearlyanylinktechnology– Greaterinteroperabilityandevolution
3/27/17
39
IntermediateTransportLayer• But,applications wantefficient,accuratetransferofdatainorder,ina
timelyfashion– Lettheendhostshandleallofthat– (Anexampleofthe“end-to-endargument”)
• Transportlayercanoptionally…– Detectandretransmitlostpackets– Putout-of-orderpacketsbackinorder– Detectandhandlecorruptedpackets– Avoidoverloadingthereceiver– <insertyourrequirementhere>
DirectoriesandRouting
78
3/27/17
40
RelationshipBetweenLayers
79
linksession
path
name
address
Directories:MappingNametoAddress
80
linksession
path
name
address
3/27/17
41
TypesofDirectories• Simplisticdesigns
– Askeveryone(e.g.,floodinginARP)– Telleveryone(e.g.,pushing/etc/hosts)– Centraldirectory
• Scalabledistributeddesigns– Hierarchicalnamespace(e.g.,DNS)– Flatnamespace(e.g.,DistributedHashTable)
81
Routing:MappingLinktoPath
82
linksession
path
name
address
3/27/17
42
PathComputation• Spanningtree(e.g.,Ethernet)
– Onetreethatconnectseverypairofnodes• Shortestpaths(e.g.,OSPF,IS-IS,RIP)
– Shortest-pathtreerootedateachnode
• Locallyoptimalpaths(e.g.,BGP)– Eachnodeselectsthebestamongitsneighbors
• End-to-endpaths(e.g.,sourcerouting)– Eachnodepicksthebestend-to-endpath
83
NetworkDiscoveryandBootstrapping
84
3/27/17
43
RelationshipBetweenLayers
85
linksession
path
name
address
ThreeKindsofIdentifiersHost Name IP Address MAC Address
Example www.cs.princeton.edu 128.112.7.156 00-15-C5-49-04-A9
Size Hierarchical, human readable, variable length
Hierarchical, machine readable, 32 bits (in IPv4)
Flat, machine readable, 48 bits
Read by Humans, hosts IP routers Switches in LAN
Allocation, top-level
Domain, assigned by registrar (e.g., for .edu)
Variable-length prefixes, assigned by ICANN, RIR, or ISP
Fixed-sized blocks, assigned by IEEE to vendors (e.g., Dell)
Allocation, low-level
Host name, local administrator
Interface, by DHCPor an administrator
Interface, by vendor
86
3/27/17
44
LearningaHost’sAddress
• WhoamI?– Hard-wired:MACaddress– Staticconfiguration:IPinterfaceconfiguration– Dynamicallylearned:IPaddressconfiguredbyDHCP
• Whoareyou?– Hard-wired:IPaddressinaURL,orinthecode– Dynamicallylookedup:ARPorDNS
87
me youadapter adapter
88
MappingBetweenIdentifiers• DynamicHostConfigurationProtocol(DHCP)
– GivenaMACaddress,assignauniqueIPaddress– …andtellhostotherstuffabouttheLocalAreaNetwork– Toautomatetheboot-strappingprocess
• AddressResolutionProtocol(ARP)– GivenanIPaddress,providetheMACaddress– ToenablecommunicationwithintheLocalAreaNetwork
• DomainNameSystem(DNS)– Givenahostname,providetheIPaddress– GivenanIPaddress,providethehostname
3/27/17
45
89
DynamicHostConfigurationProtocol
arrivingclient DHCP server
Host learnsIP address,Subnet mask, Gateway address, DNS server(s), and a lease time.
90
AddressResolutionProtocol(ARP)• EveryhostmaintainsanARPtable
– (IPaddress,MACaddress)pair• Consultthetablewhensendingapacket
– MapdestinationIPaddresstodestinationMACaddress– Encapsulateandtransmitthedatapacket
• But,whatiftheIPaddressisnotinthetable?– Senderbroadcasts:“WhohasIPaddress1.2.3.156?”– Receiverresponds:“MACaddress58-23-D7-FA-20-B0”– SendercachestheresultinitsARPtable
3/27/17
46
91
requesting hostcis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS serverdns.poly.edu
1
23
4
5
6
authoritative DNS serverdns.cs.umass.edu
78
TLD DNS server
DomainNameSystemHostatcis.poly.eduwants
IPaddressforgaia.cs.umass.edu
Recursive query: #1Iterative queries: #2, 4, 6
Questions• Shouldaddressescorrespondtotheinterface(pointofattachment)ortothehost?
• Whydowehaveallthreeidentifiers?Doweneedallthree?
• Whatshouldbedonetopreventspoofingofaddresses?