computer networks - university of washington€¦ · computer networks 14 4 applicaon – programs...
TRANSCRIPT
ComputerNetworksShyamGollakota
ComputerNetworks 2
ProtocolsandLayers• Protocolsandlayeringisthemainstructuringmethodusedtodivideupnetworkfunc>onality– Eachinstanceofaprotocoltalksvirtuallytoitspeerusingtheprotocol
– Eachinstanceofaprotocolusesonlytheservicesofthelowerlayer
ProtocolsandLayers(3)• Protocolsarehorizontal,layersarever>cal
ComputerNetworks 3
X
YY
XInstanceofprotocolX
Peerinstance
Node1 Node2
Lowerlayerinstance(ofprotocolY)
ProtocolX
ServiceprovidedbyProtocolY
ProtocolsandLayers(4)• Setofprotocolsinuseiscalledaprotocolstack
ComputerNetworks 4
ComputerNetworks 5
ProtocolsandLayers(6)• Protocolsyou’veprobablyheardof:
– TCP,IP,802.11,Ethernet,HTTP,SSL,DNS,…andmanymore
• Anexampleprotocolstack– UsedbyawebbrowseronahostthatiswirelesslyconnectedtotheInternet
HTTP
TCP
IP
802.11
Browser
ComputerNetworks 6
Encapsula>on• Encapsula>onisthemechanismusedtoeffectprotocollayering– Lowerlayerwrapshigherlayercontent,addingitsowninforma>ontomakeanewmessagefordelivery
– Likesendingale[erinanenvelope;postalservicedoesn’tlookinside
Encapsula>on(3)• Message“onthewire”beginstolooklikeanonion
– Lowerlayersareoutermost
ComputerNetworks 7
HTTP
TCP
IP
802.11
HTTP
TCP HTTP
TCP HTTPIP
TCP HTTPIP802.11
Encapsula>on(4)
ComputerNetworks 8
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
AdvantageofLayering• Informa>onhidingandreuse
ComputerNetworks 9
HTTP
Browser
HTTP
Server
HTTP
Browser
HTTP
Server
or
AdvantageofLayering(2)• Informa>onhidingandreuse
ComputerNetworks 10
HTTP
TCP
IP
802.11
Browser
HTTP
TCP
IP
802.11
Server
HTTP
TCP
IP
Ethernet
Browser
HTTP
TCP
IP
Ethernet
Server
or
AdvantageofLayering(3)• Usinginforma>onhidingtoconnectdifferentsystems
ComputerNetworks 11
HTTP
TCP
IP
802.11
Browser
HTTP
TCP
IPEthernet
Server
AdvantageofLayering(4)• Usinginforma>onhidingtoconnectdifferentsystems
ComputerNetworks 12
HTTP
TCP
IP
802.11
Browser
IP
802.11
IP
Ethernet
HTTP
TCP
IPEthernet
Server
IP TCP HTTP
802.11 IP TCP HTTP Ethernet IP TCP HTTP
ComputerNetworks 13
DisadvantageofLayering• ??
InternetReferenceModel• Afourlayermodelbasedonexperience;omitssomeOSIlayersandusesIPasthenetworklayer.
ComputerNetworks 14
4Applica>on–Programsthatusenetworkservice3Transport–Providesend-to-enddatadelivery2Internet –Sendpacketsovermul>plenetworks
1Link –Sendframesoveralink
InternetReferenceModel(3)• IPisthe“narrowwaist”oftheInternet
– Supportsmanydifferentlinksbelowandappsabove
ComputerNetworks 15
4Applica>on3Transport
2Internet
1Link Ethernet802.11
IP
TCP UDP
HTTPSMTP RTP DNS
3GDSLCable
ComputerNetworks 16
Layer-basedNames(2)• Fordevicesinthenetwork:
NetworkLink
NetworkLink
Link Link
Physical PhysicalRepeater(orhub)
Switch(orbridge)
Router
ComputerNetworks 17
Layer-basedNames(3)• Fordevicesinthenetwork:
Proxyormiddleboxorgateway
NetworkLink
NetworkLink
AppTransport
AppTransport
Buttheyalllooklikethis!
18
ScopeofthePhysicalLayer• Concernshowsignalsareusedtotransfermessagebitsoveralink– Wiresetc.carryanalogsignals– Wewanttosenddigitalbits
…1011010110…
Signal
SimpleLinkModel• We’llendwithanabstrac>onofaphysicalchannel
– Rate(orbandwidth,capacity,speed)inbits/second– Delayinseconds,relatedtolength
• Otherimportantproper>es:– Whetherthechannelisbroadcast,anditserrorrate
CSE461UniversityofWashington 19
DelayD,RateR
Message
MessageLatency• Latencyisthedelaytosendamessageoveralink
– Transmissiondelay:>metoputM-bitmessage“onthewire”
– Propaga>ondelay:>meforbitstopropagateacrossthewire
– Combiningthetwotermswehave:
CSE461UniversityofWashington 20
MessageLatency(2)• Latencyisthedelaytosendamessageoveralink
– Transmissiondelay:>metoputM-bitmessage“onthewire”
T-delay=M(bits)/Rate(bits/sec)=M/Rseconds
– Propaga>ondelay:>meforbitstopropagateacrossthewire
P-delay=Length/speedofsignals=Length/⅔c=Dseconds
– Combiningthetwotermswehave:L=M/R+D
CSE461UniversityofWashington 21
CSE461UniversityofWashington 22
MetricUnits• Themainprefixesweuse:
• Usepowersof10forrates,2forstorage– 1Mbps=1,000,000bps,1KB=210bytes
• “B”isforbytes,“b”isforbits
Prefix Exp. prefix exp. K(ilo) 103 m(illi) 10-3
M(ega) 106 µ(micro) 10-6
G(iga) 109 n(ano) 10-9
CSE461UniversityofWashington 23
LatencyExamples(2)• “Dialup”withatelephonemodem:
D=5ms,R=56kbps,M=1250bytes
L=5ms+(1250x8)/(56x103)sec=184ms!
• Broadbandcross-countrylink:D=50ms,R=10Mbps,M=1250bytes
L=50ms+(1250x8)/(10x106)sec=51ms
• Alonglinkoraslowratemeanshighlatency– Open,onedelaycomponentdominates
CSE461UniversityofWashington 24
Bandwidth-DelayProduct• Messagestakespaceonthewire!
• Theamountofdatainflightisthebandwidth-delay(BD)product
BD=RxD– Measureinbits,orinmessages– SmallforLANs,bigfor“longfat”pipes
CSE461UniversityofWashington 25
Bandwidth-DelayExample(2)• Fiberathome,cross-country
R=40Mbps,D=50msBD=40x106x50x10-3bits
=2000Kbit=250KB
• That’squitealotofdata“inthenetwork”!
110101000010111010101001011
weightsofharmonicfrequenciesSignalover>me
=
FrequencyRepresenta>on• Asignalover>mecanberepresentedbyitsfrequencycomponents(calledFourieranalysis)
26am
plitu
de
Lost!
EffectofLessBandwidth• Fewerfrequencies(=lessbandwidth)degradessignal
27
Lost!
27
Lost!Bandwidth
SignalsoveraWire(2)• Example:
28
2:A[enua>on:
3:Bandwidth:
4:Noise:
Sentsignal
CSE461UniversityofWashington 29
SignalsoverWireless• Signalstransmi[edonacarrierfrequency,likefiber
• Travelatspeedoflight,spreadoutanda[enuatefasterthan1/dist2
• Mul>plesignalsonthesamefrequencyinterfereatareceiver
30
SignalsoverWireless(5)• Variousothereffectstoo!
– Wirelesspropaga>oniscomplex,dependsonenvironment
• Somekeyeffectsarehighlyfrequencydependent,– E.g.,mul>pathatmicrowavefrequencies
WirelessMul>path• Signalsbounceoffobjectsandtakemul>plepaths
– Somefrequenciesa[enuatedatreceiver,varieswithloca>on– Messesupsignal;handledwithsophis>catedmethods(§2.5.3)
31
32
Wireless• Senderradiatessignaloveraregion
– Inmanydirec>ons,unlikeawire,topoten>allymanyreceivers
– Nearbysignals(samefreq.)interfereatareceiver;needtocoordinateuse
33
WiFi
WiFi
Wireless(2)• Microwave,e.g.,3G,andunlicensed(ISM)frequencies,e.g.,WiFi,arewidelyusedforcomputernetworking
34
802.11b/g/n
802.11a/g/n
35
Topic• We’vetalkedaboutsignalsrepresen>ngbits.How,exactly?– Thisisthetopicofmodula>on
…1011010110…
Signal
ASimpleModula>on• Letahighvoltage(+V)representa1,andlowvoltage(-V)representa0– ThisiscalledNRZ(Non-ReturntoZero)
36
Bits
NRZ
0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0
+V
-V
ASimpleModula>on(2)• Letahighvoltage(+V)representa1,andlowvoltage(-V)representa0– ThisiscalledNRZ(Non-ReturntoZero)
37
Bits
NRZ
0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0
+V
-V
Modula>on
38
NRZsignalofbits
Amplitudeshipkeying
Frequencyshipkeying
Phaseshipkeying
39
Topic• Howrapidlycanwesendinforma>onoveralink?– Nyquistlimit(~1924)»– Shannoncapacity(1948)»
• Prac>calsystemsaredevisedtoapproachtheselimits
40
KeyChannelProper>es• Thebandwidth(B),signalstrength(S),andnoisestrength(N)– Blimitstherateoftransi>ons– SandNlimithowmanysignallevelswecandis>nguish
BandwidthB SignalS,NoiseN
41
NyquistLimit• Themaximumsymbolrateis2B
• ThusifthereareVsignallevels,ignoringnoise,themaximumbitrateis: R=2Blog2Vbits/sec
1010101010101010101
42
ClaudeShannon(1916-2001)• Fatherofinforma>ontheory
– “AMathema>calTheoryofCommunica>on”,1948
• Fundamentalcontribu>onstodigitalcomputers,security,andcommunica>ons
Credit:CourtesyMITMuseum
Electromechanicalmousethat“solves”mazes!
ShannonCapacity• Howmanylevelswecandis>nguishdependsonS/N
– OrSNR,theSignal-to-NoiseRa>o– Notenoiseisrandom,hencesomeerrors
• SNRgivenonalog-scaleindeciBels:– SNRdB=10log10(S/N)
43
0
1
2
3
N
S+N
44
ShannonCapacity(2)• Shannonlimitisforcapacity(C),themaximuminforma>oncarryingrateofthechannel:
C=Blog2(1+S/(BN))bits/sec
Wired/WirelessPerspec>ve• Wires,andFiber
– EngineerlinktohaverequisiteSNRandB→ Canfixdatarate
• Wireless– GivenB,butSNRvariesgreatly,e.g.,upto60dB!→ Can’tdesignforworstcase,mustadaptdatarate
45
Wired/WirelessPerspec>ve(2)• Wires,andFiber
– EngineerlinktohaverequisiteSNRandB→ Canfixdatarate
• Wireless– GivenB,butSNRvariesgreatly,e.g.,upto60dB!→ Can’tdesignforworstcase,mustadaptdatarate
46
EngineerSNRfordatarate
AdaptdataratetoSNR
Puzngitalltogether–DSL• DSL(DigitalSubscriberLine)iswidelyusedforbroadband;manyvariantsoffer10sofMbps– Reusestwistedpairtelephonelinetothehome;ithasupto~2MHzofbandwidthbutusesonlythelowest~4kHz
47
DSL(2)• DSLusespassbandmodula>on(calledOFDM)
– Separatebandsforupstreamanddownstream(larger)– Modula>onvariesbothamplitudeandphase(calledQAM)– HighSNR,upto15bits/symbol,lowSNRonly1bit/symbol
48
Upstream Downstream
26–138kHz
0-4kHz 143kHzto1.1MHz
Telephone
Freq.
Voice Upto1Mbps Upto12Mbps
ADSL2:
CSE461UniversityofWashington 49
Topic• Somebitswillbereceivedinerrordue
tonoise.Whatcanwedo?– Detecterrorswithcodes»– Correcterrorswithcodes»– Retransmitlostframes
• Reliabilityisaconcernthatcutsacrossthelayers–we’llseeitagain
Later
Problem–Noisemayflipreceivedbits
CSE461UniversityofWashington 50
Signal0 0 0 0
11 10
0 0 0 011 1
0
0 0 0 011 1
0
SlightlyNoisy
Verynoisy
CSE461UniversityofWashington 51
Approach–AddRedundancy• Errordetec>oncodes
– Addcheckbitstothemessagebitstoletsomeerrorsbedetected
• Errorcorrec>oncodes– Addmorecheckbitstoletsomeerrorsbecorrected
• Keyissueisnowtostructurethecodetodetectmanyerrorswithfewcheckbitsandmodestcomputa>on
CSE461UniversityofWashington 52
Mo>va>ngExample• Asimplecodetohandleerrors:
– Sendtwocopies!Errorifdifferent.
• Howgoodisthiscode?– Howmanyerrorscanitdetect/correct?– Howmanyerrorswillmakeitfail?
CSE461UniversityofWashington 53
Mo>va>ngExample(2)• Wewanttohandlemoreerrorswithlessoverhead– Willlookatbe[ercodes;theyareappliedmathema>cs
– But,theycan’thandleallerrors– Andtheyfocusonaccidentalerrors(willlookatsecurehasheslater)
CSE461UniversityofWashington 54
UsingErrorCodes• CodewordconsistsofDdataplusR
checkbits(=systema>cblockcode)
• Sender:– ComputeRcheckbitsbasedontheDdatabits;sendthecodewordofD+Rbits
D R=fn(D)Databits Checkbits
CSE461UniversityofWashington 55
UsingErrorCodes(2)• Receiver:
– ReceiveD+Rbitswithunknownerrors– RecomputeRcheckbitsbasedontheDdatabits;errorifRdoesn’tmatchR’
D R’Databits Checkbits
R=fn(D)=?
CSE461UniversityofWashington 56
Intui>onforErrorCodes• ForDdatabits,Rcheckbits:
• Randomlychosencodewordisunlikelytobecorrect;overheadislow
AllcodewordsCorrect
codewords
CSE461UniversityofWashington 57
R.W.Hamming(1915-1998)• Muchearlyworkoncodes:
– “ErrorDetec>ngandErrorCorrec>ngCodes”,BSTJ,1950
• Seealso:– “YouandYourResearch”,1986
Source:IEEEGHN,©2009IEEE
CSE461UniversityofWashington 58
HammingDistance• DistanceisthenumberofbitflipsneededtochangeD1toD2
• Hammingdistanceofacodeistheminimumdistancebetweenanypairofcodewords
CSE461UniversityofWashington 59
HammingDistance(2)• Errordetec>on:
– Foracodeofdistanced+1,uptoderrorswillalwaysbedetected
CSE461UniversityofWashington 60
HammingDistance(3)• Errorcorrec>on:
– Foracodeofdistance2d+1,uptoderrorscanalwaysbecorrectedbymappingtotheclosestcodeword
CSE461UniversityofWashington 61
Topic• Somebitsmaybereceivedinerror
duetonoise.Howdowedetectthis?– Parity»– Checksums»– CRCs»
• Detec>onwillletusfixtheerror,forexample,byretransmission(later).
CSE461UniversityofWashington 62
SimpleErrorDetec>on–ParityBit• TakeDdatabits,add1checkbitthatisthesumoftheDbits– Sumismodulo2orXOR
CSE461UniversityofWashington 63
ParityBit(2)• Howwelldoesparitywork?
– Whatisthedistanceofthecode?– Howmanyerrorswillitdetect/correct?
• Whataboutlargererrors?
CSE461UniversityofWashington 64
Checksums• Idea:sumupdatainN-bitwords
– Widelyusedin,e.g.,TCP/IP/UDP
• Strongerprotec>onthanparity
1500bytes 16bits
CSE461UniversityofWashington 65
InternetChecksum• Sumisdefinedin1scomplementarithme>c(mustaddbackcarries)– Andit’sthenega>vesum
• “Thechecksumfieldisthe16bitone'scomplementoftheone'scomplementsumofall16bitwords…”–RFC791
CSE461UniversityofWashington 66
InternetChecksum(2)Sending:1. Arrangedatain16-bitwords
2. Putzeroinchecksumposi>on,add
3. Addanycarryoverbacktoget16bits
4. Negate(complement)togetsum
0001 f203 f4f5 f6f7
+(0000) ------ 2ddf0
ddf0
+ 2 ------ ddf2
220d
CSE461UniversityofWashington 67
InternetChecksum(3)Sending:1. Arrangedatain16-bitwords2. Putzeroinchecksumposi>on,add
3. Addanycarryoverbacktoget16bits
4. Negate(complement)togetsum
0001 f203 f4f5 f6f7
+(0000) ------ 2ddf0
ddf0
+ 2 ------ ddf2
220d
CSE461UniversityofWashington 68
InternetChecksum(4)Receiving:1. Arrangedatain16-bitwords2. Checksumwillbenon-zero,add
3. Addanycarryoverbacktoget16bits
4. Negatetheresultandcheckitis0
0001 f203 f4f5 f6f7
+ 220d ------ 2fffd
fffd
+ 2 ------ ffff
0000
CSE461UniversityofWashington 69
InternetChecksum(5)Receiving:1. Arrangedatain16-bitwords2. Checksumwillbenon-zero,add
3. Addanycarryoverbacktoget16bits
4. Negatetheresultandcheckitis0
0001 f203 f4f5 f6f7
+ 220d ------ 2fffd
fffd
+ 2 ------ ffff
0000
CSE461UniversityofWashington 70
InternetChecksum(6)• Howwelldoesthechecksumwork?
– Whatisthedistanceofthecode?– Howmanyerrorswillitdetect/correct?
• Whataboutlargererrors?
CSE461UniversityofWashington 71
CyclicRedundancyCheck(CRC)• Evenstrongerprotec>on
– Givenndatabits,generatekcheckbitssuchthatthen+kbitsareevenlydivisiblebyageneratorC
• Examplewithnumbers:– n=302,k=onedigit,C=3
CSE461UniversityofWashington 72
CRCs(2)• Thecatch:
– It’sbasedonmathema>csoffinitefields,inwhich“numbers”representpolynomials
– e.g,10011010isx7+x4+x3+x1
• Whatthismeans:– Weworkwithbinaryvaluesandoperateusingmodulo2arithme>c
CSE461UniversityofWashington 73
CRCs(3)• SendProcedure:1. Extendthendatabitswithkzeros2. DividebythegeneratorvalueC3. Keepremainder,ignorequo>ent4. Adjustkcheckbitsbyremainder
• ReceiveProcedure:1. Divideandcheckforzeroremainder
CRCs(4)
CSE461UniversityofWashington 74
Databits:1101011111
Checkbits:C(x)=x4+x1+1C=10011
k=4
100111101011111
CRCs(5)
CSE461UniversityofWashington 75
CSE461UniversityofWashington 76
CRCs(6)• Protec>ondependongenerator
– StandardCRC-32is100000100110000010001110110110111
• Proper>es:– HD=4,detectsuptotriplebiterrors– Alsooddnumberoferrors– Andburstsofuptokbitsinerror– Notvulnerabletosystema>cerrorslikechecksums
CSE461UniversityofWashington 77
ErrorDetec>oninPrac>ce• CRCsarewidelyusedonlinks
– Ethernet,802.11,ADSL,Cable…• ChecksumusedinInternet
– IP,TCP,UDP…butitisweak• Parity
– Isli[leused
CSE461UniversityofWashington 78
Topic• Twostrategiestohandleerrors:1. Detecterrorsandretransmitframe
(Automa>cRepeatreQuest,ARQ)
2. Correcterrorswithanerrorcorrec>ngcode
Donethis
CSE461UniversityofWashington 79
ContextonReliability• Whereinthestackshouldweplacereliabilityfunc>ons?
PhysicalLink
NetworkTransportApplica>on
CSE461UniversityofWashington 80
ContextonReliability(2)• Everywhere!Itisakeyissue
– Differentlayerscontributedifferently
PhysicalLink
NetworkTransportApplica>on
Recoverac>ons(correctness)
Maskerrors(performanceop>miza>on)
CSE461UniversityofWashington 81
ARQ• ARQopenusedwhenerrorsarecommonormustbecorrected– E.g.,WiFi,andTCP(later)
• Rulesatsenderandreceiver:– Receiverautoma>callyacknowledgescorrectframeswithanACK
– Senderautoma>callyresendsapera>meout,un>lanACKisreceived
CSE461UniversityofWashington 82
ARQ(2)• Normalopera>on(noloss)
Frame
ACKTimeout Time
Sender Receiver
CSE461UniversityofWashington 83
ARQ(3)• Lossandretransmission
Frame
Timeout Time
Sender Receiver
Frame
ACK
X
CSE461UniversityofWashington 84
SoWhat’sTrickyAboutARQ?• Twonon-trivialissues:
– Howlongtosetthe>meout?»– Howtoavoidaccep>ngduplicateframesasnewframes»
• Wantperformanceinthecommoncaseandcorrectnessalways
CSE461UniversityofWashington 85
Timeouts• Timeoutshouldbe:
– Nottoobig(linkgoesidle)– Nottoosmall(spuriousresend)
• FairlyeasyonaLAN– Clearworstcase,li[levaria>on
• FairlydifficultovertheInternet– Muchvaria>on,noobviousbound– We’llrevisitthiswithTCP(later)
CSE461UniversityofWashington 86
Duplicates• WhathappensifanACKislost?
X
Frame
ACKTimeout
Sender Receiver
NewFrame?
CSE461UniversityofWashington 87
Duplicates(2)• WhathappensifanACKislost?
Frame
ACK
X
Frame
ACKTimeout
Sender Receiver
NewFrame?
NewFrame??
CSE461UniversityofWashington 88
Duplicates(3)• Orthe>meoutisearly?
ACK
Frame
Timeout
Sender Receiver
NewFrame?
CSE461UniversityofWashington 89
Duplicates(4)• Orthe>meoutisearly?
Frame
ACK
Frame
ACK
Timeout
Sender Receiver
NewFrame?
NewFrame??
CSE461UniversityofWashington 90
SequenceNumbers• FramesandACKsmustbothcarrysequencenumbersforcorrectness
• Todis>nguishthecurrentframefromthenextone,asinglebit(twonumbers)issufficient– CalledStop-and-Wait
CSE461UniversityofWashington 91
Stop-and-Wait• Inthenormalcase:
Time
Sender Receiver
CSE461UniversityofWashington 92
Stop-and-Wait(2)• Inthenormalcase:
Frame0
ACK0Timeout Time
Sender Receiver
Frame1
ACK1
CSE461UniversityofWashington 93
Stop-and-Wait(3)• WithACKloss:
X
Frame0
ACK0Timeout
Sender Receiver
NewFrame?
CSE461UniversityofWashington 94
Stop-and-Wait(4)• WithACKloss:
Frame0
ACK0
X
Frame0
ACK0Timeout
Sender Receiver
NewFrame?
It’saResend!
CSE461UniversityofWashington 95
Stop-and-Wait(5)• Withearly>meout:
ACK0
Frame0
Timeout
Sender Receiver
NewFrame?
CSE461UniversityofWashington 96
Stop-and-Wait(6)• Withearly>meout:
Frame0
ACK0
Frame0
ACK0
Timeout
Sender Receiver
NewFrame?
It’saResend
OK…
CSE461UniversityofWashington 97
Limita>onofStop-and-Wait• Itallowsonlyasingleframetobeoutstandingfromthesender:– GoodforLAN,notefficientforhighBD
• Ex:R=1Mbps,D=50ms– Howmanyframes/sec?IfR=10Mbps?
CSE461UniversityofWashington 98
SlidingWindow• Generaliza>onofstop-and-wait
– AllowsWframestobeoutstanding– CansendWframesperRTT(=2D)
– Variousop>onsfornumberingframes/ACKsandhandlingloss
• WilllookatalongwithTCP(later)