CSIS 625 Week 5
Error Detection & Correction
Copyright 2001 and 2002 – Daniel R. Oelke
For use by students of CSIS 625 for purposes of this class only.
- Overview
- Error Control
- Error Detection
- Error Correction
- Data Link Layer
- Line Discipline
- Flow Control
- Error Control
- Byte Oriented Link Control
- Bit Oriented Link Control
- HDLC
- Error Detection
- Errors always occur during transmission
- Point of Error Detection is to detect these errors so we can correct them.
- Some systems fix these errors by re-transmission.
- Some systems fix these errors using Forward Error Correction (FEC)
- Vocabulary
- Bit Error - an error that changes only one bit
- Burst Error - an error that changes several adjacent bits.
- Coding Violations - When the line coding mechanism tells us of an error.
- Need to use something like Bipolar-AMI, 8b10b, etc.
- Error Detection - Parity Bits
- Parity Bit - one extra bit of data sent with every data packet.
- Even Parity - The extra bit is set so that the number of bits is always even
- Odd Parity - The extra bit is set so that the number of bits is always odd
- Receiver checks parity and discards data if parity is not valid
- Regular parity is also known as Vertical Redundancy Check
- Parity term is sometimes mis-used to refer to any redundant bit
- Error Detection - BIP
- BIP-8 - Bit Interleaved Parity - 8 bits
- BIP is also known as Longitudinal Redundancy Check
- Takes bytes and calculates a parity bit for each bit position
- Provides better detection for burst errors.
- It is technically possible to have BIP-16 or BIP-32
- Not commonly seen
- BIP-8 is by far the most common system.
- Error Detection - Checksum
- Checksum - a byte added to the end of the frame to catch errors
- Simplest form is calculated by adding up all the bytes in the frame
- There are several algorithms - so check specifics on any one algorithm
- BIP-8 is sometimes called a checksum
- Start with 0x00 and do bitwise XOR of every byte in the message
- Checksums do not catch all kinds of errors.
- For example: They don’t catch blocks of data being re-arranged.
- Error Detection - CRC
- CRC - Cyclic Redundancy Check
- Catches many errors that Parity or BIP-8 will miss.
- Adds bits to the end of a frame so that it can be evenly divided by a number
- Usually 8, 16, or 32-bit CRC
- Easy to implement in hardware with shift register and feedback xor’s.
- See book for examples
- CRC - Strength
- CRC’s are considered quite strong
- All bursts of errors £
r (r = length of CRC)
- All odd number of errors
- Probability of missing error
- if burst is r+1 => 0.5r-1 (0.532-1 = 4.6E-10)
- if burst is >
r+1 => 0.5r (0.532 = 2.3E-10)
- See also: http://www.ross.net/crc/
- Error Rates - BER
- BER - Bit Error Rate - the probability of a bit being changed
- Used to describe transmission lines
- All transmission lines have some non-zero BER
- Calculate by counting the number of errors and dividing by the number of bits through the system.
- Need to adjust for errors that occur but are not detected
- For example - an odd number of errors when using parity
- Normal practice is to measure 10 times the period to report a BER
- This means that to state the line has a 1E-10 error rate (or better) you must measure 1E+11 bits
- A T1 would require 18 hours to have 1E+11 bits go through.
- BER and real transmission systems
- Voice sounds ok at BER of 1E-5
- Voice till intelligible at BER of 1E-3
- Data doesn’t work very well at BER below 1E-7
- Retransmission of packets occurs so often that it is difficult to get a very high data rate.
- Error Correction
- FEC - Forward Error Correction
- FEC – A method by which errors in received data can be corrected without requiring retransmission
- Sometimes it is advantageous to correct an error instead of just detecting it.
- May take too long for retransmission to occur
- Real-time Data may not be able to wait for the round trip time
- May not be possible to ask for retransmission
- One way transmissions – Satellite, Broadcast data, etc.
- Brute force method:
- Send data repeatedly
- To correct n errors, send data 2n+1 times
- Not very efficient - there are better ways.
- This is almost never used in real systems.
- Hamming codes or Reed-Solomon codes do it much more efficiently
- Hamming Distance
- Hamming distance - the number of bits that have to be changed to go from one valid code to another.
- To detect d errors -Hamming distance of d+1
- parity gives a Hamming distance of 2, so it detects up to one bit error
- To correct d errors - Hamming distance of 2d+1
- Need to be able to distinguish "closest" valid code
- Hamming Code
- A symbol is a block of bits to be transmitted from source to destination.
- Hamming Code - an error correcting code to correct 1 bit error in a symbol
- For 4 data bits, 3 redundancy bits needed
- For 8 data bits, 5 redundancy bits needed
- Hamming Codes may also be used to detect up to 2 bit errors in the code word.
- Rule for Hamming Codes:
- (d + p + 1) £
2P
- d = message bits (data)
- p = redundant bits (parity
- Codes often notated as (c,d)
- c = code size or d + p
- Therefore a (12,8) code has 8 data bits and 4 parity bits.
- A 50% overhead.
- (12 + 1) < 24
- To handle burst errors, multiple codes can be interleaved.
- Errors normally occur in bursts.
- Hamming code can handle only one bit error in the code word.
- Solution is to spread out the bits so that more than one won’t be hit by a burst of errors.
- Perfect code – an error correcting code where all possible codes are within hamming distance of a symbol.
- No "wasted" space in the code.
- Most efficient code that is possible for that symbol size, and code size.
- For Hamming codes a perfect code is when there is equality in the Hamming Code equation above
- (7,4) code is an example – m = 4, r = 3
- (4 + 3 + 1) = 23
- Reed-Solomon codes
- Another error correcting code
- Designed to have redundant symbols
- Allows for whole symbols to be errored
- It handles bursts of errors
- Common applications
- CD Players,
- Spacecraft communication
- DSL lines
- Notation - RS(NN,KK)
- MM - the code symbol size in bits
- NN - the block size in symbols (2**MM - 1)
- KK - the number of data symbols per block
- KK < NN
- Can correct (NN-KK)/2 errors per block
- If known that there are missing symbols, then RS can correct NN-KK "erasures"
- Common Reed Solomon Codes
- RS (255,223)
- Sends 255 8 bit characters, 223 of them are data and 32 are parity
- Can correct 16 errors or 32 erasures
- RS(204,188) - Used in Digital Video
- Sends 204 8 bit characters, 188 of them are data and 16 are parity
- Can correct 8 symbol errors
- Can be done on other than 8-bit characters
- More on FEC
- FEC is often used to improve the BER of lines.
- Can be more cost effective than boosting the power sent over the line
- Retransmission at higher levels may not be practical
- Error Correcting web pages
- http://www.piclist.com/techref/method/errors.htm
- http://people.qualcomm.com/karn/code/fec/
- http://www.engelschall.com/u/sb/hamming/
- Line Discipline
- Line Discipline defines who can send and when they can send.
- Simplex system
- Who is always known
- When is usually any time
- ENQ/ACK system
- Used in point to point systems
- Process
- Sender sends a ENQ (Enquiry) to the intended receiver.
- Receiver sends back an ACK (Acknowledgement) when it is ready to receive
- Sender sends data
- Sender sends EOT (End of Transmission) when done sending.
- Receiver may send a NAK (Negative Acknowledgement) if it isn’t ready.
- Common to have one node a primary and another a secondary
- Primary is responsible for initiating communication
- Some systems have nodes as peers
- Either can initiate a transfer
- In full-duplex system, data and control messages can be sent simultaneously
- Poll & Select system
- Always has a primary and secondary nodes
- May be point-to-point or multi-point
- Process - Poll
- Primary node requests data from the secondary
- If no data, secondary responds with a NAK
- Otherwise secondary responds with the data, and the primary ACKs this data.
- Process - Select
- Primary node sends message to secondary
- Secondary responds with ACK if it can accept data
- Primary sends data to secondary
- Secondary responds with ACK after successful transfer of data
- Network Addresses
- In a multi-point system, addresses needed so that nodes know who is talking to who
- Simple in some systems where physical position or dip-switch sets it.
- Ethernet defines that all manufactures of devices include a unique 48-bit (6-byte) address in every device.
- Polling 2^48 devices isn’t practical
- at 10Mbps, with a 60 byte poll it would take
- 2^24 / 10Mbps * 60 * 8 bytes = 1.35E+10 seconds
- or about 428 years
- Media Access Control
- MAC - Media access Control
- A multipoint network with no clear master and slave.
- master == primary
- slave == secondary
- In this system, there needs to be more complicated protocol than ENQ/ACK or select/poll to figure out who sends when
- See later on in this lecture….
- Flow Control
- Flow control - a protocol to ensure that the sender does not overwhelm a receiving station
- Incoming data must be checked and processed before it can be used
- This is often slower than the transmission rate
- Receivers need to buffer received data until it is processed
- Buffers are always limited
- Stop-n-Wait
- Stop and Wait flow control is simplest form of flow control
- Process
- Sender sends one frame of data
- Sender waits for ACK before sending more
- Receiver can slow down process by waiting to send ACK
- May be simple - but it is inefficient
- Stop-n-Wait efficiency
- Entire set of data is divided into n frames
- t
prop = time to go from sender to receiver
- depends on distance and medium
- t
frame = time to send one data frame
- depends on bit rate and frame size
- TD = n(2 tprop + tframe) = Time to send data
- Actual transmission of data is n* tframe
- Efficiency is (n* tframe )/ n(2 tprop + tframe)
- = 1 / (1 +2(tprop / tframe))
- If tprop is small and tframefor frame is large, it approaches 100%, but never reaches it.
- Sliding Window Protocol
- Sliding Window flow control allows for more than one frame to be sent before an acknowledgement is received
- frames are numbered from 0 to n-1
- Sender sends frames up until it has sent n-1 frames
- Receiver sends back an ACK with the number of the next frame it expects
- Sender can now send up to this new number
- Maximum window size is n-1 frames
- Sliding Window Efficiency
- If the sliding window is big enough, and the receiver is fast enough, then 100% efficiency can be achieved
- To get 100% -
- 2 * t
prop £
((n - 1) * tframe )
- t
prop = Time for a frame to propagate from one end to the other of the system
- t
frame = Time to send a frame (based on frame size and bit rate)
- Error Control
- Error Control is the use of error detection combined with retransmission of data that has had an error detected in it.
- Error detection is achieved
- using parity, checksums, CRC, etc
- Extra data added to each frame
- ARQ - Automatic Repeat Request
- This abbreviation isn’t really used much
- Stop-n-Wait Error Control
- Extension of Stop-n-Wait flow control
- When a good frame is received, an ACK sent back to originator.
- When a damaged frame is received, a NAK is sent back to originator
- When a NAK is received, the same frame is retransmitted
- Any frame may be dropped - data or NAK or ACK.
- If ACK isn’t received after some time, a NAK is assumed
- If a NAK is lost - timeout and retransmission
- If a ACK is lost timeout and retransmission
- Frames must be numbered so receiver can throw away duplicates
- If data is lost - timeout and retransmission
- Has same efficiency issues
- Go-back-N Error Control
- Uses a Sliding window
- If a NAK is received or an ACK timeout occurs
- all data since last ACK received is resent
- This may be several frames
- ACKs contain next expected frame number
- NAKs contain errored frame number
- Selective-Reject Error Control
- Uses a Sliding window
- If a NAK is received, only the damaged frame is resent
- Selective Reject is more complicated to implement
- Receiver must contain the sorting logic to enable it to reorder frames
- Sending device must contain searching mechanism to enable it to find and select only the requested frame for retransmission
- Buffer in the receiver must keep all previously received frames on hold
until all retransmissions have been sorted, duplicates identified and discarded
- ACK numbers must refer to the frame received instead of next frame expected
- More efficient as it resends less data
- If errors don’t occur very often - there isn’t a big difference in efficiency
- Selective Reject is rarely implemented over Go-back-N method
- Complication makes it slower to get products made
- Increased Efficiency is minimal and not worth the extra effort
- Byte Oriented Link Control
- List
here is all from Modem communications world
- Normally people don’t address these as link layer controls
- Not just data-link as most of these protocols addressed issues of file-transfer
- XMODEM
- Stop-n-Wait error control
- Fixed data field of 128 bytes, CRC-8
- YMODEM
- increased data field to 1024 bytes, CRC-16
- ZMODEM
- More features
- Sliding window
- Kermit
- sliding window
- Also a terminal emulation package
- BSC - Binary synchronous communication
- Few people care about this one
- Bit Oriented Link Control
- Many bit Oriented protocols today are oriented around HDLC
- Ethernet, Token-Ring and other LAN technologies are also bit-oriented
- SONET, T1, and most telephony systems are bit-oriented.
- It is common to use HDLC over a SONET or T1 system
- HDLC – High-Level Data Link Control
- HDLC node types
- Primary station
- Has complete control over the link
- Can be used in point-to-point or multi-link
- Secondary station
- Receives commands from the primary and responds accordingly
- Combined station
- Can both command and respond to commands
- Used in peer to peer (or balanced) configurations
- HDLC Configurations
- Unbalanced
- One primary node and one or more secondary nodes
- May be point-to-point or multi-point
- Full or half-duplex
- Balanced
- point-to-point topology only
- Both nodes are combined stations
- HDLC Modes of Communication
- NRM - Normal Response mode
- Standard Primary-secondary relationship
- Secondary can transmit only when polled
- ARM - Asynchronous Response Mode
- A secondary may initiate a transmission without permission from the primary
- ABM - Asynchronous Balanced Mode
- Combined stations - either can initiate
- Point-to-point topology
- HDLC Frame structure
- Frame of data consists of:
- Flag: 8 bits
- Address: 1 or more bytes
- Control: 8 or 16 bits
- Information: many bits
- Frame Check Sequence (FCS): 16 or 32 bits
- Flag: 8 bits
- HDLC Flag byte
- The flag is a special bit pattern that signifies the start/end of a frame.
- A single flag byte may be used to end one frame and start another
- Flag bit pattern is 0111 1110
- Bit stuffing is used to make sure this pattern does not occur any where else.
- Bit stuffing occurs on all bytes (control or data) that are not flag bytes
- HDLC Address field
- First seven bits are used for address
- Last bit - if a 1 then there are no more address bytes
- Last bit - if a 0 then there is another address byte
- Last bit of last address byte is always a 1
- Number of address bits is a multiple of 7
- HDLC Control Field
- One or two byte segment for flow management
- Control fields change based on type of frame
- If first bit is 0
- frame is an I-Frame
- If first bit is 1 and second 0
- frame is an S-Frame
- If first bit is 1 and second 1
- frame is a U-Frame
- I-Frame - Information Frame
- 3 bits for send sequence number
- 3 bits for receive sequence number (ACKs)
- 1-bit - Poll/Final bit
- From secondary - set to 1 if last I-frame of response
- From primary - set to 1 if polling secondary for data
- S-Frame - Supervisory Frame
- 3 bits for receive sequence number
- 2 bits for "supervisory" functions
- 1 bit - Poll/final bit
- S-Frames used for ACK when no data
- U-Frame - Unnumbered frame
- 1 bit- Poll/Final bit
- 5 bits - "Unnumbered function" bits
- S-frames can be used for:
- reject
- selective rejects
- receiver ready
- receiver not ready
- U-frames can be used for
- Mode setting (primary/secondary)
- unnumbered information transfer
- recovery - bad commands, etc
- initialization
- disconnect
- test command/response
- HDLC - Information field
- The information field is a series of bits until the next flag byte is found
- S-Frame has no information field
- The last 16 or 32 bits of the Information field is actually the FCS
- FCS - Frame check sequence
- a 16 or 32-bit CRC on the data