280 likes | 512 Views
Part 2: Packet Transmission. Packets, frames Local area networks (LANs) Wide area networks (LANs) Hardware addresses Bridges and switches Routing and protocols. Packets, frames and error detection. Packets and frames Control data and byte stuffing
E N D
Part 2: Packet Transmission Packets, frames Local area networks (LANs) Wide area networks (LANs) Hardware addresses Bridges and switches Routing and protocols
Packets, frames and error detection • Packets and frames • Control data and byte stuffing • Error detection - parity bits, checksums and cyclic redundancy checks
Packets • Most networks transmit data in small blocks called packets • helps to detect transmission errors • gives fair access for a shared connection between many computers • These are packet networks or packet switching networks
An example of fair access A wants to send a 5 megabyte file to C network speed is 56,000 bits per second B wants to send a 10 kilobyte file to D
Packets and time division multiplexing • Packet networks use a form of TDM
Packets and hardware frames • Each type of hardware defines its own format/wrapping for a packet called a frame
Simple example of framing • A frame may include “unused” control data values to mark both its beginning and end • Advantage is error detection: • transmitter crashes => eot will not arrive • receiver crashes => soh marks next valid frame • Disadvantages: • requires two extra characters per frame • cannot carry arbitrary values (e.g, soh and eot)
Byte stuffing • So control characters can be included in data • Reserve a special character to mark the occurrence of control characters • Transmitter scans data block and replaces all occurrences of control characters. Receiver performs the reverse mapping. Character in data Characters sent soh esc x eot esc y esc esc z
An example of byte stuffing Frame before byte stuffing Frame after byte stuffing
Transmission Errors • Much of the complexity of networks arises from susceptibility to interference that can cause: • transmitted data to be lost or changed • random data to appear • Single-bit errors versus burst errors
Error Detection and Correction • First we need to detect errors • Sender includes some extra (redundant) information that summarises the original data • Receiver checks this • Various schemes, differing in complexity, data overhead and robustness • Then we need to decide what to do • Error correction • Retransmission
Parity bits and parity checking • Count number of 1 bits in the data and add an extra parity bit to make this odd or even • even parity - parity bit is set so that total number of 1s is even - 1011001 => parity bit 0 • odd parity - total 1s should be odd - 1011001 => parity bit 1 • Transmitter calculates and adds, receiver calculates and checks • Introduces additional costs • Only detects limited types of errors
Other error detection methods • Other methods include checksums and cyclic redundancy checks • These can be compared according to: • amount of extra data to be transmitted • amount of extra computation involved • types of errors that are detected • Note the difference between detecting that an error occurred and knowing how to fix it
Checksums • Interpret the data as if it were a sequence of integers and add them together to get an integer result called a checksum • Add in any carry bits too • Append the checksum to the frame • 16 and 32 bit checksums are common and are usually computed for a whole packet
Evaluation of checksums • Data overhead - 16 or 32 bits • Computational overhead - simple additions • Undetected errors - some periodic reversal of bits (e.g., reversing one bit in each of four data items)
Example failure of checksums data item (binary) 0001 0010 0011 0001 totals checksum value 1 2 3 1 7 data item (binary) 0011 0000 0001 0011 totals checksum value 3 0 1 3 7
Cyclic redundancy checks (CRCs) • Detects more errors than checksums and only requires simple hardware • Based on binary division rather than addition
Overview of CRC • Uses binary division instead of addition • Sender wants to send D, a piece of data d bits long • Sender and receiver agree a generator, G, a bit pattern that is r + 1 bits long • Sender appends R (an additional sequence of r bits) to D so that the resulting sequence is exactly divisible by G using binary (modulo 2) arithmetic • Receiver divides the received bit pattern by G and checks whether the remainder is 0
d bits r bits D: Data bits R: CRC bits • Can detect burst errors of less than r +1 bits and odd number of bit errors • Can detect burst errors of length greater than r + 1 with probability 1 – 0.5r
CRC - hardware components Exclusive or (xor) unit
CRC - hardware components Shift register
CRC - combining components • Combine 3 shift registers and 3 xor units • Initialise registers and then feed in the bits of the message one at a time • Final state gives the CRC - calculated by both the transmitter and receiver
Evaluation of CRCs • Data overhead - 16 or 32 bits • Computational overhead - low - combines simple hardware devices • Types of errors - good for burst errors - changes to several bits in one location that may be caused by a sudden interference (e.g. by lightening)
Why do CRCs work? • Mathematical analysis is beyond our scope • Intuition • each single bit of the message dramatically affects the whole CRC (feeds into three places) • the effect of each bit loops through the process several times (the registers are connected into a cycle)
Revised frame format • Frames now contain a data block, framing information and error detection information • Transmitter does: data -> byte stuffing -> framing -> error detection and receiver does the reverse
Summary • Packets and frames • Control data and byte stuffing • Error detection - parity bits, checksums and cyclic redundancy checks