cse 123 computer networksbisync, ppp, ddcmp etx stx header body etx 0x48 0x69 0x48 dle etx 0x69...

30
CSE 123 CSE 123 Computer Networks Computer Networks Fall 2009 Fall 2009 Lecture 4: Lecture 4: Data Data-Link I: Framing and Errors Link I: Framing and Errors Some portions courtesy Robin Kravets and Steve Lumetta

Upload: others

Post on 26-Apr-2020

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

CSE 123CSE 123Computer NetworksComputer Networks

Fall 2009Fall 2009

Lecture 4: Lecture 4: DataData--Link I: Framing and ErrorsLink I: Framing and Errorsgg

Some portions courtesy Robin Kravets and Steve Lumetta

Page 2: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Administrative updatesAdministrative updatesAdministrative updatesAdministrative updates I’m out all next week – no lectures, but… I m out all next week no lectures, but… You will have work

HW #1: will be posted by 10pm tonight, will be due HW #1: will be posted by 10pm tonight, will be due next Wed (Frank will collect)

Project #1: will also be posted by 10pm tonight, will b d th M d ft t ( l t i t ibe due the Monday after next (electronic turn-in before class)

We’re stuck with this room We re stuck with this room

Page 3: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Last timeLast timeLast time…Last time… How to send a signal from here to there How to send a signal from here to there

Page 4: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Today: DataToday: Data--link layerlink layerToday: DataToday: Data--link layerlink layer

Framing Framing Error detection/correction Media Access Media Access Bridging/Switching

Page 5: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

FramingFramingFramingFraming Goal: separate bitstream into distinct units of transfer p

(a frame) Why?

Synchronization recovery Link multiplexing Efficient error detection

Challenges How can we determine exactly what set of bits constitute a

frame?frame? How do we determine the beginning and end of a frame?

Page 6: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

FramingFramingFramingFraming Approachespp

Sentinel (like C strings) Length-based (like Pascal strings)

Clock based Clock based

Characteristics Bit- or byte-oriented Fixed or variable length Data-dependent or data-independent length

Page 7: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SentinelSentinel--Based FramingBased FramingSentinelSentinel--Based FramingBased Framing Basic idea: identify start/end of frame with y

special “marker” Byte pattern, bit pattern, signal pattern

Challenge: what if marker is in data stream

Solution: “stuffing” recode data to prevent marker from occurringmarker from occurring

Page 8: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

ByteByte--oriented Sentintelsoriented SentintelsByteByte--oriented Sentintelsoriented Sentintels STX – start of text

ETX d f ETX – end of text Problem: what if ETX appears in the data portion of the frame? Solution

If ETX appears in the data introduce a special character DLE (Data If ETX appears in the data, introduce a special character DLE (Data Link Escape) before it

If DLE appears in the text, introduce another DLE character before it Efficiency can be only 50%

P t l l Protocol examples BISYNC, PPP, DDCMP

ETX

STX ETXBODYHEADER

0x48 0x69 ETXDLE 0x690x48ETX0x48 0x69 ETXDLE 0x690x48

Page 9: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS)Stuffing (COBS)Stuffing (COBS)Stuffing (COBS)

Run length encoding applied to byte stuffing Add implied 0 to end of frame Each 0 is replaced with (number of bytes to next 0) + 1 What if no 0 within 255 bytes? – 255 value indicates 254

bytes followed by no zerobytes followed by no zero Worst case – no 0’s in packet – 1/254 overhead

Appropriate for very low-bandwidth links

Code Followed by Meaning0x00 (not applicable) (not allowed)0x00 (not applicable) (not allowed)0x01 No data bytes A single zero byten (n-1) data bytes Data followed by 00xFF 254 data bytes Data, no following 00xFF 254 data bytes Data, no following 0

Page 10: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

LengthLength--Based FramingBased FramingLengthLength--Based FramingBased Framing End of frame

Calculated from length sent at start of frame Challenge: Corrupt length markers

Examples DECNET’s DDCMP:

» Byte-oriented, variable-length RS-232 framing:

» Bit oriented implicit fixed length» Bit-oriented, implicit fixed-length

LENGTH BODYHEADER

Page 11: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

ClockClock--Based FramingBased FramingClockClock--Based FramingBased Framing Continuous stream of fixed-length framesg Clocks must remain synchronized

No bit or byte stuffing

Example: Synchronous Optical Network (SONET)

Problems: Frame synchronization Clock synchronization

Page 12: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SONETSONETSONETSONET All frames (STS formats) are 125 μsec long Problem: how to recover frame synchronization

2-byte synchronization pattern starts each frame (unlikely in data) Wait until pattern appears in same place repeatedly

Problem: how to maintain clock synchronization NRZ encoding, data scrambled (XOR’d) with 127-bit pattern Creates transitions

Al d h f fi di f l tt Also reduces chance of finding false sync. pattern

………Overhead Payload

s …………………

9 ro

ws

90 bytes

Page 13: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SONET MultiplexingSONET MultiplexingSONET MultiplexingSONET MultiplexingSTS-1FH STS 1FH

STS-1FH STS-3FH

STS-3 has the payloads of three STS-1’s byte-

STS-1FH

STS-3 has the payloads of three STS-1 s byte-wise interleaved.

For STS-N frame size is always 125 microsec For STS N, frame size is always 125 microsec STS-1 frame is 810 bytes STS-3 frame is 810x3 =2430 bytesy

Page 14: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SONETSONETSONETSONET STS-1 merged bytewise round-robin into STS-3 Unmerged (single-source) format called STS-3c Problem: simultaneous synchronization of many distributed

clocks

not too difficult to synchronize clocks such that first byte of yall incoming flows arrives just before sending first 3 bytes of outgoing flow

Page 15: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SONETSONETSONETSONET

... but now try to synchronize this network’s clocksnetwork s clocks

Page 16: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Error DetectionError DetectionError DetectionError Detection Goal: validate “correctness” of frame Idea: send additional redundant data with frame to

check if it has been damaged

Checked at many layers Physical (e.g. modulation) Datalink (e.g. cyclic redundancy check) Network/Transport (e.g. IP Checksum) Application (e.g. MD5 hash)

Today: simple parity, redundancy w/voting, 2 dimensional parity, IP checksum, CRCsp y, ,

Page 17: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Error Detection from 10 000 feetError Detection from 10 000 feetError Detection from 10,000 feetError Detection from 10,000 feet• EDC= Error Detection bits (redundancy)• D = Data protected by error checking may include header fields• D = Data protected by error checking, may include header fields • Error detection not 100% reliable!

• Protocol may miss some errors, but rarely• Larger EDC field yields better detectionLarger EDC field yields better detection

Page 18: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

ParityParityParityParity 1-bit error detection with parityp y

Add an extra bit to a code to ensure an even (odd) number of 1sEvery code word has an even (odd) number of 1s Every code word has an even (odd) number of 1s

011 11101 11

1000

Valid code

words

010 110

100000

Parity Encoding:

White – invalid ( ) 101001(error)

Page 19: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

VotingVotingVotingVoting 1-bit error correction with voting 1 bit error correction with voting

Every codeword is transmitted n times

011 111010 110

100000

Voting:

White – correct to 1

Blue - correct to 00 1

Valid code

words

101001

Page 20: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Hamming DistanceHamming DistanceHamming DistanceHamming Distance The Hamming distance between two code words is the minimum

number of bit flips to move from one to the othernumber of bit flips to move from one to the other Example: 00101 and 00010 Hamming distance of 3g

The minimum Hamming distance of a code is the minimum distance over all pairs of codewords

Minimum Hamming Distance for parity 2 Minimum Hamming Distance for parity = 2 Minimum Hamming Distance for voting = 3

N-bit error detection No code word changed into another code word Requires Minimum Hamming Distance of N+1

Page 21: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

TwoTwo--Dimensional ParityDimensional ParityTwoTwo--Dimensional ParityDimensional Parity

Use 1-dimensional parity Add one bit to a 7-bit code to ensure an

even/odd number of 1sParity Bits even/odd number of 1s

Add 2nd dimension Add an extra byte to frame

» Bits are set to ensure even/odd number of

1

0

1

0101001

1101001

1011110Data1s in that position across all bytes in frame

Comments Catches all 1- 2- and 3-bit and most 4-bit

1

1

0

0001110

0110100

1011111 Catches all 1 , 2 and 3 bit and most 4 bit errors

0

1111011 0Parity Byte

1011111

Page 22: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Internet ChecksumInternet ChecksumInternet ChecksumInternet Checksum Idea

Add ll th d Add up all the words Transmit the sum

Internet Checksum 1’s complement of the 1’s complement sum on 16bit codewords 1 s complement of the 1 s complement sum on 16bit codewords Example

» Message: e34f 2396 4427 99f3» 2s complement sum is 1e4ff» 1s complement sum is e4ff + 1 = e500» 1s complement sum is e4ff + 1 = e500» Checksum is 1aff

Comments VERY easy to implement, fast incremental updates Not very robust

Page 23: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

IP ChecksumIP ChecksumIP ChecksumIP Checksumu_short cksum(u_short *buf, int count) {

register u_long sum = 0;while (count--) {

sum += *buf++;if (sum & 0xFFFF0000) {if (sum & 0xFFFF0000) {/* carry occurred, so wrap around */

sum &= 0xFFFF;sum++;

}}return ~(sum & 0xFFFF);

}

Page 24: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Cyclic Redundancy Check Cyclic Redundancy Check (CRC)(CRC)(CRC)(CRC)

Polynomial code Treat packet bits a coefficients of n-bit polynomial

» Message = 10011010» Polynomial

= 1 x7 0 x6 0 x5 1 x4 1 x3 0 x2 1 x 0= 1 x7 0 x6 0 x5 1 x4 1 x3 0 x2 1 x 0 = x7 x4 x3 x

Choose r+1 bit generator polynomial (well known – chosen in advance)

Add r bits to packet such that message is divisible by generator polynomial

Note: easy way to think of polynomial arithmetic mod 2» Multiplication: binary addition without carries» Multiplication: binary addition without carries» Division: binary subtraction without carries

Better loss detection properties than checksums

Page 25: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Error Detection Error Detection –– CRCCRCError Detection Error Detection –– CRCCRC View data bits, D, as a binary number Choose r+1 bit pattern (generator) G Choose r+1 bit pattern (generator), G Goal: choose r CRC bits, R, such that

<D,R> exactly divisible by G (modulo 2) Receiver knows G divides <D R> by G If non zero remainder: error Receiver knows G, divides <D,R> by G. If non-zero remainder: error detected!

Can detect all burst errors less than r+1 bitsWidely used in practice (Ethernet FDDI ATM) Widely used in practice (Ethernet, FDDI, ATM)

Page 26: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

Common Generator PolynomialsCommon Generator PolynomialsCommon Generator PolynomialsCommon Generator Polynomials

CRC-8 x8 x2 x1 1

CRC 10 x10 x9 x5 x4 x1 1CRC-10 x10 x9 x5 x4 x1 1

CRC-12 x12 x11 x3 x2 x1 1

CRC-16 x16 x15 x2 1

CRC-CCITT x16 x12 x5 1

CRC-32 x32 x26 x23 x22 x16 x12 x11 x10 x8 x7 x5 x4 x2 x1 1

Page 27: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

CRC CRC –– Example EncodingExample EncodingCRC CRC –– Example EncodingExample Encoding

x3 x2 1 = 1101 Generator

11011101 10011010000 Message plus k

x3 x2 1 = 1101 Generatorx7 x4 x3 x = 10011010 Message

10011101

10001101

k + 1 bit check sequence c,

equivalent to a

zeros

R lt1011

1101

11001101

qdegree-k

polynomialResult:

Transmit message followed by1100

10001101

1011101Remainder

followed by remainder:

10011010101101m mod c10011010101

Page 28: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

CRC CRC –– Example Decoding Example Decoding ––No ErrorsNo ErrorsNo ErrorsNo Errors

x3 x2 1 = 1101 Generator

1101 10011010101 Received

x3 x2 1 = 1101 Generatorx10 x7 x6 x4 x2 1 = 10011010101 Received Message

10011101

10001101

k + 1 bit check sequence c,

equivalent to a

message, no errors

R lt1000

10111101

11001101

equivalent to a degree-k

polynomialResult:

CRC test is passed1100

11011101

1101Remainder0m mod c

Page 29: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

CRC CRC –– Example Decoding Example Decoding ––with Errorswith Errorswith Errorswith Errors

x3 x2 1 = 1101 Generator

11011101 10010110101 Received

message

x3 x2 1 = 1101 Generatorx10 x7 x5 x4 x2 1 = 10010110101 Received Message

10001101

10111101

k + 1 bit check sequence c,

equivalent to a

message

R lt

Two bit errors

11011101

qdegree-k

polynomial

01011101

Result:

CRC test failed0101

Remainder

m mod c

Page 30: CSE 123 Computer NetworksBISYNC, PPP, DDCMP ETX STX HEADER BODY ETX 0x48 0x69 0x48 DLE ETX 0x69 ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS) Run length encoding

SummarySummarySummarySummary Framingg

Bunching bits into distinct messages (frames) Challenge is in finding where one frame starts and another

beginsbegins

Error detection Determine if frame is corrupted by checking it against

redundant data

Next time (one week from next Monday): more on the e e (o e ee o e o day) o e o edatalink layer Media access

Read 2 6 2 7 2 8 Read 2.6, 2.7, 2.8