/
1 EE 1 EE

1 EE - PowerPoint Presentation

lois-ondreau
lois-ondreau . @lois-ondreau
Follow
365 views
Uploaded On 2015-12-03

1 EE - PPT Presentation

122 Link Layer Ion Stoica TAs Junda Liu DK Moon David Zats http insteecsberkeleyeduee122 Materials with thanks to Vern Paxson Jennifer Rexford and colleagues at UC Berkeley ID: 213011

bit frame data clock frame bit clock data channel access node collision transmit time nodes detection csma receiver ethernet

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "1 EE" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

1

EE 122: Link Layer

Ion StoicaTAs: Junda Liu, DK Moon, David Zatshttp://inst.eecs.berkeley.edu/~ee122/(Materials with thanks to Vern Paxson, Jennifer Rexford,and colleagues at UC Berkeley)Slide2

2

Goals of Today’s LectureLink-layer services

Encoding, framing, error detection, transmission controlError correction and flow controlArbitrating access to a shared mediumChannel partitioningTaking turnsRandom accessCarrier senseCollision detectionSlide3

3

Message, Segment, Packet, and Frame

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

Ethernet

frame

Ethernet frame

SONET frameSlide4

4

Adaptors Communicating

Link layer implemented in adaptor (network interface card; NIC)Ethernet card, 802.11 cardSending side:Encapsulates datagram in a frameDetermines local addressing, adds error checking, controls transmissionReceiving sideRecognizes arrival, looks for errors, possibly acknowledgesExtracts datagram and passes to receiving node

sending

node

frame

receiving

node

datagram

frame

adapter

adapter

link layer protocolSlide5

5

Link-Layer Services

EncodingRepresenting the 0s and 1sFramingEncapsulating packet into frame, adding header, trailerUsing MAC addresses rather than IP addressesError detectionErrors caused by signal attenuation, noise Receiver detects presence, may ask for repeat (ARQ)Resolving contentionDeciding who gets to transmit when multiple senders want to use a shared media

Flow

control (pacing between sender & receiver)Slide6

6

Encoding

Signals propagate over physical linksHow do we represent the bits?Physical layer issueSimplify some electrical engineering detailsAssume two discrete signals, high and lowE.g., could correspond to two different voltagesBasic approachHigh for a 1, low for a 0How hard can it be?Sender & receiver agree: what’s “high”, what’s “low”And: when to read the signalSlide7

7

Non-Return to Zero (NRZ)

1  high signal; 0  low signal(Actual signals are of course not so sharp)How does receiver know where one bit stops and another begins?0

0

1

0

1

0

1

1

0

NRZ

(non-return to zero)

Clock

Receiver reads the signal on the clock’s

leading

edge

Sender begins to transmit signal on clock’s

falling

edgeSlide8

8

Clock Coordination

How do the sender and receiver agree on the running of the clock?Problem: without explicit synchronization, receiver’s clock can drift with respect to sender’s0

0

1

0

1

0

1

1

0

NRZ

ClockSlide9

9

Clock Drift

001

0

1

0

1

1

0

NRZ

Clock

Sender’s Clock

Receiver’s Clock …

… can

drift

Here we

slip a bit

, reading a 0 on leading edge rather than the correct 1Slide10

10

Clock RecoveryTo avoid clock drift, we use the signal itself to coordinate

Whenever see a transition (0  1 or 1  0) we know that corresponds to sender clock’s trailing edgeSo pull our clock in phase towards itProblem with NRZ: long strings of 0s or 1sQuite commonNo transitions from low-to-high, or high-to-lowClock recovery fails and receiver’s clock begins to driftSlide11

11

Non-Return to Zero Inverted (NRZI)

1  make transition; 0  stay at same levelFixes previous problem for long sequences of 1’sBut not for 0’s0

0

1

0

1

0

1

1

0

Clock

(read on

falling edge)

NRZI

(non-return to zero

inverted)Slide12

12

Manchester Encoding

1  high-to-low transition; 0  low-to-high transitionAddresses clock recovery problemsBut: physical signaling must be twice as fastTo support 2 transitions/cycle  Efficiency of 50%

0

0

1

0

1

0

1

1

0

Clock

(read on each

rising edge)

ManchesterSlide13

13

4-bit/5-bit (100Mb/s Ethernet)

Goal: address inefficiency of Manchester encoding, while avoiding long periods of no transitionSolution:Use 5 bits to encode every sequence of four bits such that No 5 bit code has more than one leading 0 or two trailing 0’sUse NRZI to then encode the 5 bit codes Efficiency is 80%

0000 11110

0001 01001

0010 10100

0011 10101

0100 01010

0101 01011

0110 01110

0111 01111

1000 10010

1001 10011

1010 10110

1011 10111

1100 11010

1101 11011

1110 11100

1111 11101

4-bit 5-bit

4-bit 5-bitSlide14

14

5 Minute Break

Questions Before We Proceed?Slide15

15

Framing

Specify how blocks of data are transmitted between two nodes connected on the same physical mediaService provided by the data link layerImplemented by the network adaptorChallengesDecide when a frame starts & endsHow hard can that be?Slide16

16

Simple Approach to Framing: Counting

Sender: begin frame with byte(s) giving lengthReceiver: extract this length and countHow can this go wrong?On occasion, the count gets corrupted

53

Frame

content

53 bytes of data

21

Frame

content

21 bytes of data

58

Frame

content

21

Frame

content

58 bytes of data

misdelivered

94

Bogus new frame length;

desynchronizationSlide17

17

Framing: Sentinels

Delineate frame with special patternBoth can be the same, e.g., 01111110Problem: what if sentinel occurs within frame?Solution: escape the special charactersSender: insert a 0 after five 1s in data portionReceiver: when it sees five 1s makes a decision on next two bits:If next bit 0 (this is a stuffed bit), remove it

If next bit, look at next bit

If 0, this is end of frame (receiver has seen 0111110)

If 1 this is an error, discard frame (receiver as seen 01111111)

01111110

01111110

Frame

contentSlide18

Example

01111110 0111111011111011111001 01111110

1801111110

011111

0

1011111

0

011111

0

001

01111110

01111110

0111111011111011111001

01111110

Five 1s

insert a 0

Sender:

s

tuff bits

Five 1s, and next two

bits 10

end/start frame

Five 1s and next

bit 0

remove it

Receiver:

i

dentify &

r

emove

s

tuffed bitsSlide19

19

Clock-Based Framing (SONET)

SONET (Synchronous Optical NETwork)SONET endpoints maintain clock synchronizationFrames have fixed size (e.g., 125 sec)No ambiguity about start & stop of frameBut may be wastefulNRZ encodingTo avoid long sequences of 0’s or 1’s payload is XOR-ed with special 127-bit pattern w/ many 0-1/1-0 transitionsWhat problem can that lead to?Slide20

20

Error Detection

Errors are unavoidableElectrical interference, thermal noise, etc.Error detectionTransmit extra (redundant) information Use redundant information to detect errorsExtreme case: send two copies of the dataTrade-off: accuracy vs. overheadTechniques for detecting errorsParity checkingChecksumCyclic Redundancy Check (CRC)Slide21

21

Error Detection: Parity

Add an extra bit to a 7-bit codeOdd parity: ensure an odd number of 1sE.g., 0101011 becomes 01010111Even parity: ensure an even number of 1sE.g., 0101011 becomes 01010110Overhead: 1/7thPower: Detects all 1-bit errorsBut: can’t detect an even number of bit errors in a wordCan use more bits to gain more powerSlide22

22

Error Detection Techniques, con’t

Internet ChecksumTreat data as a sequence of 16-bit wordsCompute ones-complement sum of all the 16-bit wordsIntermingles integrity of a large group of dataOverhead: 16 bitsPower:Catches 1-bit errors, most other errorsBut not, for example, same bit flipped in two different words Cyclic Redundancy Check (CRC)Family of quite powerful, principled algorithmsDetects wide range of bit corruption patterns seen in practiceUsed by most modern link layersSee K&R Section 5.2.3Slide23

23

Point-to-Point vs. Broadcast Media

Point-to-point: dedicated pairwise communicationLong-distance fiber linkPoint-to-point link between Ethernet switch and hostBroadcast: shared wire or mediumTraditional Ethernet802.11 wireless LANSlide24

24

Multiple Access AlgorithmSingle shared broadcast channel

Avoid having multiple nodes speaking at onceOtherwise, collisions lead to garbled dataMultiple access mechanismDistributed algorithm for sharing the channelAlgorithm determines which node can transmitClasses of techniquesChannel partitioning: divide channel into piecesTaking turns: scheme for trading off who gets to transmitRandom access: allow collisions, and then recoverOptimizes for the common case of only one senderSlide25

25

Channel Partitioning: TDMA

TDMA: Time Division Multiple Access Access to channel in "rounds" Each station gets fixed length slot in each roundTime-slot length is packet transmission time Unused slots go idle Example: 6-station LAN with slots 0, 3, and 4

Rounds

0

1

2

3

4

5

0

1

2

3

4

5

Slots = Slide26

26

Channel Partitioning: FDMA

FDMA: Frequency Division Multiple Access Channel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle

frequency bands

time

FDM cableSlide27

27

“Taking Turns” MAC protocols

Polling Master node “invites” slave nodes to transmit in turnConcerns:Polling overhead LatencySingle point of failure (master)

Token passing

Control token

passed from one node to next sequentially

Node must have token to send

Concerns:

Token overhead

Latency

Single point of failure (token)

master

slaves

poll

data

dataSlide28

28

Random Access ProtocolsWhen node has packet to send

Transmit at full channel data rateNo a priori coordination among nodesTwo or more transmitting nodes  collisionData lostRandom access MAC protocol specifies: How to detect collisionsHow to recover from collisions Examples ALOHA and Slotted ALOHACSMA, CSMA/CD, CSMA/CASlide29

29

Key Ideas of Random Access

Carrier senseListen before speaking, and don’t interruptChecking if someone else is already sending data… and waiting till the other node is doneCollision detectionIf someone else starts talking at the same time, stopRealizing when two nodes are transmitting at once…by detecting that the data on the wire is garbledRandomnessDon’t start talking again right awayWaiting for a random time before trying againSlide30

30

Where it all Started:AlohaNet

Norm Abramson left Stanford in search of surfingSet up first radio-based data communication system connecting the Hawaiian islandsHub at Alohanet HQ (Univ. Hawaii, Oahu)Other sites spread among the islandsHad two radio channels:Random access: sites sent data on this channelBroadcast: only used by hub to rebroadcast incoming dataSlide31

31

Slotted ALOHA

AssumptionsAll frames same sizeTime divided into equal slots (time to transmit a frame)Nodes are synchronizedNodes begin to transmit frames only at start of slotsNo carrier senseIf two or more nodes transmit, all nodes detect collisionOperationWhen node obtains fresh frame, transmits in next slotNo collision: node can send new frame in next slotCollision: node retransmits frame in each subsequent slot with probability p until successSlide32

32

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized: only slots in nodes need to be in syncSimpleConsCollisions, wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronizationSlide33

33

Efficiency of Slotted Aloha

What is the maximum fraction of successful transmissions? Suppose N stations have packets to sendEach transmits in slot with probability pProbability of successful transmission S is(very approximate analysis!): by a particular node i: Si = p (1-p)(N-1)

by

exactly

one of N nodes

S =

Prob

(only one transmits)

= N

p

(1-p)

(N-1) <= 1/e =

0.37 but must have p proportional to 1/N Slide34

34

CSMA (Carrier Sense Multiple Access)Collisions hurt the efficiency of ALOHA protocol

Utilization  1/e  37%CSMA: listen before transmitIf channel sensed idle: transmit entire frameIf channel sensed busy, defer transmission Human analogy: don’t interrupt others!Slide35

35

CSMA Collisions

Collisions can still occur:propagation delay means two nodes may not heareach other’s transmission in time.

At time t

1

,

D

still hasn’t heard

B

’s signal sent at the earlier time t

0

, so

D

goes ahead and transmits: failure of

carrier sense

.

Collision:

entire packet transmission time wastedSlide36

36

CSMA/CD (Collision Detection)CSMA/CD: carrier sensing, deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted, reducing wastage Collision detection Easy in wired LANs: measure signal strengths, compare transmitted, received signalsDifficult in wireless LANsReception shut off while transmittingEven if on, might not be able to hear the other sender, even though the receiver canLeads to use of collision avoidance insteadSlide37

37

CSMA/CD Collision Detection

Both B and D can tell that collision occurred.This lets them (1) know that they need to resend the frame,and (2) recognize that there’s contention and adopt a strategy for dealing with it.

Note: for this to work, we need restrictions on

minimum frame size

and

maximum distanceSlide38

38

Three Ways to Share the Media

Channel partitioning MAC protocols (TDMA, FDMA):Share channel efficiently and fairly at high loadInefficient at low load: delay in channel access, 1/N bandwidth allocated even if only 1 active node! “Taking turns” protocolsEliminates empty slots without causing collisionsOverhead in acquiring the tokenVulnerable to failures (e.g., failed node or lost token)Random access MAC protocolsEfficient at low load: single node can fully utilize channelHigh load: collision overheadSlide39

39

Next Lecture

Ethernet + bridges/hubs/switchesK&R 5.5, 5.6

Related Contents


Next Show more