Top Banner
Link Layer
206

Link Layer - courses.cs.washington.edu

Jan 21, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Link Layer - courses.cs.washington.edu

Link Layer

Page 2: Link Layer - courses.cs.washington.edu

Where we are in the Course

• Moving on up to the Link Layer!

CSE 461 University of Washington 2

Physical

Link

Network

Transport

Application

Page 3: Link Layer - courses.cs.washington.edu

Scope of the Link Layer

• Concerns how to transfer messages over one or more connected links

• Messages are frames, of limited size• Builds on the physical layer

CSE 461 University of Washington 3

Frame

Page 4: Link Layer - courses.cs.washington.edu

In terms of layers …

CSE 461 University of Washington 4

Actual data path

Virtual data path

Network

Link

Physical

Page 5: Link Layer - courses.cs.washington.edu

In terms of layers (2)

CSE 461 University of Washington 5

Actual data path

Virtual data path

Network

Link

Physical

Page 6: Link Layer - courses.cs.washington.edu

Typical Implementation of Layers (2)

CSE 461 University of Washington 6

Page 7: Link Layer - courses.cs.washington.edu

Topics

1. Framing• Delimiting start/end of frames

2. Error detection and correction• Handling errors

3. Retransmissions• Handling loss

4. Multiple Access• 802.11, classic Ethernet

5. Switching• Modern Ethernet

CSE 461 University of Washington 7

Page 8: Link Layer - courses.cs.washington.edu

FramingDelimiting start/end of frames

Page 9: Link Layer - courses.cs.washington.edu

Topic

• The Physical layer gives us a stream of bits. How do we interpret it as a sequence of frames?

CSE 461 University of Washington 9

…10110 …

Um?

Page 10: Link Layer - courses.cs.washington.edu

Framing Methods

• We’ll look at:• Byte count (motivation)

• Byte stuffing

• Bit stuffing

• In practice, the physical layer often helps to identify frame boundaries• E.g., Ethernet, 802.11

CSE 461 University of Washington 10

Page 11: Link Layer - courses.cs.washington.edu

Simple ideas?

Page 12: Link Layer - courses.cs.washington.edu

Byte Count

• First try:• Let’s start each frame with a length field!

• It’s simple, and hopefully good enough …

CSE 461 University of Washington 12

Page 13: Link Layer - courses.cs.washington.edu

Byte Count (2)

• How well do you think it works?

CSE 461 University of Washington 13

Page 14: Link Layer - courses.cs.washington.edu

Byte Count (3)

• Difficult to re-synchronize after framing error• Want a way to scan for a start of frame

CSE 461 University of Washington 14

Page 15: Link Layer - courses.cs.washington.edu

Byte Stuffing

• Better idea:• Have a special flag byte value for start/end of frame• Replace (“stuff”) the flag with an escape code• Problem?

CSE 461 University of Washington 15

Page 16: Link Layer - courses.cs.washington.edu

Byte Stuffing

• Better idea:• Have a special flag byte value for start/end of frame• Replace (“stuff”) the flag with an escape code• Complication: have to escape the escape code too!

CSE 461 University of Washington 16

Page 17: Link Layer - courses.cs.washington.edu

Byte Stuffing (2)

• Rules:• Replace each FLAG in data with ESC FLAG

• Replace each ESC in data with ESC ESC

CSE 461 University of Washington 17

Page 18: Link Layer - courses.cs.washington.edu

Byte Stuffing (3)

• Now any unescaped FLAG is the start/end of a frame

CSE 461 University of Washington 18

Page 19: Link Layer - courses.cs.washington.edu

Unstuffing

You see:

1. Solitary FLAG?

2. Solitary ESC?

3. ESC FLAG?

4. ESC ESC FLAG?

5. ESC ESC ESC FLAG?

6. ESC FLAG FLAG?

Page 20: Link Layer - courses.cs.washington.edu

Unstuffing

You see:

1. Solitary FLAG? -> Start or end of packet

2. Solitary ESC? -> Bad packet!

3. ESC FLAG? -> remove ESC and pass FLAG through

4. ESC ESC FLAG? -> removed ESC and then start or end of packet

5. ESC ESC ESC FLAG? -> pass ESC FLAG through

6. ESC FLAG FLAG? -> pass FLAG through then start or end of packet

Page 21: Link Layer - courses.cs.washington.edu

Bit Stuffing

• Can stuff at the bit level too• Call a flag six consecutive 1s

• On transmit, after five 1s in the data, insert a 0

• On receive, a 0 after five 1s is deleted

CSE 461 University of Washington 21

Page 22: Link Layer - courses.cs.washington.edu

Bit Stuffing (2)

• Example:

CSE 461 University of Washington 22

Transmitted bitswith stuffing

Data bits

Page 23: Link Layer - courses.cs.washington.edu

Bit Stuffing (3)

• So how does it compare with byte stuffing?

CSE 461 University of Washington 23

Transmitted bitswith stuffing

Data bits

Page 24: Link Layer - courses.cs.washington.edu

Link Example: PPP over SONET

• PPP is Point-to-Point Protocol

• Widely used for link framing• E.g., it is used to frame IP packets that are sent over SONET optical links

CSE 461 University of Washington 24

Page 25: Link Layer - courses.cs.washington.edu

Link Example: PPP over SONET (2)

• Think of SONET as a bit stream, and PPP as the framing that carries an IP packet over the link

CSE 461 University of Washington 25

Protocol stacksPPP frames may be split over

SONET payloads

Page 26: Link Layer - courses.cs.washington.edu

Link Example: PPP over SONET (3)

• Framing uses byte stuffing

• FLAG is 0x7E and ESC is 0x7D

CSE 461 University of Washington 26

Page 27: Link Layer - courses.cs.washington.edu

Link Layer: Error detection and correction

Page 28: Link Layer - courses.cs.washington.edu

Topic

• Some bits will be received in error due to noise. What can we do?

• Detect errors with codes• Retransmit lost frames• Correct errors with codes

•Reliability is a concern that cuts across the layers

CSE 461 University of Washington 28

Later

Page 29: Link Layer - courses.cs.washington.edu

Problem – Noise may flip received bits

CSE 461 University of Washington 29

Signal0 0 0 0

11 1

0

0 0 0 0

11 1

0

0 0 0 0

11 1

0

SlightlyNoisy

Verynoisy

Page 30: Link Layer - courses.cs.washington.edu

Approach – Add Redundancy

• Error detection codes• Add check bits to the message bits to let some errors be

detected

• Error correction codes• Add more check bits to let some errors be corrected

• Key issue is now to structure the code to detect many errors with few check bits and modest computation

CSE 461 University of Washington 30

Page 31: Link Layer - courses.cs.washington.edu

• Ideas?

Page 32: Link Layer - courses.cs.washington.edu

Motivating Example

• A simple code to handle errors:• Send two copies! Error if different.

• How good is this code?• How many errors can it detect/correct?• How many errors will make it fail?

CSE 461 University of Washington 32

Page 33: Link Layer - courses.cs.washington.edu

Motivating Example (2)

• We want to handle more errors with less overhead• Will look at better codes; they are applied mathematics• But, they can’t handle all errors• And they focus on accidental errors (will look at secure

hashes later)

CSE 461 University of Washington 33

Page 34: Link Layer - courses.cs.washington.edu

Using Error Codes

• Codeword consists of D data plus R check bits (=systematic block code)

• Sender: • Compute R check bits based on the D data bits; send the

codeword of D+R bits

CSE 461 University of Washington 34

D R=fn(D)

Data bits Check bits

Page 35: Link Layer - courses.cs.washington.edu

Using Error Codes (2)

• Receiver: • Receive D+R bits with unknown errors• Recompute R check bits based on the D data bits; error if

R doesn’t match R’

CSE 461 University of Washington 35

D R’

Data bits Check bits

R=fn(D)=?

Page 36: Link Layer - courses.cs.washington.edu

Intuition for Error Codes

• For D data bits, R check bits:

• Randomly chosen codeword is unlikely to be correct; overhead is low

CSE 461 University of Washington 36

Allcodewords

Correctcodewords

Page 37: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 37

R.W. Hamming (1915-1998)

• Much early work on codes:• “Error Detecting and Error Correcting

Codes”, BSTJ, 1950

• “If the computer can tell when an error has occurred, surely there is a way of telling where the error is so the computer can correct the error itself” - Hamming

Source: IEEE GHN, © 2009 IEEE

Page 38: Link Layer - courses.cs.washington.edu

Hamming Distance

• Hamming distance between two codes (D1 D2) is the number of bit flips needed to change D1 to D2

• Hamming distance of a coding is the minimum error distance between any pair of codewords (bit-strings) that cannot be detected

CSE 461 University of Washington 38

Page 39: Link Layer - courses.cs.washington.edu

Hamming Distance (2)

• Error detection:• For a coding of distance d+1, up to d errors will always be

detected

• Error correction:• For a coding of distance 2d+1, up to d errors can always be

corrected by mapping to the closest valid codeword

CSE 461 University of Washington 39

Page 40: Link Layer - courses.cs.washington.edu

Simple Error Detection – Parity Bit

• Take D data bits, add 1 check bit that is the sum of the D bits

• Sum is modulo 2 or XOR

CSE 461 University of Washington 40

Page 41: Link Layer - courses.cs.washington.edu

Parity Bit (2)

• How well does parity work?• What is the distance of the code?• How many errors will it detect/correct?

• What about larger errors?

CSE 461 University of Washington 41

Page 42: Link Layer - courses.cs.washington.edu

Checksums

• Idea: sum up data in N-bit words• Widely used in, e.g., TCP/IP/UDP

• Stronger protection than parity

CSE 461 University of Washington 42

1500 bytes 16 bits

Page 43: Link Layer - courses.cs.washington.edu

Internet Checksum

• Sum is defined in 1s complement arithmetic (must add back carries)

• And it’s the negative sum

• “The checksum field is the 16 bit one's complement of the one's complement sum of all 16 bit words …” – RFC 791

CSE 461 University of Washington 43

Page 44: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 44

Internet Checksum (2)Sending:

1.Arrange data in 16-bit words

2.Put zero in checksum position, add

3.Add any carryover back to get 16 bits

4.Negate (complement) to get sum

0001 f204 f4f5 f6f7

+(0000)------2ddf0

ddf0 + 2 ------

ddf2

220d

Page 45: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 45

Internet Checksum (3)0001 f204 f4f5 f6f7

+(0000)------2ddf1

ddf1 + 2 ------

ddf3

220c

Sending:

1.Arrange data in 16-bit words

2.Put zero in checksum position, add

3.Add any carryover back to get 16 bits

4.Negate (complement) to get sum

Page 46: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 46

Internet Checksum (4)Receiving:

1. Arrange data in 16-bit words

2. Checksum will be non-zero, add

3. Add any carryover back to get 16 bits

4. Negate the result and check it is 0

0001 f204 f4f5 f6f7

+ 220c ------2fffd

fffd + 2 ------

ffff

0000

Page 47: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 47

Internet Checksum (5)Receiving:

1. Arrange data in 16-bit words

2. Checksum will be non-zero, add

3. Add any carryover back to get 16 bits

4. Negate the result and check it is 0

0001 f204 f4f5 f6f7

+ 220c ------2fffd

fffd + 2 ------

ffff

0000

Page 48: Link Layer - courses.cs.washington.edu

Internet Checksum (6)

• How well does the checksum work?• What is the distance of the code?• How many errors will it detect/correct?

• What about larger errors?

CSE 461 University of Washington 48

Page 49: Link Layer - courses.cs.washington.edu

Cyclic Redundancy Check (CRC)

• Even stronger protection• Given n data bits, generate k check bits such that the n+k

bits are evenly divisible by a generator C

• Example with numbers:• n = 302, k = one digit, C = 3

CSE 461 University of Washington 49

Page 50: Link Layer - courses.cs.washington.edu

CRCs (2)

• The catch:• It’s based on mathematics of finite fields, in which “numbers” represent

polynomials

• e.g, 10011010 is x7

+ x4

+ x3

+ x1

• What this means:• We work with binary values and operate using modulo 2 arithmetic

CSE 461 University of Washington 50

Page 51: Link Layer - courses.cs.washington.edu

CRCs (3)

• Send Procedure:

1. Extend the n data bits with k zeros

2. Divide by the generator value C

3. Keep remainder, ignore quotient

4. Adjust k check bits by remainder

• Receive Procedure:

1. Divide and check for zero remainder

CSE 461 University of Washington 51

Page 52: Link Layer - courses.cs.washington.edu

CRCs (4)

CSE 461 University of Washington 52

Data bits:1101011111

Check bits:C(x)=x4+x1+1

C = 10011k = 4

Page 53: Link Layer - courses.cs.washington.edu

CRCs (5)

CSE 461 University of Washington 53Plus

Page 54: Link Layer - courses.cs.washington.edu

CRCs (6)

• Protection depend on generator• Standard CRC-32 is 10000010 01100000 10001110 110110111

• Properties:• HD=4, detects up to triple bit errors

• Also odd number of errors

• And bursts of up to k bits in error

• Not vulnerable to systematic errors like checksums

CSE 461 University of Washington 54

Page 55: Link Layer - courses.cs.washington.edu

Why Error Correction is Hard

• If we had reliable check bits we could use them to narrow down the position of the error

• Then correction would be easy

• But error could be in the check bits as well as the data bits!

• Data might even be correct

CSE 461 University of Washington 55

Page 56: Link Layer - courses.cs.washington.edu

Intuition for Error Correcting Code

• Suppose we construct a code with a Hamming distance of at least 3

• Need ≥3 bit errors to change one valid codeword into another

• Single bit errors will be closest to a unique valid codeword

• If we assume errors are only 1 bit, we can correct them by mapping an error to the closest valid codeword

• Works for d errors if HD ≥ 2d + 1

CSE 461 University of Washington 56

Page 57: Link Layer - courses.cs.washington.edu

Intuition (2)

• Visualization of code:

CSE 461 University of Washington 57

A

B

Validcodeword

Errorcodeword

Page 58: Link Layer - courses.cs.washington.edu

Intuition (3)

• Visualization of code:

CSE 461 University of Washington 58

A

B

Validcodeword

Errorcodeword

Single bit errorfrom A

Three bit errors to get to B

Page 59: Link Layer - courses.cs.washington.edu

Hamming Code

• Gives a method for constructing a code with a distance of 3

• Uses n = 2k – k – 1, e.g., n=4, k=3• Put check bits in positions p that are powers of 2, starting

with position 1• Check bit in position p is parity of positions with a p term

in their values

• Plus an easy way to correct [soon]

CSE 461 University of Washington 59

Page 60: Link Layer - courses.cs.washington.edu

Hamming Code (2)

• Example: data=0101, 3 check bits• 7 bit code, check bit positions 1, 2, 4• Check 1 covers positions 1, 3, 5, 7• Check 2 covers positions 2, 3, 6, 7• Check 4 covers positions 4, 5, 6, 7

CSE 461 University of Washington 60

_ _ _ _ _ _ _1 2 3 4 5 6 7

Page 61: Link Layer - courses.cs.washington.edu

Hamming Code (3)

• Example: data=0101, 3 check bits• 7 bit code, check bit positions 1, 2, 4• Check 1 covers positions 1, 3, 5, 7• Check 2 covers positions 2, 3, 6, 7• Check 4 covers positions 4, 5, 6, 7

CSE 461 University of Washington 61

0 1 0 0 1 0 1

p1= 0+1+1 = 0, p2= 0+0+1 = 1, p4= 1+0+1 = 0

1 2 3 4 5 6 7

Page 62: Link Layer - courses.cs.washington.edu

Hamming Code (4)

• To decode:• Recompute check bits (with parity sum including the

check bit)• Arrange as a binary number• Value (syndrome) tells error position• Value of zero means no error• Otherwise, flip bit to correct

CSE 461 University of Washington 62

Page 63: Link Layer - courses.cs.washington.edu

Hamming Code (5)

• Example, continued

CSE 461 University of Washington 63

0 1 0 0 1 0 1

p1= p2= p4=

Syndrome = Data =

1 2 3 4 5 6 7

Page 64: Link Layer - courses.cs.washington.edu

Hamming Code (6)

• Example, continued

CSE 461 University of Washington 64

0 1 0 0 1 0 1

p1= 0+0+1+1 = 0, p2= 1+0+0+1 = 0,p4= 0+1+0+1 = 0

Syndrome = 000, no errorData = 0 1 0 1

1 2 3 4 5 6 7

Page 65: Link Layer - courses.cs.washington.edu

Hamming Code (7)

• Example, continued

CSE 461 University of Washington 65

0 1 0 0 1 1 1

p1= p2= p4=

Syndrome = Data =

1 2 3 4 5 6 7

Page 66: Link Layer - courses.cs.washington.edu

Hamming Code (8)

• Example, continued

CSE 461 University of Washington 66

0 1 0 0 1 1 1

p1= 0+0+1+1 = 0, p2= 1+0+1+1 = 1,p4= 0+1+1+1 = 1

Syndrome = 1 1 0, flip position 6Data = 0 1 0 1 (correct after flip!)

1 2 3 4 5 6 7

Page 67: Link Layer - courses.cs.washington.edu

Hamming Code (3)

• Example: bad message 0100111• 7 bit code, check bit positions 1, 2, 4• Check 1 covers positions 1, 3, 5, 7• Check 2 covers positions 2, 3, 6, 7• Check 4 covers positions 4, 5, 6, 7

CSE 461 University of Washington 67

0 1 0 0 1 1 1

p1= 0+0+1+1 = 0, p2= 1+0+1+1 = 1, p4= 0+1+1+1 = 1

1 2 3 4 5 6 7

Page 68: Link Layer - courses.cs.washington.edu

Hamming Code (3)

• Example: bad message 0100111• 7 bit code, check bit positions 1, 2, 4• Check 1 covers positions 1, 3, 5, 7• Check 2 covers positions 2, 3, 6, 7• Check 4 covers positions 4, 5, 6, 7

CSE 461 University of Washington 68

0 1 0 0 1 1 1

p1= 0+0+1+1 = 0, p2= 1+0+1+1 = 1, p4= 0+1+1+1 = 1

1 2 3 4 5 6 7

Page 69: Link Layer - courses.cs.washington.edu

Other Error Correction Codes

• Real codes are more involved than Hamming

• E.g., Convolutional codes (§3.2.3)• Take a stream of data and output a mix of the input bits• Makes each output bit less fragile• Decode using Viterbi algorithm (which can use bit confidence

values)

CSE 461 University of Washington 69

Page 70: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 70

Other Codes (2) – Turbo Codes • Turbo Codes

• Evolution of convolutional codes• Sends multiple sets of parity bits with payload• Decodes sets together (e.g. Sudoku)• Used in 3G and 4G cellular technologies

• Invented and patented by Claude Berrou• Professor at École Nationale Supérieure des

Télécommunications de Bretagne

Page 71: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 71

Other Codes (3) – LDPC • Low Density Parity Check (§3.2.3)

• LDPC based on sparse matrices• Decoded iteratively using a belief

propagation algorithm

• Invented by Robert Gallager in 1963 as part of his PhD thesis

• Promptly forgotten until 1996 …

Source: IEEE GHN, © 2009 IEEE

Page 72: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 72

More coding theory • This is a huge field. • See EE 505, 514, 515 for more info

− These are graduate classes• Key points:

− Coding allows us to detect and correct bit errors received from the PHY

− It is very complicated. Abstract away with Hamming Distance

Page 73: Link Layer - courses.cs.washington.edu

Detection vs. Correction

• Which is better will depend on the pattern of errors. For example:

• 1000 bit messages with a bit error rate (BER) of 1 in 10000

• Which has less overhead?

CSE 461 University of Washington 73

Page 74: Link Layer - courses.cs.washington.edu

Detection vs. Correction

• Which is better will depend on the pattern of errors. For example:

• 1000 bit messages with a bit error rate (BER) of 1 in 10000

• Which has less overhead?• It still depends! We need to know more about the errors

CSE 461 University of Washington 74

Page 75: Link Layer - courses.cs.washington.edu

Detection vs. Correction (2)

Assume bit errors are random• Messages have 0 or maybe 1 error (1/10 of the time)

Error correction: • Need ~10 check bits per message

• Overhead:

Error detection: • Need ~1 check bits per message plus 1000 bit retransmission

• Overhead:

CSE 461 University of Washington 75

Page 76: Link Layer - courses.cs.washington.edu

Detection vs. Correction (3)

Assume errors come in bursts of 100• Only 1 or 2 messages in 1000 have significant (multi-bit) errors

Error correction: • Need >>100 check bits per message

• Overhead:

Error detection: • Need 32 check bits per message plus 1000 bit resend 2/1000 of the time

• Overhead:

CSE 461 University of Washington 76

Page 77: Link Layer - courses.cs.washington.edu

Detection vs. Correction (4)

• Error correction: • Needed when errors are expected

• Or when no time for retransmission

• Error detection: • More efficient when errors are not expected

• And when errors are large when they do occur

CSE 461 University of Washington 77

Page 78: Link Layer - courses.cs.washington.edu

Error Correction in Practice

• Heavily used in physical layer• LDPC is the future, used for demanding links like 802.11, DVB, WiMAX, power-line, …

• Convolutional codes widely used in practice

• Error detection (w/ retransmission) is used in the link layer and above for residual errors

• Correction also used in the application layer• Called Forward Error Correction (FEC)

• Normally with an erasure error model

• E.g., Reed-Solomon (CDs, DVDs, etc.)

CSE 461 University of Washington 78

Page 79: Link Layer - courses.cs.washington.edu

Link Layer: Retransmissions

Page 80: Link Layer - courses.cs.washington.edu

Context on Reliability

• Where in the stack should we place reliability functions?

CSE 461 University of Washington 80

Physical

Link

Network

Transport

Application

Page 81: Link Layer - courses.cs.washington.edu

Context on Reliability (2)

• Everywhere! It is a key issue• Different layers contribute differently

CSE 461 University of Washington 81

Recover actions(correctness)

Mask errors(performance optimization)

Physical

Link

Network

Transport

Application

Page 82: Link Layer - courses.cs.washington.edu

So what do we do if a frame is corrupted?

• From sender?

• From receiver?

Page 83: Link Layer - courses.cs.washington.edu

ARQ (Automatic Repeat reQuest)

• ARQ often used when errors are common or must be corrected

• E.g., WiFi, and TCP (later)

• Rules at sender and receiver:• Receiver automatically acknowledges correct frames with

an ACK• Sender automatically resends after a timeout, until an ACK

is received

CSE 461 University of Washington 83

Page 84: Link Layer - courses.cs.washington.edu

ARQ (2)

• Normal operation (no loss)

CSE 461 University of Washington 84

Frame

ACKTimeout Time

Sender Receiver

Page 85: Link Layer - courses.cs.washington.edu

ARQ (3)

• Loss and retransmission

CSE 461 University of Washington 85

ACK

Frame

Timeout Time

Sender Receiver

Frame

X

Page 86: Link Layer - courses.cs.washington.edu

So What’s Tricky About ARQ?

CSE 461 University of Washington 86

Page 87: Link Layer - courses.cs.washington.edu

Duplicates

• What happens if an ACK is lost?

CSE 461 University of Washington 87

X

Frame

ACKTimeout

Sender Receiver

Page 88: Link Layer - courses.cs.washington.edu

Duplicates (2)

• What happens if an ACK is lost?

CSE 461 University of Washington 88

Frame

ACK

X

Frame

ACKTimeout

Sender Receiver

New Frame??

Page 89: Link Layer - courses.cs.washington.edu

Duplicates (3)

• Or the timeout is early?

CSE 461 University of Washington 89

ACK

Frame

Timeout

Sender Receiver

Page 90: Link Layer - courses.cs.washington.edu

Duplicates (4)

• Or the timeout is early?

CSE 461 University of Washington 90

Frame

ACK

Frame

ACK

Timeout

Sender Receiver

New Frame??

Page 91: Link Layer - courses.cs.washington.edu

So What’s Tricky About ARQ?

• Two non-trivial issues:• How long to set the timeout? • How to avoid accepting duplicate frames as new frames

• Want performance in the common case and correctness always

• Ideas?

CSE 461 University of Washington 91

Page 92: Link Layer - courses.cs.washington.edu

Timeouts

• Timeout should be:• Not too big (link goes idle)

• Not too small (spurious resend)

• Fairly easy on a LAN• Clear worst case, little variation

• Fairly difficult over the Internet• Much variation, no obvious bound

• We’ll revisit this with TCP (later)

CSE 461 University of Washington 92

Page 93: Link Layer - courses.cs.washington.edu

Sequence Numbers

• Frames and ACKs must both carry sequence numbers for correctness

• To distinguish the current frame from the next one, a single bit (two numbers) is sufficient

• Called Stop-and-Wait

CSE 461 University of Washington 93

Page 94: Link Layer - courses.cs.washington.edu

Stop-and-Wait

• In the normal case:

CSE 461 University of Washington 94

Time

Sender Receiver

Page 95: Link Layer - courses.cs.washington.edu

Stop-and-Wait (2)

• In the normal case:

CSE 461 University of Washington 95

Frame 0

ACK 0Timeout Time

Sender Receiver

Frame 1

ACK 1

Page 96: Link Layer - courses.cs.washington.edu

Stop-and-Wait (3)

• With ACK loss:

CSE 461 University of Washington 96

X

Frame 0

ACK 0Timeout

Sender Receiver

Page 97: Link Layer - courses.cs.washington.edu

Stop-and-Wait (4)

• With ACK loss:

CSE 461 University of Washington 97

Frame 0

ACK 0

X

Frame 0

ACK 0Timeout

Sender Receiver

It’s a Resend!

Page 98: Link Layer - courses.cs.washington.edu

Stop-and-Wait (5)

• With early timeout:

CSE 461 University of Washington 98

ACK 0

Frame 0

Timeout

Sender Receiver

Page 99: Link Layer - courses.cs.washington.edu

Stop-and-Wait (6)

• With early timeout:

CSE 461 University of Washington 99

Frame 0

ACK 0

Frame 0

ACK 0

Timeout

Sender Receiver

It’s aResend

OK …

Page 100: Link Layer - courses.cs.washington.edu

Limitation of Stop-and-Wait

• It allows only a single frame to be outstanding from the sender:

• Good for LAN, not efficient for high BD

• Ex: R=1 Mbps, D = 50 ms• How many frames/sec? If R=10 Mbps?

CSE 461 University of Washington 100

Page 101: Link Layer - courses.cs.washington.edu

Sliding Window

• Generalization of stop-and-wait• Allows W frames to be outstanding• Can send W frames per RTT (=2D)

• Various options for numbering frames/ACKs and handling loss• Will look at along with TCP (later)

CSE 461 University of Washington 101

Page 102: Link Layer - courses.cs.washington.edu

Multiple Access

Page 103: Link Layer - courses.cs.washington.edu

Topic

• Multiplexing is the network word for the sharing of a resource

• What are some obvious ways to multiple a resource?

CSE 461 University of Washington 103

Page 104: Link Layer - courses.cs.washington.edu

Topic

• Multiplexing is the network word for the sharing of a resource

• Classic scenario is sharing a link among different users• Time Division Multiplexing (TDM)

• Frequency Division Multiplexing (FDM)

CSE 461 University of Washington 104

Page 105: Link Layer - courses.cs.washington.edu

Time Division Multiplexing (TDM)

•Users take turns on a fixed schedule

CSE 461 University of Washington 105

2 2 2 2

Page 106: Link Layer - courses.cs.washington.edu

Frequency Division Multiplexing (FDM)

• Put different users on different frequency bands

CSE 461 University of Washington 106

Overall FDM channel

Page 107: Link Layer - courses.cs.washington.edu

TDM versus FDM

• Tradeoffs?

CSE 461 University of Washington 107

Page 108: Link Layer - courses.cs.washington.edu

TDM versus FDM (2)

• In TDM a user sends at a high rate a fraction of the time; in FDM, a user sends at a low rate all the time

CSE 461 University of Washington 108

Rate

TimeFDM

TDM

Page 109: Link Layer - courses.cs.washington.edu

TDM/FDM Usage

• Statically divide a resource• Suited for continuous traffic, fixed number of users

• Widely used in telecommunications• TV and radio stations (FDM)• GSM (2G cellular) allocates calls using TDM within FDM

CSE 461 University of Washington 109

Page 110: Link Layer - courses.cs.washington.edu

Multiplexing Network Traffic

• Network traffic is bursty• ON/OFF sources • Load varies greatly over time

CSE 461 University of Washington 110

Rate

TimeRate

Time

R

R

Page 111: Link Layer - courses.cs.washington.edu

Multiplexing Network Traffic (2)

• Network traffic is bursty• Inefficient to always allocate user their ON needs with

TDM/FDM

CSE 461 University of Washington 111

Rate

TimeRate

Time

R

R

Page 112: Link Layer - courses.cs.washington.edu

Multiplexing Network Traffic (3)

• Multiple access schemes multiplex users according to demands – for gains of statistical multiplexing

CSE 461 University of Washington 112

Rate

TimeRate

Time

Rate

Time

R

R

R’<2R

Two users, each need RTogether they need R’ < 2R

Page 113: Link Layer - courses.cs.washington.edu

How to control?

Two classes of multiple access algorithms: Centralized and distributed

• Centralized: Use a privileged “Scheduler” to pick who gets to transmit and when.

• Positives: Scales well, usually efficient.• Negatives: Requirements management, fairness• Examples: Cellular networks (tower coordinates)

• Distributed: Have all participants “figure it out” through some mechanism.

• Positives: Operates well under low load, easy to set up, equality• Negatives: Scaling is really hard, • Examples: Wifi networks

Page 114: Link Layer - courses.cs.washington.edu

Distributed (random) Access

• How do nodes share a single link? Who sends when, e.g., in WiFI?

• Explore with a simple model

• Assume no-one is in charge• Distributed system

CSE 461 University of Washington 114

Page 115: Link Layer - courses.cs.washington.edu

Distributed (random) Access (2)

• We will explore random multiple access control(MAC) protocols

• This is the basis for classic Ethernet• Remember: data traffic is bursty

CSE 461 University of Washington 115

Zzzz..Busy! Ho hum

Page 116: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 116

ALOHA Network

• Seminal computer network connecting the Hawaiian islands in the late 1960s

• When should nodes send?• A new protocol was devised by

Norm Abramson …Hawaii

Page 117: Link Layer - courses.cs.washington.edu

ALOHA Protocol

• Simple idea:• Node just sends when it has traffic. • If there was a collision (no ACK received) then wait a

random time and resend

• That’s it!

CSE 461 University of Washington 117

Page 118: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 118

ALOHA Protocol (2)

• Some frames will be lost, but many may get through…

• Limitations?

Page 119: Link Layer - courses.cs.washington.edu

ALOHA Protocol (3)

• Simple, decentralized protocol that works well under low load!

• Not efficient under high load• Analysis shows at most 18% efficiency

• Improvement: divide time into slots and efficiency goes up to 36%

• We’ll look at other improvements

CSE 461 University of Washington 119

Page 120: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 120

Classic Ethernet • ALOHA inspired Bob Metcalfe to

invent Ethernet for LANs in 1973• Nodes share 10 Mbps coaxial cable• Hugely popular in 1980s, 1990s

: © 2009 IEEE

Page 121: Link Layer - courses.cs.washington.edu

CSMA (Carrier Sense Multiple Access)

• Improve ALOHA by listening for activity before we send (Doh!)

• Can do easily with wires, not wireless

• So does this eliminate collisions?• Why or why not?

CSE 461 University of Washington 121

Page 122: Link Layer - courses.cs.washington.edu

CSMA (2)

• Still possible to listen and hear nothing when another node is sending because of delay

CSE 461 University of Washington 122

Page 123: Link Layer - courses.cs.washington.edu

CSMA (3)

• CSMA is a good defense against collisions only when BD is small

CSE 461 University of Washington 123

X

Page 124: Link Layer - courses.cs.washington.edu

CSMA/CD (with Collision Detection)

• Can reduce the cost of collisions by detecting them and aborting (Jam) the rest of the frame time

• Again, we can do this with wires

CSE 461 University of Washington 124

X X X X X X X XJam! Jam!

Page 125: Link Layer - courses.cs.washington.edu

CSMA/CD Complications

• Everyone who collides needs to know it happened• How long do we need to wait to know there wasn’t a JAM?

CSE 461 University of Washington 125

X

Page 126: Link Layer - courses.cs.washington.edu

CSMA/CD Complications

• Everyone who collides needs to know it happened• How long do we need to wait to know there wasn’t a JAM?• Time window in which a node may hear of a collision

(transmission + jam) is 2D seconds

CSE 461 University of Washington 126

X

Page 127: Link Layer - courses.cs.washington.edu

CSMA/CD Complications (2)

• Impose a minimum frame length of 2D seconds• So node can’t finish before collision• Ethernet minimum frame is 64 bytes – Also sets maximum

network length (500m w/ coax, 100m w/ Twisted Pair)

CSE 461 University of Washington 127

X

Page 128: Link Layer - courses.cs.washington.edu

CSMA “Persistence”

• What should a node do if another node is sending?

• Idea: Wait until it is done, and send

CSE 461 University of Washington 128

What now?

Page 129: Link Layer - courses.cs.washington.edu

CSMA “Persistence” (2)

• Problem is that multiple waiting nodes will queue up then collide

• More load, more of a problem

CSE 461 University of Washington 129

Now! Now!Uh oh

Page 130: Link Layer - courses.cs.washington.edu

CSMA “Persistence” (2)

• Problem is that multiple waiting nodes will queue up then collide

• Ideas?

CSE 461 University of Washington 130

Now! Now!Uh oh

Page 131: Link Layer - courses.cs.washington.edu

CSMA “Persistence” (3)

• Intuition for a better solution• If there are N queued senders, we want each to send next

with probability 1/N

CSE 461 University of Washington 131

Send p=½WhewSend p=½

Page 132: Link Layer - courses.cs.washington.edu

Binary Exponential Backoff (BEB)

• Cleverly estimates the probability• 1st collision, wait 0 or 1 frame times• 2nd collision, wait from 0 to 3 times• 3rd collision, wait from 0 to 7 times …

• BEB doubles interval for each successive collision• Quickly gets large enough to work• Very efficient in practice

CSE 461 University of Washington 132

Page 133: Link Layer - courses.cs.washington.edu

Classic Ethernet, or IEEE 802.3

• Most popular LAN of the 1980s, 1990s• 10 Mbps over shared coaxial cable, with baseband signals• Multiple access with “1-persistent CSMA/CD with BEB”

CSE 461 University of Washington 133

Page 134: Link Layer - courses.cs.washington.edu

Ethernet Frame Format

• Has addresses to identify the sender and receiver

• CRC-32 for error detection; no ACKs or retransmission

• Start of frame identified with physical layer preamble Packet from Network layer (IP)

Page 135: Link Layer - courses.cs.washington.edu

Modern Ethernet

• Based on switches, not multiple access, but still called Ethernet

• We’ll get to it in a later segment

CSE 461 University of Washington 135

Switch

Twisted pair

Switch ports

Page 136: Link Layer - courses.cs.washington.edu

Topic

• How do wireless nodes share a single link? (Yes, this is WiFi!)

• Build on our simple, wired model

CSE 461 University of Washington 136

Send? Send?

Page 137: Link Layer - courses.cs.washington.edu

Wireless Complications

• Wireless is more complicated than the wired case (Surprise!)

1. Media is infinite – can’t Carrier Sense2. Nodes can’t hear while sending – can’t Collision Detect

CSE 461 University of Washington 137

≠ CSMA/CD

Page 138: Link Layer - courses.cs.washington.edu

No CS: Different Coverage Areas

• Wireless signal is broadcast and received nearby, where there is sufficient SNR

CSE 461 University of Washington 138

Page 139: Link Layer - courses.cs.washington.edu

No CS: Hidden Terminals

• Nodes A and C are hidden terminals when sending to B

• Can’t hear each other (to coordinate) yet collide at B• We want to avoid the inefficiency of collisions

CSE 461 University of Washington 139

Page 140: Link Layer - courses.cs.washington.edu

No CS: Exposed Terminals

• B and C are exposed terminals when sending to A and D

• Can hear each other yet don’t collide at receivers A and D• We want to send concurrently to increase performance

CSE 461 University of Washington 140

Page 141: Link Layer - courses.cs.washington.edu

Nodes Can’t Hear While Sending

• With wires, detecting collisions (and aborting) lowers their cost

• More wasted time with wireless

CSE 461 University of Washington 141

Time XXXXXXXXX

XXXXXXXXX

WirelessCollision

ResendX

X

WiredCollision

Resend

Page 142: Link Layer - courses.cs.washington.edu

Wireless Problems:

• Ideas?

Page 143: Link Layer - courses.cs.washington.edu

MACA (Multiple Access with Collision Avoidance) • MACA uses a short handshake instead of CSMA (Karn, 1990)

• 802.11 uses a refinement of MACA (later)

• Protocol rules:1. A sender node transmits a RTS (Request-To-Send, with frame length)

2. The receiver replies with a CTS (Clear-To-Send, with frame length)

3. Sender transmits the frame while nodes hearing the CTS stay silent

• Collisions on the RTS/CTS are still possible, but less likely

CSE 461 University of Washington 143

Page 144: Link Layer - courses.cs.washington.edu

MACA – Hidden Terminals

• A B with hidden terminal C1. A sends RTS, to B

CSE 461 University of Washington 144

DCBARTS

Page 145: Link Layer - courses.cs.washington.edu

MACA – Hidden Terminals (2)

• A B with hidden terminal C2. B sends CTS, to A, and C too

CSE 461 University of Washington 145

DCBARTS

CTSCTS

Alert!

Page 146: Link Layer - courses.cs.washington.edu

MACA – Hidden Terminals (3)

• A B with hidden terminal C3. A sends frame while C defers

CSE 461 University of Washington 146

Frame

Quiet...

Page 147: Link Layer - courses.cs.washington.edu

MACA – Exposed Terminals

• B A, C D as exposed terminals• B and C send RTS to A and D

CSE 461 University of Washington 147

DCBARTSRTS

Page 148: Link Layer - courses.cs.washington.edu

MACA – Exposed Terminals (2)

• B A, C D as exposed terminals• A and D send CTS to B and C

CSE 461 University of Washington 148

DCBARTSRTS

CTSCTS

All OKAll OK

Page 149: Link Layer - courses.cs.washington.edu

MACA – Exposed Terminals (3)

• B A, C D as exposed terminals• A and D send CTS to B and C

CSE 461 University of Washington 149

DCBAFrameFrame

Page 150: Link Layer - courses.cs.washington.edu

MACA

• Assumptions? Where does this break?

Page 151: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 151

802.11, or WiFi

• Very popular wireless LAN started in the 1990s

• Clients get connectivity from a (wired) AP (Access Point)

• It’s a multi-access problem

• Various flavors have been developed over time

• Faster, more features

AccessPoint

Client

To Network

Page 152: Link Layer - courses.cs.washington.edu

802.11 Physical Layer

• Uses 20/40 MHz channels on ISM (unlicensed) bands• 802.11b/g/n on 2.4 GHz

• 802.11 a/n on 5 GHz

• OFDM modulation (except legacy 802.11b)• Different amplitudes/phases for varying SNRs

• Rates from 6 to 54 Mbps plus error correction

• 802.11n uses multiple antennas• Lots of fun tricks here

CSE 461 University of Washington 152

Page 153: Link Layer - courses.cs.washington.edu

802.11 Link Layer

• Multiple access uses CSMA/CA (next); RTS/CTS optional • Frames are ACKed and retransmitted with ARQ (why?)• Funky addressing (three addresses!) due to AP• Errors are detected with a 32-bit CRC• Many, many features (e.g., encryption, power save)

CSE 461 University of Washington 153

Packet from Network layer (IP)

Page 154: Link Layer - courses.cs.washington.edu

802.11 CSMA/CA for Multiple Access

• Still using BEB!

CSE 461 University of Washington 154

Time

Send?

Send?

Page 155: Link Layer - courses.cs.washington.edu

Centralized MAC: Cellular

• Spectrum suddenly very very scarce• We can’t waste all of it sending JAMs

• We have QoS requirements• Can’t be as loose with expectations

• Can’t have traffic fail

• We also have client/server• Centralized control

• Not peer-to-peer/decentralized

Page 156: Link Layer - courses.cs.washington.edu

GSM MAC

• FDMA/TDMA

• Use one channel for coordination – Random access w/BEB (no CSMA, can’t detect)

• Use other channels for traffic• Dedicated channel for QoS

Page 157: Link Layer - courses.cs.washington.edu

Link Layer: Switching

Page 158: Link Layer - courses.cs.washington.edu

Topic

• How do we connect nodes with a switch instead of multiple access

• Uses multiple links/wires • Basis of modern (switched) Ethernet

CSE 461 University of Washington 158

Switch

Page 159: Link Layer - courses.cs.washington.edu

Switched Ethernet

• Hosts are wired to Ethernet switches with twisted pair

• Switch serves to connect the hosts• Wires usually run to a closet

CSE 461 University of Washington 159

Switch

Twisted pair

Switch ports

Page 160: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 160

What’s in the box?• Remember from protocol layers:

Network

Link

Network

Link

Link Link

Physical PhysicalHub, orrepeater

Switch

Router

All look like this:

Page 161: Link Layer - courses.cs.washington.edu

Inside a Hub

• All ports are wired together; more convenient and reliable than a single shared wire

CSE 461 University of Washington 161

Page 162: Link Layer - courses.cs.washington.edu

Inside a Repeater

• All inputs are connected; then amplified before going out

CSE 461 University of Washington 162

Page 163: Link Layer - courses.cs.washington.edu

Inside a Switch

• Uses frame addresses (MAC addresses in Ethernet) to connect input port to the right output port; multiple frames may be switched in parallel

CSE 461 University of Washington 163

Fabric

. . .

12

3

N

Page 164: Link Layer - courses.cs.washington.edu

. . .

12

3

N

Inside a Switch (2)

• Port may be used for both input and output (full-duplex)

• Just send, no multiple access protocol

164

1 → 4and

2 → 3

Page 165: Link Layer - courses.cs.washington.edu

Inside a Switch (3)

• Need buffers for multiple inputs to send to one output

CSE 461 University of Washington 165

. . .

. . .

. . . . . .

Input Buffer Output BufferFabric

Input Output

Page 166: Link Layer - courses.cs.washington.edu

Inside a Switch (4)

• Sustained overload will fill buffer and lead to frame loss

CSE 461 University of Washington 166

. . .

. . .

. . . . . .

Input Buffer Output BufferFabric

Input Output

XXX

Loss!

Page 167: Link Layer - courses.cs.washington.edu

Advantages of Switches

• Switches and hubs (mostly switches) have replaced the shared cable of classic Ethernet

• Convenient to run wires to one location• More reliable; wire cut is not a single point of failure that

is hard to find

• Switches offer scalable performance• E.g., 100 Mbps per port instead of 100 Mbps for all nodes

of shared cable / hub

CSE 461 University of Washington 167

Page 168: Link Layer - courses.cs.washington.edu

Switch Forwarding

• Switch needs to find the right output port for the destination address in the Ethernet frame. How?

• Link-level, don’t look at IP

. . .

. . .

. . . . . .

Source

Destination

Ethernet Frame

Page 169: Link Layer - courses.cs.washington.edu

Switch Forwarding

• Ideas?

. . .

. . .

. . . . . .

Source

Destination

Ethernet Frame

Page 170: Link Layer - courses.cs.washington.edu

Backward Learning

• Switch forwards frames with a port/address table as follows:1. To fill the table, it looks at the source address of input frames

2. To forward, it sends to the port, or else broadcasts to all ports

CSE 461 University of Washington 170

Page 171: Link Layer - courses.cs.washington.edu

Backward Learning (2)

• 1: A sends to D

CSE 461 University of Washington 171

Switch

D

Address Port

A

B

C

D

Page 172: Link Layer - courses.cs.washington.edu

Backward Learning (3)

• 2: D sends to A

CSE 461 University of Washington 172

Switch

D

Address Port

A 1

B

C

D

Page 173: Link Layer - courses.cs.washington.edu

Backward Learning (4)

• 3: A sends to D

CSE 461 University of Washington 173

Address Port

A 1

B

C

D 4

Switch

D

Page 174: Link Layer - courses.cs.washington.edu

Learning with Multiple Switches

• Just works with multiple switches and a mix of hubs, e.g., A -> D then D -> A

CSE 461 University of Washington 174

Switch

Page 175: Link Layer - courses.cs.washington.edu

Learning with Multiple Switches

• Just works with multiple switches and a mix of hubs, e.g., A -> D then D -> A

CSE 461 University of Washington 175

Switch

Problems?

Page 176: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 176

Problem – Forwarding Loops

• May have a loop in the topology• Redundancy in case of failures• Or a simple mistake

• Want LAN switches to “just work”• Plug-and-play, no changes to hosts• But loops cause a problem …

Redundant Links

Page 177: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 177

Forwarding Loops (2) • Suppose the network is started and A

sends to F. What happens?

Left / Right

A B

C

D

E F

Page 178: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 178

Forwarding Loops (3) • Suppose the network is started and A sends to F.

What happens?• 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 179: Link Layer - courses.cs.washington.edu

Spanning Tree Solution

• Switches collectively find a spanning tree for the topology

• A subset of links that is a tree (no loops) and reaches all switches

• They switches forward as normal on the spanning tree• Broadcasts will go up to the root of the tree and down all

the branches

CSE 461 University of Washington 179

Page 180: Link Layer - courses.cs.washington.edu

Spanning Tree (2)

CSE 461 University of Washington 180

Topology One ST Another ST

Page 181: Link Layer - courses.cs.washington.edu

Spanning Tree (3)

CSE 461 University of Washington 181

Topology One ST Another ST

Root

Page 182: Link Layer - courses.cs.washington.edu

Spanning Tree Algorithm

• Rules of the distributed game:• All switches run the same algorithm

• They start with no information

• Operate in parallel and send messages

• Always search for the best solution

• Ensures a highly robust solution• Any topology, with no configuration

• Adapts to link/switch failures, …

CSE 461 University of Washington 182

Page 183: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 183

Radia Perlman (1952–)

• Key early work on routing protocols• Routing in the ARPANET

• Spanning Tree for switches (next)

• Link-state routing (later)

• Worked at Digital Equipment Corp (DEC)

• Now focused on network security

Page 184: Link Layer - courses.cs.washington.edu

Spanning Tree Algorithm (2)

• Outline:1. Elect a root node of the tree (switch with the lowest address)

2. Grow tree as shortest distances from the root (using lowest address to break distance ties)

3. Turn off ports for forwarding if they aren’t on the spanning tree

CSE 461 University of Washington 184

Page 185: Link Layer - courses.cs.washington.edu

Spanning Tree Algorithm (3)

• Details:• Each switch initially believes it is the root of the tree• Each switch sends periodic updates to neighbors with:

• Its address, address of the root, and distance (in hops) to root• Short-circuit when topology changes

• Switches favors ports with shorter distances to lowest root• Uses lowest address as a tie for distances

CSE 461 University of Washington 185

C

Hi, I’m C, the root is A, it’s 2 hops away or (C, A, 2)

Page 186: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 186

Spanning Tree Example• 1st round, sending:

• A sends (A, A, 0) to say it is root

• B, C, D, E, and F do likewise

• 1st round, receiving:• A still thinks is it (A, A, 0)

• B still thinks (B, B, 0)

• C updates to (C, A, 1)

• D updates to (D, C, 1)

• E updates to (E, A, 1)

• F updates to (F, B, 1)

A,A,0 B,B,0

C,C,0

D,D,0

E,E,0 F,F,0

Page 187: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 187

Spanning Tree Example (2)• 2nd round, sending

• Nodes send their updated state

• 2nd round receiving:• A remains (A, A, 0)

• B updates to (B, A, 2) via C

• C remains (C, A, 1)

• D updates to (D, A, 2) via C

• E remains (E, A, 1)

• F remains (F, B, 1)

A,A,0 B,B,0

C,A,1

D,C,1

E,A,1 F,B,1

Page 188: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 188

Spanning Tree Example (3)• 3rd round, sending

• Nodes send their updated state

• 3rd round receiving:• A remains (A, A, 0)

• B remains (B, A, 2) via C

• C remains (C, A, 1)

• D remains (D, A, 2) via C-left

• E remains (E, A, 1)

• F updates to (F, A, 3) via B

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,B,1

Page 189: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 189

Spanning Tree Example (4)• 4th round

• Steady-state has been reached• Nodes turn off forwarding that is

not on the spanning tree

• Algorithm continues to run• Adapts by timing out information• E.g., if A fails, other nodes forget it,

and B will become the new root

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Page 190: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 190

Spanning Tree Example (5)• Forwarding proceeds as usual on the ST

• Initially D sends to F:

• And F sends back to D:

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Page 191: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 191

Spanning Tree Example (6)• Forwarding proceeds as usual on the ST

• Initially D sends to F:• D → C-left

• C → A, B

• A → E

• B → F

• And F sends back to D:• F → B

• B → C

• C → D

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Page 192: Link Layer - courses.cs.washington.edu

CSE 461 University of Washington 192

Spanning Tree Example (6)• Forwarding proceeds as usual on the ST

• Initially D sends to F:• D → C-left

• C → A, B

• A → E

• B → F

• And F sends back to D:• F → B

• B → C

• C → D

A,A,0 B,A,2

C,A,1

D,A,2

E,A,1 F,A,3

Problems?

Page 193: Link Layer - courses.cs.washington.edu

Link Layer: Software Defined Networking

Page 194: Link Layer - courses.cs.washington.edu

Topic

• How do we scale these networks up?• Answer 1: Network of networks, a.k.a. The Internet• Answer 2: Ah, just kinda hope spanning tree works?

CSE 461 University of Washington 194

SwitchSwitch Switch

Page 195: Link Layer - courses.cs.washington.edu

Rise of the Datacenter

CSE 461 University of Washington 195

Page 196: Link Layer - courses.cs.washington.edu

Datacenter Networking

CSE 461 University of Washington 196

Page 197: Link Layer - courses.cs.washington.edu

Scaling the Link Layer

• Fundamentally, it’s hard to scale distributed algorithms

⚫ Exacerbated when failures become common

⚫ Nodes go down, gotta run spanning tree again…

⚫ If nodes go down faster than spanning tree resolves, we get race conditions

⚫ If they don’t, we may still be losing paths and wasting resources

• Ideas?

CSE 461 University of Washington 197

Page 198: Link Layer - courses.cs.washington.edu

Software Defined Networking (SDN)

• Core idea: stop being a distributed system⚫ Centralize the operation of the network

⚫ Create a “controller” that manages the network

⚫ Push new code, state, and configuration from “controller” to switches

⚫ Run link state with a global view of the network rather than in a distributed fashion.

⚫ Allows for “global” policies to be enforced.

⚫ Can resolve failures in more robust, faster manners

⚫ Problems?

CSE 461 University of Washington 198

Page 199: Link Layer - courses.cs.washington.edu

SDN – Problem 1

• Problem: How do we talk to the switches if there’s no network?

⚫ Seems a little chicken-and-egg

⚫ Nodes go down, gotta run spanning tree again…

⚫ If nodes go down faster than spanning tree resolves, we get race conditions

⚫ If they don’t, we may still be losing paths and wasting resources

• Ideas?

CSE 461 University of Washington 199

Page 200: Link Layer - courses.cs.washington.edu

SDN – Control and Data Planes

CSE 461 University of Washington 200

Page 201: Link Layer - courses.cs.washington.edu

SDN – Problem 2

• Problem: How do we efficiently run algorithms on switches?

⚫ These are extremely time-sensitive boxes

⚫ Gotta move the packets!

⚫ Need to be able to support

⚫ Fast packet handling

⚫ Quick route changes

⚫ Long-term policy updates

• Ideas?

CSE 461 University of Washington 201

Page 202: Link Layer - courses.cs.washington.edu

SDN – OpenFlow

CSE 461 University of Washington 202

Control Program A Control Program B

Controller

Packet

Forwarding

Packet

Forwarding

Packet

Forwarding

Flow

Table(s)

“If header = p, send to port 4”

“If header = ?, send to me”

“If header = q, overwrite header with r,

add header s, and send to ports 5,6”

Page 203: Link Layer - courses.cs.washington.edu

SDN – OpenFlow

• Two different classes of programmability

• At Controller

⚫ Can be heavy processing algorithms

⚫ Results in messages that update switch flow table

• At switch

⚫ Local flow table

⚫ Built from basic set of networking primitives

⚫ Allows for fast operation

CSE 461 University of Washington 203

Page 204: Link Layer - courses.cs.washington.edu

SDN – Timescales

CSE 461 University of Washington 204

Data Control Management

Time-scale Packet (nsec) Event (10 msec to sec)

Human (min to hours)

Location Linecard hardware

Router software Humans or scripts

Page 205: Link Layer - courses.cs.washington.edu

SDN – OpenFlow

CSE 461 University of Washington 205

Control Program A Control Program B

Controller

Packet

Forwarding

Packet

Forwarding

Packet

Forwarding

Flow

Table(s)

“If header = p, send to port 4”

“If header = ?, send to me”

“If header = q, overwrite header with r,

add header s, and send to ports 5,6”

Page 206: Link Layer - courses.cs.washington.edu

SDN – Key outputs

• Simplify network design and implementation?

⚫ Sorta. Kinda pushed the complexity around if anything

• However...

⚫ Does enable code reuse and libraries

⚫ Does standardize and simplify deployment of rules to switches

⚫ Allows for fast operation

CSE 461 University of Washington 206