Networking Fundamentals - ecs-network.serv.pacific.edu · ì Computer Systems and Networks ECPE 170...
Transcript of Networking Fundamentals - ecs-network.serv.pacific.edu · ì Computer Systems and Networks ECPE 170...
Lab Schedule
Activitiesì ThisWeek
ì Networkprogrammingì Endiannessì Lab8– Network
Programming
AssignmentsDueì Lab8
ì DuebyMar27th 5:00am
ì Lab9ì DuebyApr3rd 5:00am
Spring2017ComputerSystemsandNetworks
2
Persons of the Day: Vint Cerf / Bob Kahn
ì Co-designersofTCP/IPprotocolsuiteì Enablesreliable
communicationacrossunreliablenetwork
ì FoundationofInternet
ì 2004ACMTuringAwardwinners(shared)
ì 2005PresidentialMedalofFreedomwinners (shared)
Spring2017ComputerSystemsandNetworks
3
Person of the Day: Tim Berners-Lee
ì Inventorof“WorldWideWeb”ì Firstimplementationof
HTTP(HyperText TransferProtocol)tocommunicatebetweenclientandserver
ì KnightedbyQueenElizabethIIin2004
Spring2017ComputerSystemsandNetworks
4
Disclaimer
ì ThesetopicstakeanentiresemesterofCOMP177(ComputerNetworking)toexplore!
ì Afewdays(mostofwhichislabtime) isonlysufficientforthebriefestofoverviews…
Spring2017ComputerSystemsandNetworks
6
Network Model
7
Application Layer(Myriad examples: Web browser, web server, etc…)
Transport Layer(Reliability – e.g. TCP)
Network Layer(Global Network – e.g. IP)
Link Layer(Local Area Network – e.g. Ethernet)
Physical Layer (“Bit on a Wire”)
Spring2017ComputerSystemsandNetworks
Application Layer
8
Application Layer
Transport LayerNetwork Layer
Link LayerPhysical Layer
HTTP DNS IMAP
Sockets
…andmanymore!
Skype BitTorrent RDP
SSH NTP NFS
Spring2017ComputerSystemsandNetworks
Application Layer
ì Theapplicationlayer programmercanmakemany(fantastic)assumptionsaboutthenetworkì Thenetworkisreliable
ì Messagesarenotlostì Messagesarereceivedintheordertheyaresent
ì Thenetworkcantransferdataofinfinitelength(youcansendasmuchdataasdesired)
ì Youcandelivermessagesdirectlytoaspecificapplicationonaspecificcomputeranywhereontheplanet
ì Thelowerlayers(transport,network,link,…)doalltheheavy-liftingtomaketheseassumptionstrue
Spring2017ComputerSystemsandNetworks
9
Client-Server Architecture
Serverì Always-onhost
ì AlwayshasaknownIPaddress
ì Lotsofbandwidth
ì Serverprocess:processthatwaitstobecontacted
Clientì Communicatewithserver
ì Maybeintermittentlyconnected
ì MayhavedynamicIPaddresses
ì Donotcommunicatedirectlywitheachother
ì Clientprocess:processthatinitiatescommunication
Spring2017ComputerSystemsandNetworks
10
Why Do We Have Sockets?
ì Challenge– Inter-processcommunication
ì Aprocessisanindependentprogramrunningonahostì Separatememoryspace
ì Howdoprocessescommunicatewithotherprocessesì Onthesamehost?ì Ondifferenthosts?
ì Sendmessages betweeneachother
11
Spring2017ComputerSystemsandNetworks
12
What is a Socket?
ì Aninterfacebetween process(application)andnetworkì Theapplicationcreatesasocketì Thesockettypedictatesthestyleofcommunication
ì Reliablevs.besteffortì Connection-orientedvs.connectionless
ì Onceconfiguredtheapplicationcanì Passdatatothesocketfornetworktransmissionì Receivedatafromthesocket(transmittedthrough
thenetworkbysomeotherhost)
Spring2017ComputerSystemsandNetworks
What is a Socket?ì Processsends/receivesmessages
to/fromitssocket
ì Socketanalogoustodoorì Sendingprocessshovesmessage
outdoorì Transportinfrastructureonother
sideofdoorcarriesmessagetosocketatreceivingprocess
ì Imagineyouarejustwritingtoafile…
ì APIallowcustomizationofsocketì Choosetransportprotocolì Chooseparametersofprotocol
13
process
TCPwithbuffers,variables
socket
hostorserver
process
TCPwithbuffers,variables
socket
hostorserver
Internet
controlledbyOS
controlledbyappdeveloper
Spring2017ComputerSystemsandNetworks
Addressing Processes
ì Toreceivemessages,eachprocessonahostmusthaveanidentifierì IPaddressesareuniqueì Isthissufficient?
ì No,therecanthousandsofprocessesrunningonasinglemachine(withoneIPaddress)
ì Identifiermustincludeì IPaddressì and portnumber(example:80forweb)
14
Spring2017ComputerSystemsandNetworks
ì Eachhosthas65,536ports
ì Someportsarereservedforspecificappsì FTP(20,21),Telnet(23),HTTP(80),etc…
ì Outgoingports(onclients)canbedynamicallyassignedbyOSinupperregion(above49,152)– calledephemeralports
ì Seehttp://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
15
Ports
Port0
Port1
Port65535
Spring2017ComputerSystemsandNetworks
Socket Usage: Client Program
ì Basicsocketfunctionsforconnection-oriented(TCP)clients
1. socket() createthesocketdescriptor
2. connect() connecttotheremoteserver
3. send(),recv() communicatewiththe server
4. close() endcommunicationbyclosingsocketdescriptor
16
Spring2017ComputerSystemsandNetworks
Application-Layer Protocol
ì Socketsjustallowustosendrawmessagesbetweenprocessesondifferenthostsì Transportservicetakescareofmovingthedata
ì What exactlyissentisuptotheapplicationì Anapplication-layer protocolì HTTP,NTP,IMAP,SFTP,Skype,etc…
17
Spring2017ComputerSystemsandNetworks
Application-Layer Protocol
ì Boththeclientandserverspeakingtheprotocolmustagreeonì Typesofmessagesexchanged
ì e.g.,request,responseì Messagesyntax
ì Whatfieldsareinmessagesì Howfieldsaredelineated
ì Messagesemanticsì Meaningofinformationinfields
ì Rulesforwhen andhow processessendandrespondtomessages
18
Spring2017ComputerSystemsandNetworks
Hypertext Transfer Protocol Overview
ì HTTP istheapplicationlayerprotocol fortheweb
ì Itishowtheclientandservercommunicate
ì Client/servermodelì Client:browserthat
requests,receives,“displays”Webobjects
ì Server:Webserversendsobjectsinresponsetorequests
19
PCrunningChrome
Serverrunning
ApacheWebserver
MacrunningSafari
Spring2017ComputerSystemsandNetworks
Web and HTTP
ì Webpage consistsofbaseHTMLfileand(potentially)manyreferencedobjectsì HTMLfile,PNGimage,Flashvideo,…
ì EachobjectisaddressablebyaURL
ì ExampleURL:
Spring2017ComputerSystemsandNetworks
20
www.somecompany.com/someDept/image.png
hostname pathname
HTTP Request Message (Client->Server)
Spring2017ComputerSystemsandNetworks
21
GET /about/ HTTP/1.1Host: www.google.comUser-agent: Mozilla/13.0Connection: close Accept-language:en<line with only \r\n>
requestline(GET,POST,
HEADcommands)
headerlines
Carriagereturn,linefeed
indicatesendofmessage
HTTPisatext-basedprotocol.TheclientsendsASCII bytesintherequest,andtheserverrespondswithASCIIbytesinthereply.
HTTP Response Message (Server -> Client)
Spring2017ComputerSystemsandNetworks
22
HTTP/1.1 200 OKVary: Accept-EncodingContent-Type: text/htmlLast-Modified: Tue, 10 Apr 2012 09:33:47Date: Tue, 10 Apr 2012 17:50:51 GMTExpires: Tue, 10 Apr 2012 17:50:51 GMTCache-Control: private, max-age=0X-Content-Type-Options: nosniffServer: sffeX-XSS-Protection: 1; mode=blockTransfer-Encoding: chunked<line with only \r\n><Data begins here...>
statusline(protocol
statuscode,statusphrase)
headerlines
data,e.g.,requestedHTMLfile
HTTP Response Status Codes
200 OKì Requestsucceeded,requestedobjectlaterinthismessage
301 Moved Permanentlyì Requestedobjectmoved,newlocationspecifiedlaterinthis
message(Location:)
400 Bad Requestì Requestmessagenotunderstoodbyserver
404 Not Foundì Requesteddocumentnotfoundonthisserver
505 HTTP Version Not Supported
Spring2017ComputerSystemsandNetworks
23
Afewexamplesoutofmany!
Link Layer
25
Application LayerTransport LayerNetwork Layer
Link Layer
Physical Layer
Framing
Ethernet!
MAC addressesHubs & Switches
Transfer between
neighbors
Spring2017ComputerSystemsandNetworks
Network Layer
26
Application LayerTransport Layer
Network Layer
Link LayerPhysical Layer
IP – Internet Protocol!
IP Addresses Routers Routing Protocols
End-to-End packet
transfer
Spring2017ComputerSystemsandNetworks
IP Properties
ì Datagramì Eachpacketisindividually
routedì Packetsmaybe
fragmented orduplicatedbyunderlyingnetworks
ì Connectionlessì Noguaranteeofdeliveryin
sequence
ì Unreliableì Noguaranteeofdeliveryì Noguaranteeofintegrity
ofdata
ì Besteffortì Onlydroppacketswhen
necessaryì Notimeguaranteefor
delivery
Spring2017ComputerSystemsandNetworks
27
Ethernetnetworksprovidethesame“guarantees”
Transport Layer
28
Application LayerTransport Layer
Network LayerLink Layer
Physical Layer
TCP UDP
End-to-End message transfer
Sockets
Flow Control Congestion Control
Spring2017ComputerSystemsandNetworks
“Magic” of the Internet
ì IP:Un-reliable,ordernotguaranteed,deliveryofindividualmessages
ì TCP:Reliable,in-orderdeliveryofdatastream
ì Magicì TCPisbuiltontopofIP!
ì GreatclownanalogybyJoelSpolskyhttp://www.joelonsoftware.com/articles/LeakyAbstractions.html
29
Spring2017ComputerSystemsandNetworks
Clown Delivery
30
Broadway,NYC
NeedtomoveclownsfromBroadwaytoHollywoodforanewjob
Spring2017ComputerSystemsandNetworks
Clown Delivery – Problems?
31
Carcrash/lost
DifferentroutesShavedhead/toouglytowork!
Manycars,manyclownsBadthingsareguaranteedtohappentoatleastsome ofthem
Spring2017ComputerSystemsandNetworks
Clown Delivery – Problems?
32
PeopleinHollywoodgetfrustrated–It’shardtomakemovieswithclownsinthiscondition!
Spring2017ComputerSystemsandNetworks
Clown Delivery - Solution
ì Newcompanyì HollywoodExpress
ì Guaranteesthatallclownsì (1)Arriveì (2)InOrderì (3)InPerfectCondition
ì Mishap?Callandrequestclown’stwinbrotherbesentimmediately
ì UFOcrashinNevadablockshighway?
ì Clownsre-routedviaArizonaì Directorneverevenhears
abouttheUFOcrashì Clownsarrivealittlemore
slowly
33
Spring2017ComputerSystemsandNetworks
Networking Abstraction
ì TCPprovidesasimilarreliabledeliveryserviceforIP
ì Abstractionhasitslimitsì Ethernetcablechewed
throughbycat?ì Nousefulerrormessage
forthatproblem!ì Theabstractionis
“leaky”– itcouldn’tsavetheuserfromlearningaboutthechewedcable
34
Spring2017ComputerSystemsandNetworks