31
Introduction to Computer Networks Tian Song (嵩天), Ph.D., Assoc. Prof. [email protected]

Introduction to Computer Networks - bit-netlab.org · Assign sequence numbers to outgoing frames, so that the receiver can distinguish proper retransmissions ... Generator polynomial

Embed Size (px)

Citation preview

Introduction to Computer Networks

Tian Song (嵩天), Ph.D., Assoc. [email protected]

Introduction to Computer Networks

Tian Song (嵩天), Ph.D., Assoc. [email protected]

Design Issue and Error Correction

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian3

Outline

• Design of Data Link Layer 

• Framing

• Error Correction

• Example: PPP

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian4

Data Link LayerBasic Services:

–Network layer passes a number of bits (frame) to the data link layer.

– Data link layer is responsible for transmitting the frame to the destination machine.

– Receiving layer passes received frame to its network layer.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian5

Data Link Layer• Data link layer is responsible to transmit bits from source to destination

• Three jobs: framing, error control, and flow control(a) Virtual communication.     (b) Actual communication.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian6

Data Link LayerDuty:

Transmit a set of 0 and 1 without error

Question:

How a data frame can be reliably transmit?

How a shared channel can be accessed? 

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian7

Framing

Question:

How to encapsulate a bit stream into frames?

(1) Character count 

(2) Flag byte

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian8

Framing: Character Count

A character stream.   (a) Without errors.   (b) With one error.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian9

Framing: Flag ByteMark the beginning and end of a frame with a flag byte 

Byte stuffing

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian10

Framing: Flag ByteMark the beginning and end of a frame with a 01111110 

For a given sequence (a), then…

bit stuffing

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian11

FramingThinking about byte stuffing and bit stuffing:

Pros:practical way to frame a bit streaming

Cons:the length of frames depend on the original bits 

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian12

Error Correction

Question:

How to detect or correct transfer errors of frames? 

发现 纠正

What kind of errors there are in the transmission?

(1) frame lost

(2) bit error (error in flags, error in content)

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian13

Frame LostHow to solve “frame lost”?

Acknowledgement: 

Receiver sends back to sender special control frames  

Timer:

Sender starts a timer to detect acknowledge frame

Sequencing:

Assign sequence numbers to outgoing frames, so that 

the receiver can distinguish proper retransmissions

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian14

Frame LostWhy there is “frame lost”?

Unmatched Rate: 

Fast sender will flood the slow receiver.

Two Solutions:

(1) feedback‐based flow control:

the receiver tells the sender how to send.

(2) rate‐based flow control: 

protocol has a way to limit the senders’ rate.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian15

Bit ErrorRedundant information is the key! (m+r)       

Two Philosophies

More redundant information : So, receivers can correct some errors.

Less redundant information:

So, receivers can detect errors and 

ask retransmission if there are errors.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian16

Error Correcting CodesHamming Code:

Hamming distance is the number of differences 

between two frames a and b at the same position.

E.g. the distance (d) is _______. 

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian17

Error Correcting CodesHamming Code:

Coding schema (编码方案)  example:

00000 00000

00000 11111     

11111 00000

11111 11111

Only 4 codes exist.  

The distance of coding schema is _________.

If we receive:

00000 00011

00000 00111

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian18

Error Correcting CodesHamming Codes:  To correct 1 bit error:

p1=(p1, m3, m5, m7, m9, m11)

p2=(p2, m3, m6, m7, m10, m11)

p4 =(p4, m5, m6, m7)

p8 =(p8, m9, m10, m11)

() : 偶校验

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian19

Error Correcting CodesTo correct 1 bit error:

p1=(p1, m3, m5, m7, m9, m11)

p2=(p2, m3, m6, m7, m10, m11)

p4 =(p4, m5, m6, m7)

p8 =(p8, m9, m10, m11)

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian20

Error Detecting CodesParity: (奇偶校验)

One parity bit

The parity bit is chosen so that the number of 1 bits 

in the codeword is even (or odd)

1011100__ , for odd parity, what ‘s the bit?   1

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian21

Error Detecting CodesParity is too simple, it can only detect one bit error.

Question:

How to detect k‐bit errors?

CRC: (循环冗余校验码)

Cyclic Redundancy Check

IEEE standard

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian22

Error Detecting CodesCRC: (循环冗余校验码)

Treats bit strings as representations with coefficients 

of 0 and 1 only.

E.g. Bit string 110001, as x5 + x4 + x0

also as  1x5 + 1x4 + 0x3 + 0x2 + 0x1 + 1x0

Then, the operations of two strings is XOR.

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian23

Error Detecting CodesCRC: (循环冗余校验码)

Generator polynomial (生成多项式): G(x)

• both the high‐ and low‐ order bits 

• G(x) as divisor 

So, the idea of CRC is 

add some checksum to the string, so the new string 

can divide G(x) without reminder. 

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian24

Error Detecting Codes

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian25

Error Detecting CodesCRC: (循环冗余校验码)

r‐bit checksum can detect <= r‐bit errors.

E.g. G(x) = 10011, the max detect error is _____?

CRC‐12 =x12+x11+x3+x2+x1+1

CRC‐16 =x16+x15+x2+1

CRC‐CCITT =x16+x12+x5+1

CRC‐32     (The max detect error of CRC‐32 is _____?)

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian26

Example: PPPPPP: (Point to Point Protocol)

used in SONET and ADSL

Today, we observe framing and error correction. 

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian27

Example: PPPPPP  Framing

flag byte: 01111110 (0x7E)

how about the stuffing?

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian28

Example: PPPPPP  Framing

Byte stuffing with 0x7D and XOR 0x20

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian29

Example: PPPPPP  Error Correction:

No error correction, but error detection.

2‐byte or 4‐byte checksum. 

CRC‐16,  CRC‐32

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian30

Conclusion

• Design Issue of Data Link Layer 

• Framing

• Error Correction

• Example: PPP

School of Computer Science and Technology, BIT, http://cs.bit.edu.cn/~songtian31

End

This page is intended blank.