1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

25
1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs

Transcript of 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

Page 1: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

1

Chapter 7Chapter 7

Switching, Packets, Frames, Parity,

Checksums, and CRCs

Page 2: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

2

Smallest piece of information

Smallest piece of information

When you send a message between two hosts, the smallest piece of information may be:

BitCharacter (e.g. RS232)

Page 3: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

3

Switching Switching

When should this piece of information be sent?

As soon as it is available -> circuit switchingWhen the entire message is ready -> message

switchingAfter X number of bits/characters -> packet

switching

Page 5: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

5

Connecting to the Network

The Problem

Connecting to the Network

The ProblemCannot afford individual network connection

per pair of computersReasons

Installing wires consumes time and moneyMaintaining wires consumes money (esp. long-

distance connections)

Page 6: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

6

SolutionSolution

Network has Shared central coreMany attached stations

Page 7: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

7

The Problem With SharingThe Problem With Sharing

Demand highSome applications have large transfersSome applications cannot waitNeed mechanism for fairness

Page 8: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

8

Packet Switching PrinciplePacket Switching Principle

Solution for fairnessDivide data into small units called packetsAllow each station opportunity to send a packet

before any station sends anotherForm of time-division multiplexing

Page 9: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

9

Illustration of Packet Switching

Illustration of Packet Switching

Acquire shared mediumSend one packetAllow other stations opportunity to send

before sending again

Page 10: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

10

Packet DetailsPacket Details

Depend on underlying networkMinimum / maximum sizeFormat

Hardware packet called a frame

Page 11: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

11

Example Frame Format Used with RS-232

Example Frame Format Used with RS-232

RS-232 is character-orientedSpecial characters

Start of header (soh)End of text (eot)

Page 12: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

12

When Data Contains Special Characters

When Data Contains Special Characters

Translate to alternative formCalled byte stuffingExample

Page 13: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

13

Illustration of Frame With Byte Stuffing

Illustration of Frame With Byte Stuffing

Stuffed frame longer than originalNecessary evil

Page 14: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

14

Handling ErrorsHandling Errors

Data can be corrupted during transmissionBits lostBit values changed

Frame includes additional information to detect / correct error

Set by senderChecked by receiver

Statistical guarantee

Page 15: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

15

Error Detection And Recovery TechniquesError Detection And Recovery Techniques

Parity bitOne additional bit per characterCan use

Even parityOdd parity

Cannot handle error that changes two bits

Page 16: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

16

Error Detection And Recovery Techniques

(continued)

Error Detection And Recovery Techniques

(continued)Checksum

Treat data as sequence of integersCompute and send arithmetic sumHandles multiple bit errorsCannot handle all errors

Page 17: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

17

Error Detection And Recovery Techniques

(continued)

Error Detection And Recovery Techniques

(continued)Cyclic Redundancy Check (CRC)

Mathematical function for dataMore complex to computeHandles more errors

Page 18: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

18

Example Checksum Computation

Example Checksum Computation

Checksum computed over dataChecksum appended to frame

Page 19: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

19

Illustration Of ErrorsA Checksum Fails to

Detect

Illustration Of ErrorsA Checksum Fails to

Detect

Second bit reversed in each itemChecksum is the same

Page 20: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

20

Building Blocks For CRCBuilding Blocks For CRCExclusive or

Shift register

a shows status before shiftb shows status after shiftOutput same as top bit

Page 21: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

21

Example Of CRC HardwareExample Of CRC Hardware

Computes 16-bit CRCRegisters initialized to zeroBits of message shifted inCRC found in registers

Page 22: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

22

Example CRC ComputationExample CRC Computation

Input data is all 1 bitsCRC shown after 15, 16, and 17 bits shiftedFeedback introduces zeroes in CRC

Page 23: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

23

Illustration of Frame Using CRC

Illustration of Frame Using CRC

CRC covers data only

Page 24: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

24

SummarySummary

Packet technologyInvented to provide fair access in shared networkSender divides data into small packets

Hardware packets called framesCan use packet-switching with RS-232

Special characters delimit beginning and end of frameByte-stuffing needed when special characters appear in

data

Page 25: 1 Chapter 7 Switching, Packets, Frames, Parity, Checksums, and CRCs.

25

Summary (continued)Summary (continued)

To detect data corruptionSender adds information to packetReceiver checks

TechniquesParity bitChecksumCyclic Redundancy Check (CRC)Provide statistical guarantees