750 likes | 766 Views
Networking Overview: “Everything” you need to know, in 50 minutes. Network Security Prof. Haojin Zhu Adopted from David Wagner @ UC Berkeley May 1 1 , 201 8. Lo ca l -Area Ne t w o rks. A. C. poin t-to-point. shared. How does compu ter A send a message to compu ter C?.
E N D
Networking Overview: “Everything” you need to know, in 50minutes Network Security Prof. Haojin Zhu Adopted from David Wagner @ UC Berkeley May11,2018
Local-AreaNetworks A C point-to-point shared HowdoescomputerAsenda messagetocomputerC?
Local-AreaNetworks:Packets From:A To:C Message:Helloworld!
Wide-AreaNetworks A router C HowdoweconnecttwoLANs?
Wide-AreaNetworks A A R A.com C.com Hello world! HowdoweconnecttwoLANs? router C R C A.com C.com Helloworld! 5
KeyConcept#1:Protocols • Aprotocolisanagreementonhowto communicate • Includessyntaxand semantics • Howacommunicationisspecified&structured • oFormat,ordermessagesaresentandreceived • Whatacommunicationmeans • oActionstakenwhentransmitting,receiving,ortimerexpires • Example:makingacommentinlecture? • Raiseyourhand. • Waittobecalledon. • Or:waitforspeakertopause andvocalize 4.Ifunrecognized(aftertimeout):say“excuseme” 6
KeyConcept#2:DumbNetwork • OriginalInternetdesign:interiornodes (“routers”) havenoknowledge*ofongoingconnectionsgoing throughthem • Nothowyoupicturethetelephonesystemworks • Whichinternallytracksalloftheactivevoicecalls • Instead:thepostalsystem! • EachInternetmessage (“packet”)self-contained * Today’s Internet is full of hacks that violate this 7
Self-ContainedIPPacketFormat IP=InternetProtocol 8-bit TypeofService (TOS) 4-bit Header Length 4-bit Version 16-bitTotal Length(Bytes) 3-bit Flags 13-bitFragmentOffset 16-bitIdentification Headerislikea letter envelope: containsall info neededfor delivery 8-bitTime to Live(TTL) 8-bitProtocol 16-bitHeaderChecksum 32-bitSourceIPAddress 32-bitDestinationIPAddress Payload(remainderofmessage) . . . . .
KeyConcept#2:DumbNetwork • OriginalInternetdesign:interiornodes (“routers”) havenoknowledge*ofongoingconnectionsgoing throughthem • Not:howyoupicturethetelephonesystemworks • Whichinternallytracksalloftheactivevoicecalls • Instead:thepostalsystem! • EachInternetmessage (“packet”)self-contained • Interiorrouterslookatdestinationaddresstoforward • Ifyouwantsmarts,buildit“end-to-end”, not “hop-by-hop” • Buyssimplicity&robustnessatthecostofshifting complexityintoendsystems * Today’s Internet is full of hacks that violate this 9
KeyConcept#3:Layering • Internetdesignisstronglypartitionedintolayers • Eachlayerreliesonservicesprovidedbynextlayer below… • …andprovidesservicestolayeraboveit • Analogy: –Considerstructureofan applicationyou’vewritten andthe“services”each layerrelieson/provides SystemCalls } DeviceDrivers Fully isolated VoltageLevels/ MagneticDomains fromuser programs
InternetLayering(“ProtocolStack”) Note onapoint of potential confusion: these diagrams arealwaysdrawnwith lowerlayers below higherlayers… But diagramsshowing the layouts of packets are often the opposite, with the lowerlayers at thetopsince their headersprecede those for higherlayers 7 4 3 2 1
HorizontalViewofaSinglePacket Firstbittransmitted Link Layer Header (Inter)Network Layer Header (IP) Transport Layer Header ApplicationData:structure dependsontheapplication …
VerticalViewofaSinglePacket Link Layer Header Firstbittransmitted (Inter)NetworkLayer Header(IP) TransportLayerHeader ApplicationData: structuredependsonthe application . . . . . . . 13
InternetLayering(“Protocol Stack”) 7 4 3 2 1
Layer1:PhysicalLayer 7 4 3 2 Encodingbitstosendthem overasinglephysical link e.g.patternsof voltagelevels/ photonintensities/ RFmodulation 1
Layer2:LinkLayer Framingandtransmissionofa collectionofbitsintoindividual messagessentacrossa single“subnetwork”(one physicaltechnology) Mightinvolvemultiplephysical links(e.g.,modernEthernet) Oftentechnologysupports broadcasttransmission (every “node”connectedtosubnet receives) 7 4 3 2 1
Layer3:(Inter)NetworkLayer(IP) • Bridgesmultiple“subnets”to provideend-to-endinternet connectivitybetweennodes • Providesglobaladdressing 7 4 3 2 Worksacrossdifferentlink technologies } Differentforeach Internet“hop” 1
Layer4:TransportLayer End-to-endcommunication betweenprocesses Differentservicesprovided: TCP=reliablebytestream UDP=unreliabledatagrams (Datagram=singlepacket message) 7 4 3 2 1
Layer7:ApplicationLayer Communicationofwhatever youwish Canusewhatever transport(s)isconvenient Freelystructured E.g.: Skype,SMTP(email), HTTP(Web),Halo,BitTorrent 7 4 3 2 1
InternetLayering(“Protocol Stack”) } 7 4 3 2 Implementedonlyathosts, notatinteriorrouter (“dumb network”) 1
InternetLayering(“Protocol Stack”) 7 4 3 2 } Implementedeverywhere 1
InternetLayering(“Protocol Stack”) 7 4 3 2 }~SameforeachInternet“hop” }” Differentforeach Internet“hop 1
Hop-By-Hopvs.End-to-EndLayers HostAcommunicateswithHostD HostC HostA Router 1 HostD Router 2 Router 3 Router 5 HostB Router 4 HostE Router 7 Router 6
Hop-By-Hopvs.End-to-EndLayers HostAcommunicateswithHostD HostC HostA Router 1 E.g.,Wi-Fi HostD E.g.,Ethernet Router 3 Router 2 Router 5 HostB Router 4 HostE Router 7 Router 6 DifferentPhysical&LinkLayers(Layers1&2)
Hop-By-Hopvs.End-to-EndLayers HostAcommunicateswithHostD HostC HostA Router 1 HostD Router 2 Router 3 Router 5 E.g.,HTTPoverTCPoverIP HostB Router 4 HostE Router 7 Router 6 SameNetwork/Transport/ApplicationLayers(3/4/7) (RoutersignoreTransport&Applicationlayers)
Layer3:(Inter)NetworkLayer(IP) • Bridgesmultiple“subnets”to provideend-to-endinternet connectivitybetweennodes • Providesglobaladdressing • Worksacrossdifferentlink technologies 7 4 3 2 1 26
IPPacketStructure 8-bit TypeofService (TOS) 4-bit Header Length 4-bit Version 16-bitTotal Length(Bytes) 3-bit 16-bit Identification 13-bit Fragment Offset Fla gs 16-bit HeaderChecksum Specifiesthelengthoftheentire IPpacket:bytesinthisheader plusbytesinthePayload 8-bitTime to Live(TTL) 8-bitProtocol 32-bitSourceIPAddress 32-bitDestinationIPAddress Options (if any) Payload
IPPacketStructure 8-bit TypeofService (TOS) 4-bit Header Length 4-bit Version 16-bitTotal Length(Bytes) 3-bit 16-bit Identification gs 13-bit Fragment Offset 16-bit HeaderChecksum Fla Specifieshowtointerpretthe startofthePayload,whichis theheaderofaTransport ProtocolsuchasTCP orUDP 8-bitTime to Live(TTL) 8-bitProtocol 32-bitSourceIPAddress 32-bitDestinationIPAddress Options (if any) Payload
IPPacketStructure 8-bit TypeofService (TOS) 4-bit Header Length 4-bit Version 16-bitTotal Length(Bytes) 3-bit Flags 16-bit Identification 13-bit Fragment Offset 8-bitTime to Live(TTL) 8-bitProtocol 16-bit HeaderChecksum 32-bitSourceIPAddress 32-bitDestinationIPAddress Options (if any) Payload
IPPacketHeader(Continued) • TwoIPaddresses • –SourceIPaddress(32bits) • –DestinationIPaddress(32bits) • Destinationaddress • –Uniqueidentifier/locatorforthereceivinghost • –Allowseachnodetomakeforwardingdecisions • Sourceaddress • –Uniqueidentifier/locatorforthesendinghost • –Recipientcandecidewhethertoacceptpacket • –Enablesrecipienttosendareplybacktosource 31
PostalEnvelopes: (Postoffice doesn’t look at the letter inside the envelope) 32
AnalogyofIPtoPostalEnvelopes: IPsource address IPdestination address (Routers don’t lookat the payload beyond the IPheader)
IP:“BestEffort”PacketDelivery • Routersinspectdestinationaddress,locate“next hop”inforwardingtable • Address=~uniqueidentifier/locatorforthereceivinghost • Onlyprovidesa“I’llgiveitatry”deliveryservice: • Packetsmaybelost • Packetsmaybecorrupted • Packetsmaybedeliveredoutoforder source destination IPnetwork
“BestEffort”isLame! Whattodo? • It’sthejobofourTransport(layer4)protocolsto buildservicesourappsneedoutofIP’smodest layer-3service
Layer4:TransportLayer End-to-endcommunication betweenprocesses Differentservicesprovided: TCP=reliablebytestream UDP=unreliabledatagrams (Datagram=singlepacket message) 7 4 3 2 1
“BestEffort”isLame! Whattodo? • It’sthejobofourTransport(layer4)protocolsto buildservicesourappsneedoutofIP’smodest layer-3service • #1workhorse:TCP (TransmissionControlProtocol) • ServiceprovidedbyTCP: • Connectionoriented(explicitset-up/tear-down) • oEndhosts(processes)canhavemultipleconcurrentlong-lived communication • Reliable,in-order,byte-streamdelivery • oRobustdetection&retransmissionoflostdata
TCP “Bytestream”Service Process A onhost H1 Byte3 Byte2 Byte1 Byte0 Byte80 Hostsdon’teverseepacketboundaries,lost orcorruptedpackets,retransmissions,etc. Process B on host H2 Byte80
Bidirectionalcommunication: Process B onhost H2 Byte3 Byte2 Byte1 Byte0 Byte73 Therearetwoseparatebytestreams, one in eachdirection Process A on host H1 Byte73
TCPHeader Portsare associated with OS processes
(LinkLayerHeader) TCPHeader (IPHeader) Portsare associated with OS processes Sourceport Destinationport Sequencenumber Acknowledgment IPsource&destination addresses plusTCP source anddestination ports uniquelyidentifies aTCPconnection Advertisedwindow HdrLen Flags 0 Checksum Urgentpointer Options(variable) Data
TCPHeader Portsare associated with OS processes IPsource&destination addresses plusTCP source anddestination ports uniquelyidentifies aTCPconnection Someport numbersare “wellknown” / reserved e.g. port 80=HTTP
TCPHeader Starting sequence number(byte offset)ofdata carriedinthis packet
TCPHeader Starting sequence number(byte offset)ofdata carriedinthis packet Bytestreams numbered independentlyin eachdirection
TCPHeader Sourceport Destinationport Starting sequence number(byte offset)ofdata carriedinthis packet Sequencenumber Acknowledgment Advertisedwindow HdrLen Flags 0 Checksum Urgentpointer Bytestream numbered independentlyin eachdirection Options(variable) Data Sequencenumberassignedtostart ofbytestreamispickedwhen connectionbegins;doesn’t startat0 46
TCPHeader Acknowledgment givesseq#just beyond highest seq.receivedin order. Ifsendersends Nbytestream bytesstartingat seqSthen “ack”foritwillbeS+N.
SequenceNumbers Host A ISN(initialsequencenumber) Sequence ACKsequence TCPHDR TCP Data numberfromA numberfromB =1stbyte of data =next expected byte TCPHDR TCP Data Host B
TCPHeader Sourceport Destinationport Sequencenumber Usesinclude: Acknowledgment acknowledging data (“ACK”) Advertisedwindow HdrLen Flags 0 Checksum Urgentpointer settingup (“SYN”) andclosing connections (“FIN” and “RST”) Options(variable) Data
EstablishingaTCPConnection B A SYN EachhosttellsitsInitial SequenceNumber (ISN)totheotherhost. (Specsaystopickbased onlocalclock) SYN+A ACK Data Data • Three-wayhandshaketoestablishconnection • HostAsendsaSYN(open;“synchronizesequence numbers”)tohostB • HostBreturnsaSYNacknowledgment (SYN+ACK) • HostAsendsanACKtoacknowledgetheSYN+ACK 50