operating systems and networks network lecture 4: link layer … · 2018-01-27 · possible...

109
Operating Systems and Networks Network Lecture 4: Link Layer (2) Adrian Perrig Network Security Group ETH Zürich

Upload: others

Post on 15-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

OperatingSystemsandNetworks

NetworkLecture4:LinkLayer(2)

AdrianPerrigNetworkSecurityGroupETHZürich

Page 2: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

2

PendingIssues• Howtoreadthecoursetextbook?• Howtopreparefortheexamgiventhatthereisahugeamountofmaterial?

Page 3: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

3

WhereweareintheCourse• FinishingofftheLinkLayer!

– Buildsonthephysicallayertotransfer framesoverconnectedlinks

PhysicalLink

NetworkTransportApplication

Page 4: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

4

Topics1. Framing

– Delimitingstart/endofframes

2. Errordetection/correction– Handlingerrors

Done

DSL

Page 5: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

5

Topics(2)3. Retransmissions

– Handlingloss

4. MultipleAccess– ClassicEthernet,802.11

5. Switching– ModernEthernet

Page 6: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

6

Retransmissions(ARQ)(§3.3)• Twostrategiestohandleerrors:1. Detecterrorsandretransmitframe(AutomaticRepeatreQuest,

ARQ)

2. Correcterrorswithanerrorcorrectingcode

Donethis

Page 7: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

7

ContextonReliability• Whereinthestackshouldweplacereliabilityfunctions?

PhysicalLink

NetworkTransportApplication

Page 8: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

8

ContextonReliability(2)• Everywhere!Itisakeyissue

– Different layerscontributedifferently

PhysicalLink

NetworkTransportApplication

Recoveractions(correctness)

Maskerrors(performanceoptimization)

Page 9: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

9

ARQ(AutomaticRepeatreQuest)• ARQoftenusedwhenerrorsarecommonormustbecorrected– E.g.,WiFi,andTCP(later)

• Rulesatsenderandreceiver:– Receiverautomaticallyacknowledges correct frameswithanACK

– Senderautomaticallyresendsafteratimeout,untilanACKisreceived

Page 10: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

10

ARQ(2)• Normaloperation(noloss,noerror)

Frame

ACKTimeout Time

Sender Receiver

Page 11: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

11

ARQ(3)• Lossandretransmission

Frame

Timeout Time

Sender Receiver

Frame

ACK

X

Page 12: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

12

SoWhat’sTrickyAboutARQ?• Twonon-trivialissues:

– Howlongtosetthetimeout?– Howtoavoidacceptingduplicate framesasnewframes

• Wantperformanceinthecommoncaseandcorrectnessalways

Page 13: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

13

Timeouts• Timeoutshouldbe:

– Nottoobig(linkgoesidle)– Nottoosmall(spuriousresend)

• FairlyeasyonaLAN– Clearworstcase,littlevariation

• FairlydifficultovertheInternet– Muchvariation,noobviousbound– We’llrevisitthiswithTCP(later)

Page 14: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

14

Duplicates• WhathappensifanACKislost?

Frame

ACK

X

Frame

ACKTimeout

Sender Receiver

NewFrame??

Page 15: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

15

Duplicates(2)• Orthetimeoutisearly?

Frame

ACK

Frame

ACK

Timeout

Sender Receiver

NewFrame??

Page 16: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

16

SequenceNumbers• FramesandACKsmustbothcarrysequencenumbersforcorrectness

• Todistinguishthecurrentframefromthenextone,asinglebit(twonumbers)issufficient– CalledStop-and-Wait

Page 17: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

17

Stop-and-Wait• Inthenormalcase:

Time

Sender Receiver

Page 18: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

18

Stop-and-Wait(2)• Inthenormalcase:

Frame0

ACK0Timeout Time

Sender Receiver

Frame1

ACK1

Page 19: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

19

Stop-and-Wait(3)• WithACKloss:

Frame0

ACK0

X

Frame0

ACK0Timeout

Sender Receiver

It’saResend!

Page 20: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

20

Stop-and-Wait(4)• Withearlytimeout:

Frame0

ACK0

Frame0

ACK0

Timeout

Sender Receiver

It’saResend

OK…

Page 21: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

21

LimitationofStop-and-Wait• Itallowsonlyasingleframetobeoutstandingfromthesender:– GoodforLAN,inefficient forhighBD(bandwidth-delay product)

• Ex:R=1Mbps,D=50ms– Howmanyframes/sec? IfR=10Mbps?

Page 22: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

22

SlidingWindow• Generalizationofstop-and-wait

– AllowsWframestobeoutstanding– CansendWframesperRTT (=2D)

– Variousoptionsfornumbering frames/ACKsandhandlingloss• WilllookatalongwithTCP(later)

Page 23: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

Multiplexing(§2.5.3,2.5.4)• Multiplexingisthenetworkwordforthesharingofaresource

• Classicscenarioissharingalinkamongdifferentusers– TimeDivisionMultiplexing(TDM)– FrequencyDivisionMultiplexing(FDM)

23

Page 24: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

TimeDivisionMultiplexing(TDM)

• Userstaketurnsonafixedschedule

24

2 2 2 2

Page 25: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

FrequencyDivisionMultiplexing (FDM)• Putdifferentusersondifferentfrequencybands

25

Overall FDMchannel

Page 26: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

26

TDMversusFDM• InTDMausersendsatahighrateafractionofthetime;inFDM,ausersendsatalowrateallthetime

Rate

TimeFDM

TDM

Page 27: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

27

TDM/FDMUsage• Staticallydividearesource

– Suitedforcontinuous traffic,fixednumberofusers

• Widelyusedintelecommunications– TVandradiostations(FDM)– GSM(2Gcellular)allocatescallsusingTDMwithinFDM

Page 28: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

28

MultiplexingNetworkTraffic• Networktrafficisbursty

– ON/OFF sources– Loadvariesgreatlyovertime

Rate

TimeRate

Time

Page 29: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

29

MultiplexingNetworkTraffic(2)• Networktrafficisbursty

– Inefficient toalwaysallocateusertheirON needswithTDM/FDM

Rate

TimeRate

Time

R

R

Page 30: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

MultiplexingNetworkTraffic(3)• Multipleaccessschemesmultiplexusersaccordingtotheirdemands– forgainsofstatisticalmultiplexing

30

Rate

TimeRate

Time

Rate

Time

R

R

R’<2R

Twousers,eachneedR TogethertheyneedR’<2R

Page 31: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

31

MultipleAccess• Wewilllookattwokindsofmultipleaccessprotocols1. Randomized.Nodesrandomize their resourceaccessattempts

– Goodforlowloadsituations

2. Contention-free. Nodesordertheirresourceaccessattempts– Goodforhighloadorguaranteedqualityofservicesituations

Page 32: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

32

RandomizedMultipleAccess(§4.2.1-4.2.2,4.3.1-4.3.3)

• Howdonodesshareasinglelink?Whosendswhen,e.g.,inWiFI?– Explorewithasimplemodel

• Assumeno-oneisincharge;thisisadistributedsystem

Page 33: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

33

RandomizedMultipleAccess(2)• Wewillexplorerandommultipleaccesscontrol ormediumaccesscontrol (MAC)protocols– ThisisthebasisforclassicEthernet– Remember:datatraffic isbursty

Zzzz..Busy! Hohum

Page 34: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

34

ALOHANetwork• SeminalcomputernetworkconnectingtheHawaiianislandsinthelate1960s– Whenshouldnodessend?– A newprotocolwasdevisedbyNormAbramson…

Hawaii

Page 35: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

35

ALOHAProtocol• Simpleidea:

– Nodejustsendswhenithastraffic.– Iftherewasacollision(noACKreceived) thenwaitarandomtimeandresend

• That’sit!

Page 36: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

36

ALOHAProtocol(2)• Someframeswillbelost,butmanymaygetthrough…

• Goodidea?

Page 37: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

37

ALOHAProtocol(3)• Simple,decentralizedprotocolthatworkswellunderlowload!

• Notefficientunderhighload– Analysisshowsatmost18%efficiency– Improvement:divide timeintoslotsandefficiency goesupto36%

• We’lllookatotherimprovements

Page 38: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

38

ClassicEthernet• ALOHAinspiredBobMetcalfetoinventEthernetforLANsin1973– Nodesshare10Mbpscoaxialcable– Hugelypopular in1980s,1990s

:©2009IEEE

Page 39: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

39

CSMA(CarrierSenseMultipleAccess)

• ImproveALOHAbylisteningforactivitybeforewesend(Doh!)– Candoeasilywithwires,notwireless

• Sodoesthiseliminatecollisions?– Whyorwhynot?

Page 40: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

40

CSMA(2)• Stillpossibletolistenandhearnothingwhenanothernodeissendingbecauseofdelay

Page 41: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

41

CSMA/CD(withCollisionDetection)• Canreducethecostofcollisionsbydetectingthemandaborting(Jam)therestoftheframetime– Again,wecandothiswithwires

XX X X X X X XJam! Jam!

Page 42: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

42

CSMA/CDComplications• Wanteveryonewhocollidestoknowthatithappened

– Timewindow inwhichanodemayhearofacollisionis2Dseconds

X

Page 43: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

43

CSMA/CDComplications(2)• Imposeaminimumframesizethatlastsfor2D seconds

– Sonodecan’tfinishbeforecollision– Ethernetminimumframeis64bytes

X

Page 44: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

44

CSMA“Persistence”• Whatshouldanodedoifanothernodeissending?

• Idea:Waituntilitisdone,andsend

Whatnow?

Page 45: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

45

CSMA“Persistence”(2)• Problemisthatmultiplewaitingnodeswillqueueupthencollide– Moreload,moreofaproblem

Now! Now!Uhoh

Page 46: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

46

CSMA“Persistence”(3)• Intuitionforabettersolution

– IfthereareNqueuedsenders,wewanteachtosendnextwithprobability1/N

Sendp=½WhewSendp=½

Page 47: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

47

BinaryExponentialBackoff(BEB)• Cleverlyestimatestheprobability

– 1stcollision,wait0or1frametimes– 2ndcollision,waitfrom0to3times– 3rdcollision,waitfrom0to7times…

• BEBdoublesintervalforeachsuccessivecollision– Quicklygetslargeenoughtowork– Veryefficient inpractice

Page 48: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

ClassicEthernet,orIEEE802.3• MostpopularLANofthe1980s,1990s

– 10Mbpsoversharedcoaxialcable,withbasebandsignals– Multipleaccesswith“1-persistentCSMA/CDwithBEB”– Withreasonableparameters,85%efficiency (Book4.3.3)

48

Page 49: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

EthernetFrameFormat• Hasaddressestoidentifythesenderandreceiver• CRC-32forerrordetection;noACKsorretransmission• Startofframeidentifiedwithphysicallayerpreamble

49

PacketfromNetworklayer(IP)

Page 50: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

50

ModernEthernet• Basedonswitches,notmultipleaccess,butstillcalledEthernet– We’llgettoitlater

Switch

TwistedpairSwitchports

Page 51: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

51

WirelessMultipleAccess(§4.2.5,4.4)• Howdowirelessnodesshareasinglelink?(Yes,thisisWiFi!)– Buildonoursimple,wiredmodel

Send? Send?

Page 52: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

52

WirelessComplications• Wirelessismorecomplicatedthanthewiredcase(Surprise!)1. Nodesmayhavedifferentareasofcoverage– doesn’tfit

CarrierSense2. Nodescan’thearwhilesending– can’tCollisionDetect

≠CSMA/CD

Page 53: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

53

DifferentCoverageAreas• Wirelesssignalisbroadcastandreceivednearby,wherethereissufficientSNR

Page 54: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

HiddenTerminals• NodesAandCarehiddenterminals whensendingtoB

– Can’theareachother(tocoordinate)yetcollideatB– Wewanttoavoidtheinefficiency ofcollisions

54

Page 55: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

ExposedTerminals• BandCareexposedterminals whensendingtoAandD

– Canheareachotheryetdon’tcollideatreceiversAandD– Wewanttosendconcurrently toincreaseperformance

55

Page 56: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

56

NodesCan’tHearWhileSending• Withwires,detectingcollisions(andaborting)lowerstheircost

• Morewastedtimewithwireless

Time XXXXXXXXX

XXXXXXXXX

WirelessCollision

ResendX

X

WiredCollision

Resend

Page 57: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

PossibleSolution:MACA• MACAusesashorthandshakeinsteadofCSMA(Karn,1990)

– 802.11usesarefinementofMACA(later)

• Protocolrules:1. AsendernodetransmitsaRTS(Request-To-Send,withframelength)2. ThereceiverreplieswithaCTS(Clear-To-Send,withframelength)3. SendertransmitstheframewhilenodeshearingtheCTSstaysilent– CollisionsontheRTS/CTSarestillpossible,butlesslikely

57

Page 58: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

58

MACA– HiddenTerminals• AàBwithhiddenterminalC

1. AsendsRTS,toB

DCBA

Page 59: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

59

MACA– HiddenTerminals(2)• AàBwithhiddenterminalC

2. BsendsCTS,toA,andCtoo

DCBARTS

Page 60: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

60

MACA– HiddenTerminals(3)• AàBwithhiddenterminalC

2. BsendsCTS,toA,andCtoo

DCBARTS

CTSCTS

Alert!

Page 61: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

61

MACA– HiddenTerminals(4)• AàBwithhiddenterminalC

3. AsendsframewhileCdefers

FrameQuiet...

Page 62: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

62

MACA– ExposedTerminals• BàA,CàDasexposedterminals– BandCsendRTStoAandD

DCBA

Page 63: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

63

MACA– ExposedTerminals(2)• BàA,CàDasexposedterminals– AandDsendCTStoBandC

DCBARTSRTS

Page 64: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

64

MACA– ExposedTerminals(3)• BàA,CàDasexposedterminals– AandDsendCTStoBandC

DCBARTSRTS

CTSCTS

AllOKAllOK

Page 65: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

65

MACA– ExposedTerminals(4)• BàA,CàDasexposedterminals– AandDsendCTStoBandC

DCBAFrameFrame

Page 66: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

66

802.11,orWiFi• VerypopularwirelessLAN

startedinthe1990s• Clientsgetconnectivity froma

(wired)AP(AccessPoint)• It’samulti-accessproblemJ• Variousflavorshavebeen

developed overtime– Faster,morefeatures

AccessPoint

Client

ToNetwork

Page 67: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

67

802.11PhysicalLayer• Uses20/40MHzchannelsonISMbands

– 802.11b/g/non2.4GHz– 802.11a/non5GHz

• OFDMmodulation (except legacy802.11b)– Differentamplitudes/phasesforvaryingSNRs– Ratesfrom6to54Mbpspluserrorcorrection– 802.11nusesmultipleantennas;see“802.11withMultipleAntennasfor

Dummies”

Page 68: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

802.11LinkLayer• MultipleaccessusesCSMA/CA(next);RTS/CTSoptional• FramesareACKed andretransmittedwithARQ• Funkyaddressing(threeaddresses!)duetoAP• Errorsaredetectedwitha32-bitCRC• Many,manyfeatures(e.g.,encryption,powersave)

68

PacketfromNetworklayer(IP)

Page 69: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

802.11CSMA/CAforMultipleAccess• Senderavoidscollisionsbyinsertingsmallrandomgaps

– E.g.,whenbothBandCsend,Cpicksasmallergap,goesfirst

69

Time

Send?

Send?

Page 70: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

TheFutureof802.11(Guess)• LikelyubiquitousforInternetconnectivity– Greaterdiversity,fromlow- tohigh-enddevices

• Innovationinphysical layerdrivesspeed– Andpower-efficientoperationtoo

• Moreseamlessintegrationofconnectivity– Toomanualnow,andlimited(e.g.,device-to-device)

70

Page 71: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

71

Contention-FreeMultipleAccess(§4.2.3)• Anotherapproachtomultipleaccess

– Basedonturns,notrandomization

1

32

4

Page 72: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

72

IssueswithRandomMultipleAccess• CSMAisgoodunderlowload:– Grantsimmediateaccess– Littleoverhead(fewcollisions)

• Butnotsogoodunderhighload:– Highoverhead(expectcollisions)– Accesstimevaries(lucky/unlucky)

• Wewanttodobetterunderload!

Page 73: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

73

Turn-TakingMultipleAccessProtocols

• Theydefineanorderinwhichnodesgetachancetosend– Orpass,ifnotrafficatpresent

• Wejustneedsomeordering…– E.g.,TokenRing– E.g.,nodeaddresses

Page 74: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

TokenRing• Arrangenodesinaring;tokenrotates“permissiontosend”toeachnodeinturn

74

Node

Directionoftransmission

Token

Page 75: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

75

Turn-TakingAdvantages• Fixedoverheadwithnocollisions–Moreefficientunderload

• Regularchancetosendwithnounluckynodes– Predictableservice,easilyextendedtoguaranteedqualityofservice

Page 76: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

76

Turn-TakingDisadvantages• Complexity–Morethingsthatcangowrongthanrandomaccessprotocols!• E.g.,whatifthetokenislost?• Electaleaderwhomanagesthetoken,whattodoifleadercrashes?

– Higheroverheadatlowload

Page 77: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

77

Turn-TakinginPractice• Regularlytriedasanimprovementofferingbetterservice– E.g.,qualitiesofservice

• Butrandommultipleaccessishardtobeat– Simple,andusuallygoodenough– Scalesfromfewtomanynodes

Page 78: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

78

LANSwitches(§4.3.4,4.8.1-4.8.2,4.8.4)• Howdoweconnectnodeswithaswitch insteadofmultipleaccess– Usesmultiplelinks/wires– Basisofmodern(switched)Ethernet

Switch

Page 79: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

79

SwitchedEthernet• HostsarewiredtoEthernetswitcheswithtwistedpair

– Switchservestoconnect thehosts– Wiresusuallyruntoacloset

Switch

TwistedpairSwitchports

Page 80: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

80

What’sinthebox?• Rememberfromprotocollayers:

Network

LinkNetwork

Link

Link Link

Physical PhysicalHub,orrepeater

Switch

Router

Alllooklikethis:

Page 81: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

InsideaHub• Allportsarewiredtogether;moreconvenientandreliablethanasinglesharedwire

81

Page 82: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

InsideaSwitch• Usesframeaddressestoconnectinputporttotherightoutputport;multipleframesmaybeswitchedinparallel

82

...

Fabric

Page 83: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

InsideaSwitch(2)• Portmaybeusedforbothinputandoutput(full-duplex)

– Justsend,nomultipleaccessprotocol

83

...

123

4

1à 4and2à 3

Page 84: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

InsideaSwitch(3)• Needbuffersformultipleinputstosendtooneoutput

84

...

...

... ...

InputBuffer OutputBufferFabric

Input Output

Page 85: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

InsideaSwitch(4)• Sustainedoverloadwillfillbufferandleadtoframeloss

85

...

...

... ...

InputBuffer OutputBufferFabric

Input Output

XXX

Loss!

Page 86: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

86

AdvantagesofSwitches• Switchesandhubshavereplacedthesharedcableofclassic

Ethernet– Convenienttorunwirestoonelocation– Morereliable;wirecutisnotasinglepointoffailurethatishardto

find

• Switchesofferscalableperformance– E.g.,100Mbpsperportinsteadof100Mbpsforallnodesofshared

cable/hub

Page 87: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

SwitchForwarding• SwitchneedstofindtherightoutputportforthedestinationaddressintheEthernetframe.How?– Wanttolethostsbemovedaroundreadily;don’tlookatIP

87

...

...

... ...

Source

Destination

EthernetFrame

Page 88: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

88

BackwardLearning• Switchforwardsframeswithaport/addresstableasfollows:1. Tofillthetable,itlooksatthesourceaddressofinput

frames2. Toforward,itsendstotheport,orelsebroadcaststo

allports

Page 89: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

89

BackwardLearning(2)• 1:AsendstoD

Switch

D

Address PortABCD

Page 90: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

90

BackwardLearning(3)• 2:DsendstoA

Switch

D

Address PortA 1BCD

Page 91: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

91

BackwardLearning(4)• 3:AsendstoD

Switch

D

Address PortA 1BCD 4

Page 92: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

92

BackwardLearning(5)• 3:AsendstoD

Switch

D

Address PortA 1BCD 4

Page 93: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

LearningwithMultipleSwitches• Justworkswithmultipleswitchesandamixofhubsassumingnoloops,e.g.,AsendstoDthenDsendstoA

93

Switch

Page 94: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

94

SwitchSpanningTree(§4.8.3)• Howcanweconnectswitchesinanytopologysotheyjustwork?

Loops– yikes!

Page 95: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

95

Problem– ForwardingLoops• Mayhavealoopinthetopology

– Redundancy incaseoffailures– Orasimplemistake

• WantLANswitchesto“justwork”– Plug-and-play,nochangestohosts– Butloopscauseaproblem…

RedundantLinks

Page 96: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

96

ForwardingLoops(2)• SupposethenetworkisstartedandAsendstoF.Whathappens?

Left/Right

A B

C

D

E F

Page 97: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

97

ForwardingLoops(3)• SupposethenetworkisstartedandAsendstoF.Whathappens?– Aà Cà B,D-left,D-right– D-leftà C-right,E,F– D-rightà C-left,E,F– C-rightà D-left,A,B– C-leftà D-right,A,B– D-leftà…– D-rightà …

Left/Right

A B

C

D

E F

Page 98: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

98

SpanningTreeSolution• Switchescollectivelyfindaspanningtreeforthetopology– Asubsetoflinksthatisatree(noloops)andreachesallswitches

– Switchesforwardasnormalbutonlyonspanningtree– Broadcastswillgouptotherootofthetreeanddownallthebranches

Page 99: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

SpanningTree(2)

99

Topology OneST AnotherST

Root

Page 100: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

100

Radia Perlman(1951–)• Keyearlyworkonroutingprotocols– RoutingintheARPANET– SpanningTreeforswitches(next)– Link-staterouting(later)

• Nowfocusedonnetworksecurity

Page 101: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

101

SpanningTreeAlgorithm• Rulesofthedistributedgame:

– Allswitchesrunthesamealgorithm– Theystartwithnoinformation– Operate inparallel andsendmessages– Alwayssearchforthebestsolution

• Ensuresahighlyrobustsolution– Anytopology,withnoconfiguration– Adaptstolink/switch failures,…

Page 102: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

102

SpanningTreeAlgorithm(2)• Outline:

1. Electarootnodeofthetree(switchwiththelowestaddress)

2. Growtreeasshortestdistancesfromtheroot(usinglowestaddresstobreakdistanceties)

3. Turnoffportsforforwardingiftheyarenotonthespanningtree

Page 103: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

SpanningTreeAlgorithm(3)• Details:

– Eachswitchinitiallybelievesitistherootofthetree– Eachswitchsendsperiodic updatestoneighborswith:

• Itsaddress,addressoftheroot,anddistance(inhops)toroot– Switchesfavorsportswithshorterdistancestolowestroot

• Useslowestaddressasatiefordistances

103

C

Hi,I’mC,therootisA,it’s2 hopsaway or(C,A,2)

Page 104: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

104

SpanningTreeExample• 1st round,sending:

– Asends(A,A,0)tosayitisroot– B,C,D,E,andFdolikewise

• 1st round,receiving:– Astillthinksisit(A,A,0)– Bstillthinks(B,B,0)– Cupdatesto(C,A,1)– Dupdatesto(D,C,1)– Eupdatesto(E,A,1)– Fupdatesto(F,B,1)

A,A,0 B,B,0

C,C,0

D,D,0

E,E,0 F,F,0

Page 105: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

105

SpanningTreeExample(2)• 2nd round,sending

– Nodessendtheirupdatedstate• 2nd roundreceiving:

– Aremains(A,A,0)– Bupdatesto(B,A,2)viaC– Cremains(C,A,1)– Dupdatesto(D,A,2)viaC– Eremains(E,A,1)– Fremains(F,B,1)

A,A,0 B,B,0

C,A,1

D,C,1

E,A,1 F,B,1

Page 106: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

106

SpanningTreeExample(3)• 3rd round,sending

– Nodessendtheirupdatedstate• 3rd roundreceiving:

– Aremains(A,A,0)– Bremains(B,A,2)viaC– Cremains(C,A,1)– Dremains(D,A,2)viaC-left– Eremains(E,A,1)– Fupdatesto(F,A,3)viaB

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,B,1

Page 107: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

107

SpanningTreeExample(4)• 4th round

– Steady-statehasbeenreached– Nodesturnoffforwarding thatisnotonthespanningtree

• Algorithmcontinuestorun– Adaptsbytimingoutinformation– E.g.,ifAfails,othernodesforgetit,andBwillbecomethenewroot

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Page 108: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

108

SpanningTreeExample(5)• ForwardingproceedsasusualontheST• InitiallyDsendstoF:

• AndFsendsbacktoD:

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Page 109: Operating Systems and Networks Network Lecture 4: Link Layer … · 2018-01-27 · Possible Solution: MACA • MACA uses a short handshake instead of CSMA (Karn, 1990) – 802.11

109

SpanningTreeExample(6)• ForwardingproceedsasusualontheST• InitiallyDsendstoF:

– Dà C-left– Cà A,B– Aà E– Bà F

• AndFsendsbacktoD:– Fà B– Bà C– Cà D(hm,notsuchagreatroute)

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3