COS 461: Computer · PDF fileCOS 461: Computer Networks ... answer quesons (parcipaon!) ......

Preview:

Citation preview

COS461:ComputerNetworks

Spring2010(MW3:00‐4:20pminCS105)

Prof.MikeFreedman

TeachingAssistants:MuneebAliandDavidShuehNp://www.cs.princeton.edu/courses/archive/spr10/cos461/

1

GoalsforToday’sClass

•  COS461overview–  Goalsofthecourse–  Structureofthecourse–  Learningthematerial–  Programmingassignments–  Coursegrading–  Academicpolicies

•  Keyconceptsindatanetworking–  Protocols–  Layering–  ResourceallocaVon–  Naming

2

WhatYouLearninThisCourse

•  Skill:networkprogramming–  Socketprogramming–  DesigningandimplemenVngprotocols

•  Knowledge:howtheInternetworks–  IPprotocolsuite–  Internetarchitecture–  ApplicaVons(Web,DNS,P2P,…)

•  Insight:keyconceptsinnetworking–  Protocols–  Layering–  ResourceallocaVon–  Naming

3

StructureoftheCourse(1stHalf)•  Startatthetop

–  Sockets:howapplicaVonsviewtheInternet–  Protocols:essenValelementsofaprotocol

•  Thenstudythe“narrowwaist”ofIP–  IPbest‐effortpacket‐deliveryservice–  IPaddressingandpacketforwarding

•  Andhowtobuildontopofthenarrowwaist–  Transportprotocols(TCP,UDP)–  DomainNameSystem(DNS)–  Glue(ARP,DHCP,ICMP)–  End‐systemsecurityandprivacy(NAT,firewalls)

•  LookingunderneathIP–  Linktechnologies(Ethernet)

4

StructureoftheCourse(2ndHalf)•  Andhowtogetthetrafficfromheretothere

–  InternetrouVngarchitecture(the“inter”inInternet)–  IntradomainandinterdomainrouVngprotocols

•  Specialnetworkingtopics– MulVcast,Over/Underlaynetworking–  Datacenternetworks– Wirelessandmobility

•  BuildingapplicaVons– MulVcast,Over/Underlaynetworking–  HTTPandContentDistribuVonNetworks–  Peer‐to‐peer,DHTs,BitTorrent–  Distributedsystems:Consistencyandagreement–  NetworkandcommunicaVonsecurity 5

LearningtheMaterial:People•  Lecture(Prof.MikeFreedman)

– When:MW3:00‐4:20inComputerScience105–  SlidesavailableonlineatcourseWebsite–  Officehours(room308)onMon,4:20‐5:00(orbyappt)–  Email:mfreed+cos461atcs.princeton.edu

•  TeachingAssistants– MuneebAli

•  E‐mail:muneeb+cos461atcs.princeton.edu–  DavidShue

•  E‐mail:dshue+cos461atcs.princeton.edu

•  Mainemail:cos461‐staffatlists.cs.princeton.edu

6

LearningtheMaterial:MailingList•  Mailinglist

–  Ifyou’reenrolled,youshouldbeonit– E‐mail:cos461atlists.cs.princeton.edu– Signup:hNps://lists.cs.princeton.edu/mailman/lisVnfo/cos461

•  Readofen– GoodplacetoaskquesVons– Butdonotpostyourcode

•  Reply,too– GoodplacetoanswerquesVons(parVcipaVon!)

7

LearningtheMaterial:Books•  Requiredtextbook

–  ComputerNetworks:ASystemsApproach(4thedi:on),byPetersonandDavie[Okaytousethe3rdediVon]

– Mostlycoversthematerialinthefirsthalfoftheclass•  Booksonreserve

– Networkingtextbooks•  ComputerNetworking:ATop‐DownApproachFeaturingtheInternet(3rdedi:on),byKuroseandRoss

•  ComputerNetworks(4thedi:on),byTanenbaum– Networkprogrammingreferences

•  TCP/IPIllustrated,Volume1:TheProtocols,byStevens•  UnixNetworkProgramming,Volume1:TheSocketsNetworkingAPI(3rdEdi:on),byStevens,Fenner,&Rudolf

•  Onlineresources–  E.g.onsocketprogramming

8

GradingandSchedule•  Assignments(10%each)

–  95%3hours,70%2dayslate,50%>3dayslate– Onefreelatedayduringsemester– Mustcompleteallassignmentstopass

•  Twoexams(45%total)– Midtermexambeforespringbreak(20%)–  Finalexamduringexamperiod(25%)

•  ClassparVcipaVon(5%)–  Inlecture– Onthelistserv– Willgrade0‐5

9

ProgrammingAssignments•  Fiveassignments

–  IntroducVontosockets(SunFeb14)–  SimpleHTTPproxy–  AdvancedHTTPproxy–  Reliabletransport–  IProuter(SunApr12)‐‐nolateaccepted

10

FaciliVesforProgramming•  ComputerclusterinFriendCenter010

–  FriendCenter010computers– Machines:labpc‐XX.cs.princeton.eduforXXof01to30– Why:commonenvironment,andaccesstolabTAs

•  Accessingyouraccount–  Ifyouareenrolled,youhavealabpcaccount–  UsingyourOITloginandpassword

•  Loggingintothemachinesremotely–  SSHtoportal.cs.princeton.edu,andthentoFC010–  NeedaCSaccount,ifyoudon’thaveonealready–  hNps://csguide.cs.princeton.edu/requests/account–  Requesta“classaccount”

11

FaciliVesforProgramming•  OtheropVon:yourownPC(notrecommended)

–  RunningGNUtoolsonLinux,or–  RunningGNUtoolsonWindows,or

–  RunningastandardCdevelopmentenvironment– DevelopmentenvironmentnotsupportedbyTAs

•  SuggesVon:testaccessthisweek–  LoggingintotheFC010cluster– WriVngandrunning“HelloWorld”inC

•  Submirngassignments– UsingBlackboard– Moredetailscomingsoon! 12

GraduateStudents:TwoChoices•  PickoneoftwoopVons

– Dothefiveprogrammingassignments

– Or,firsttwoassignments,plusresearchproject

•  Researchprojects– Networking‐relatedresearchproblem

– Musthaveasystemsprogrammingcomponent– Write‐upofprojectdueonDean’sDate– Talktomeaboutaprojectbeforespringbreak

13

Policies:WriteYourOwnCodeProgramminginanindividualcreaVveprocessmuchlike

composiVon.YoumustreachyourownunderstandingoftheproblemanddiscoverapathtoitssoluVon.DuringthisVme,discussionswithfriendsareencouraged.However,whentheVmecomestowritecodethatsolvestheproblem,suchdiscussionsarenolongerappropriate‐theprogrammustbeyourownwork.

IfyouhaveaquesVonabouthowtousesomefeatureofC,UNIX,etc.,youcancertainlyaskyourfriendsortheTA,butdonot,underanycircumstances,copyanotherperson'sprogram.Lerngsomeonecopyyourprogramorusingsomeoneelse'scodeinanyformisaviola7onofacademicregula7ons."Usingsomeoneelse'scode"includesusingsoluVonsorparValsoluVonstoassignmentsprovidedbycommercialwebsites,instructors,preceptors,teachingassistants,friends,orstudentsfromanypreviousofferingofthiscourseoranyothercourse. 14

Okay,solet’sgetstarted…withacrashcourseindatanetworking

15

KeyConceptsinNetworking•  Protocols

–  Speakingthesamelanguage–  SyntaxandsemanVcs

•  Layering–  Standingontheshouldersofgiants– Akeytomanagingcomplexity

•  ResourceallocaVon– DividingscareresourcesamongcompeVngparVes– Memory,linkbandwidth,wirelessspectrum,paths,…

– Distributedvs.centralizedalgorithms•  Naming

– Whattocallcomputers,services,protocols,…•  Architecturalprinciples:End‐to‐end,etc.

16

Protocols:CalendarService•  Makinganappointmentwithyouradvisor

•  Specifyingthemessagesthatgobackandforth– Andanunderstandingofwhateachpartyisdoing

17

Please meet with me for 1.5 hours starting at

1:30pm on February 8, 200?

I can’t. I can’t. Yes!

Please meet with me for 1.5 hours starting at

3:00pm on February 8, 2009?

Please meet with me for 1.5 hours starting at

4:30pm on February 8, 2009?

Okay,SoThisisGerngTedious•  You:Whenareyoufreetomeetfor1.5hoursduringthenexttwoweeks?

•  Advisor:10:30amonFeb8and1:15pmonFeb9.

•  You:Bookmefor1.5hoursat10:30amonFeb8.•  Advisor:Yes.

18

Well,NotQuiteEnough•  Student#1:Whencanyoumeetfor1.5hoursduringthe

nexttwoweeks?•  Advisor:10:30amonFeb8and1:15pmonFeb9.•  Student#2:Whencanyoumeetfor1.5hoursduringthe

nexttwoweeks?•  Advisor:10:30amonFeb8and1:15pmonFeb9.•  Student#1:Bookmefor1.5hoursat10:30amonFeb8.•  Advisor:Yes.•  Student#2:Bookmefor1.5hoursat10:30amonFeb8.•  Advisor:Uh…well…Icannolongercanmeetthen.I’mfree

at1:15pmonFeb9.•  Bookmefor1.5hoursat1:15pmonFeb9.•  Advisor:Yes.•  Advisor:Wait…amItalkingtoStudent1or2?

19

SpecifyingtheDetails•  HowtoidenVfyyourself?

–  Name?Socialsecuritynumber?

•  HowtorepresentdatesandVme?–  Time,day,month,year?InwhatVmezone?–  NumberofsecondssinceJan1,1970?

•  WhatgranulariVesofVmestouse?–  AnypossiblestartVmeandmeeVngduraVon?– MulVplesoffiveminutes?

•  Howtorepresentthemessages?–  Strings?Recordwithname,startVme,andduraVon?

•  Whatdoyoudoifyoudon’tgetaresponse?–  Askagain?Replyagain?

20

Example:HyperTextTransferProtocol

21

GET /courses/archive/spr09/cos461/ HTTP/1.1 Host: www.cs.princeton.edu User-Agent: Mozilla/4.03 CRLF

HTTP/1.1 200 OK Date: Mon, 2 Feb 2009 13:09:03 GMT Server: Netscape-Enterprise/3.5.1 Last-Modified: Mon, 42 Feb 2009 11:12:23 GMT Content-Length: 21 CRLF Site under construction

Request

Response

Example:IPPacket

22

4-bit Version

4-bit Header Length

8-bit Type of Service (TOS) 16-bit Total Length (Bytes)

16-bit Identification 3-bit Flags 13-bit Fragment Offset

8-bit Time to Live (TTL)

8-bit Protocol 16-bit Header Checksum

32-bit Source IP Address

32-bit Destination IP Address

Options (if any)

Payload

IP:Best‐EffortPacketDelivery

23

•  Packetswitching– Senddatainpackets– Headerwithsource&desVnaVonaddress

•  Best‐effortdelivery– Packetsmaybelost– Packetsmaybecorrupted– Packetsmaybedeliveredoutoforder

source destination

IP network

Example:TransmissionControlProtocol

•  CommunicaVonservice(socket)–  Ordered,reliablebytestream–  SimultaneoustransmissioninbothdirecVons

•  Keymechanismsatendhosts–  Retransmitlostandcorruptedpackets–  Discardduplicatepacketsandputpacketsinorder–  Flowcontroltoavoidoverloadingthereceiverbuffer–  CongesVoncontroltoadaptsendingratetonetworkload

24 source network destination

TCP connection

ProtocolStandardizaVon•  CommunicaVnghostsspeakingthesameprotocol

–  StandardizaVontoenablemulVpleimplementaVons–  Or,thesamefolkshavetowriteallthesofware

•  StandardizaVon:InternetEngineeringTaskForce–  Basedonworkinggroupsthatfocusonspecificissues–  Produces“RequestForComments”(RFCs)

•  Promotedtostandardsviaroughconsensusandrunningcode•  E.g.,RFC1945on“HyperTextTransferProtocol–HTTP/1.0”

–  IETFWebsiteishNp://www.ie|.org

•  Defactostandards:samefolkswriVngthecode–  P2Pfilesharing,BitTorrent,Skype,Flashvideos(RTMP)–  <yourprotocolhere>… 25

KeyConceptsinNetworking•  Protocols

–  Speakingthesamelanguage–  SyntaxandsemanVcs

•  Layering–  Standingontheshouldersofgiants– Akeytomanagingcomplexity

26

Layering:AModularApproach•  Sub‐dividetheproblem

– Eachlayerreliesonservicesfromlayerbelow– Eachlayerexportsservicestolayerabove

•  InterfacebetweenlayersdefinesinteracVon– HidesimplementaVondetails– Layerscanchangewithoutdisturbingotherlayers

27 Link hardware

Host-to-host connectivity

Application-to-application channels

Application

IPSuite:EndHostsvs.Routers

28

HTTP

TCP

IP

Ethernet interface

HTTP

TCP

IP

Ethernet interface

IP IP

Ethernet interface

Ethernet interface

SONET interface

SONET interface

host host

router router

HTTP message

TCP segment

IP packet IP packet IP packet

TheInternetProtocolSuite

29

UDP TCP

Data Link

Physical

Applications

The Hourglass Model

Waist

The waist facilitates interoperability

FTP HTTP TFTP NV

TCP UDP

IP

NET1 NET2 NETn …

LayerEncapsulaVon

30

Get index.html

Connection ID

Source/Destination

Link Address

User A User B

WhatiftheDataDoesn’tFit?

31

Problem: Packet size

Solution: Split the data across multiple packets

•  On Ethernet, max IP packet is 1500 bytes

•  Typical Web page is 10 kbytes

GET inde x.ht ml

GET index.html

ProtocolDemulVplexing•  MulVplechoicesateachlayer

32

FTP HTTP TFTP NV

TCP UDP

IP

NET1 NET2 NETn …

TCP/UDP IP

Port Number

Network

Protocol Field

Type Field

DemulVplexing:PortNumbers•  DifferenVatebetweenmulVpletransfers

–  KnowingsourceanddesVnaVonhostisnotenough–  Needanidforeachtransferbetweenthehosts

•  Usewell‐knownportstodiscoveraparVcularservice–  E.g.,HTTPserverrunningonport80–  E.g.,FTPserverrunningonport21–  ButhowdifferenVateifserveralwaysport80?

33

HTTP transfers

FTP transfer

IsLayeringHarmful?•  LayerNmayduplicatelowerlevelfuncVonality

–  E.g.,errorrecoverytoretransmitlostdata

•  LayersmayneedsameinformaVon–  E.g.,Vmestamps,maximumtransmissionunitsize

•  Strictadherencetolayeringmayhurtperformance–  E.g.,hidingdetailsaboutwhatisreallygoingon

•  Somelayersarenotalwayscleanlyseparated–  Inter‐layerdependenciesforperformancereasons–  Somedependenciesinstandards(headerchecksums)

•  Headersstarttogetreallybig–  SomeVmesmoreheaderbytesthanactualcontent

34

KeyConceptsinNetworking•  Protocols

–  Speakingthesamelanguage–  SyntaxandsemanVcs

•  Layering–  Standingontheshouldersofgiants– Akeytomanagingcomplexity

•  ResourceallocaVon– DividingscareresourcesamongcompeVngparVes– Memory,linkbandwidth,wirelessspectrum,paths,…

– Distributedvs.centralizedalgorithms

35

ResourceAllocaVon:Queues

•  Sharingaccesstolimitedresources–  E.g.,alinkwithfixedservicerate

•  Simplestcase:first‐in‐firstoutqueue–  Servepacketsintheordertheyarrive– Whenbusy,storearrivingpacketsinabuffer– Droppacketswhenthequeueisfull

•  Anybodyhearof“NetworkNeutrality”?36

WhatiftheDatagetsDropped?

37

Internet GET index.html

Problem: Lost Data

Internet GET index.html

Solution: Timeout and Retransmit

GET index.html GET index.html

WhatiftheDataisOutofOrder?

38

Solution: Add Sequence Numbers

Problem: Out of Order

GET x.ht inde ml

GET x.htindeml

GET index.html

ml 4 inde 2 x.ht 3 GET 1

ResourceAllocaVon:CongesVonControl

•  Whatiftoomanyfolksaresendingdata?– Sendersagreetoslowdowntheirsendingrates– …inresponsetotheirpacketsgerngdropped

•  TheessenceofTCPcongesVoncontrol– KeytoprevenVngcongesVoncollapseoftheInternet

39

TransmissionControlProtocol•  Flowcontrol:window‐based

–  Senderlimitsnumberofoutstandingbytes(windowsize)–  Receiverwindowensuresdatadoesnotoverflowreceiver

•  CongesVoncontrol:adapVngtopacketlosses–  Conges:onwindowtriestoavoidoverloadingthenetwork(increasewithsuccessfuldelivery,decreasewithloss)

–  TCPconnecVonstartswithsmalliniValcongesVonwindow

time cong

esti

on w

indo

w

slow start congestion avoidance

KeyConceptsinNetworking•  Protocols

–  Speakingthesamelanguage–  SyntaxandsemanVcs

•  Layering–  Standingontheshouldersofgiants– Akeytomanagingcomplexity

•  ResourceallocaVon– DividingscareresourcesamongcompeVngparVes– Memory,linkbandwidth,wirelessspectrum,paths,…

– Distributedvs.centralizedalgorithms•  Naming

– Whattocallcomputers,services,protocols,…

41

Naming:DomainNameSystem(DNS)

•  ProperVesofDNS– Hierarchicalnamespacedividedintozones–  TranslaVonofnamesto/fromIPaddresses– DistributedoveracollecVonofDNSservers

•  ClientapplicaVon–  Extractservername(e.g.,fromtheURL)–  InvokesystemcalltotriggerDNSresolvercode

•  E.g.,gethostbyname()onwww.cs.princeton.edu

•  ServerapplicaVon–  ExtractclientIPaddressfromsocket– OpVonallyinvokesystemcalltotranslateintoname

•  E.g.,gethostbyaddr()on“12.34.158.5”42

DomainNameSystem

com edu org ac uk zw arpa

unnamed root

bar

west east

foo my

ac

cam

usr

in- addr

12

34

56

generic domains country domains

my.east.bar.edu usr.cam.ac.uk

12.34.56.0/24

DNSResolverandLocalDNSServer

Application

DNS resolver

Local DNS server

1 10

DNS cache

DNS query 2

DNS response 9

Root server

3

4

Top-level domain server

5

6

Second-level domain server

7

8

•  CachingbasedonVme‐to‐live(TTL)specifiedbyauthorita:veDNSserver,i.e.,oneresponsiblefordomainname–  ReduceslatencyinDNStranslaVon–  ReducesloadonauthoritaVveDNSservers

KeyConceptsinNetworking•  Protocols

–  Speakingthesamelanguage–  SyntaxandsemanVcs

•  Layering–  Standingontheshouldersofgiants– Akeytomanagingcomplexity

•  ResourceallocaVon– DividingscareresourcesamongcompeVngparVes– Memory,linkbandwidth,wirelessspectrum,paths,…

– Distributedvs.centralizedalgorithms•  Naming

– Whattocallcomputers,services,protocols,…•  Architecturalprinciples:End‐to‐end,etc.

45

TOCS,1981

46

•  Reliability(TCPvs.IP•  Security(SSLvs.IPSec)•  …

Conclusions•  CourseobjecVves

– Networkprogramming,howtheInternetworks,andkeyconceptsinnetworking

•  Keyconceptsinnetworking– Protocols,layers,resourceallocaVon,andnaming

•  Nextlecture:networkprogramming– SocketabstracVon(importantforassignment#1)– ReadChapter1ofthePeterson/Daviebook– Skimtheonlinereferencematerialonsockets

–  (Re)familiarizeyourselfwithCprogramming47