eec-484/584 computer networks lecture 8 wenbing zhao [email protected] (part of the slides are based...
Post on 20-Dec-2015
215 views
TRANSCRIPT
EEC-484/584EEC-484/584Computer NetworksComputer Networks
Lecture 8Lecture 8
Wenbing ZhaoWenbing Zhao
[email protected]@ieee.org(Part of the slides are based on materials supplied by (Part of the slides are based on materials supplied by
Dr. Louise Moser at UCSB and Prentice-Hall)Dr. Louise Moser at UCSB and Prentice-Hall)
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
22
OutlineOutline
• Error detection and correction
• Elementary Data Link Protocols
• Example protocols (not required for quiz)
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
33
Error-Correcting CodesError-Correcting Codes
• n-bit codeword – an n-bit unit containing data and check bits – m bits of data, r bits redundant/check bits
(n = m+r)
• How to measure the differences between two codewords (num of different bits)– Using exclusive OR and counting number of
1 bits in the result
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
44
Error-Correcting CodesError-Correcting Codes
• Hamming distance – number of bit positions in which two codewords differ
• If two codewords are a Hamming distance d apart, it will require d single-bit errors to convert one into the other
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
55
Error-Correcting CodesError-Correcting Codes
• Complete code– Complete list of all legal codewords:
2m possible data messages– Recall that there are m bits of data
• Hamming distance of the complete code– Find two codewords whose Hamming
distance is minimum
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
66
Error-Detection CodesError-Detection Codes
• A distance d+1 code can detect up to d errors, why?– If there are d+1 errors, one valid codeword
might be turned into another valid codeword– ≤ d errors will change a valid codeword into
an illegal codeword can be detected!
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
77
Error-Correcting CodesError-Correcting Codes
• To correct d errors, need a distance 2d+1 code– Legal codewords are so far part that even
with d changes, original codeword is still closer than any other codeword, so it can be uniquely determined
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
88
Error-Correcting Codes: ExampleError-Correcting Codes: Example
• Consider a code with only four valid codewords– 0000000000, 0000011111, 1111100000, 1111111111
• This code has a distance 5 can correct double errors– If 0000000111 arrives, receiver knows the original
must have been 0000011111– However, if triple error changes 0000000000 to
0000000111, the error will not be corrected properly
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
99
Parity BitParity Bit• Parity bit – a single bit is appended to the data• Parity bit is chosen so that number of 1 bits in
the codeword is even or odd• Example: Given 1011010
– With even parity 10110100
– With odd parity 10110101
• A code with a single parity bit has a distance 2– Since any single-bit error produces a codeword with
wrong parity can be used to detect single bit errors
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1010
Error-Detecting Codes: CRCError-Detecting Codes: CRC
• Polynomial code, also known as CRC (Cyclic Redundant Code)
• Treat bit string as polynomial with 0 and 1 coefficients
• m-bit frame: M(x) = bm-1xm-1 + … + b0
• E.g.: 11011010 => M(x) = x7 + x6 + x4 + x3 + x1
• Use modulo 2 arithmetic– No carries or borrows: XOR
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1111
Cyclic Redundant CodeCyclic Redundant Code• Sender and receiver agree on generator
polynomial G(x) (High & low order bits must be 1)• For a frame with m bits corresponding to M(x),
m > deg G(x) = r• Append checksum to end of frame so polynomial
T(x) corresponding to checksummed frame is divisible by G(x)
• When receiver gets checksummed frame, divides T(x) by G(x)
• If remainder R(x) != 0, then transmission error
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1212
Algorithm to Compute CRC ChecksumAlgorithm to Compute CRC Checksum
• Let m = deg M(x), r = deg G(x)• Append r 0 bits to lower-order end of frame: xrM(x)• Divide bit string corresponding to xrM(x) by bit string
corresponding to G(x)• Subtract remainder R(x) from bit string corresponding
to xrM(x), result is checksummed frame. Let T(x) be its polynomial– xrM(x) = Q(x)G(x) + R(x)– xrM(x) – R(x) = Q(x)G(x) = T(x)
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1313
Compute CRC Compute CRC ChecksumChecksum
XOR
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1414
International Standard PolynomialsInternational Standard Polynomials
• CRC-12 G(x) = x12 + x11 + x3 + x2 + x1 + 1– Used for 6-bit characters
• CRC-16 G(x) = x16 + x15 + x2 + 1CRC-CCITT G(x) = x16 + x12 + x5 + 1– Used for 8-bit characters
• CRC-32 G(x) = x32 + x26 + x23 + x22 + x16 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1– Used in IEEE 802– Detects all bursts of length 32 or less and all bursts
affecting an odd number of bits
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1515
ExerciseExercise
• Given 1011011, calculate the parity bit to be appended to the bit string– If even parity is used– If odd parity is used– If the highest order bit is inverted to 0, show
how the error can be detected
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1616
ExerciseExercise
• To provide more reliability than a single parity bit can give, an error-detecting coding scheme uses one parity bit for checking all the odd-numbered bits and a second parity bit for all the even-numbered bits. What is the Hamming distance of this code?
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1717
ExerciseExercise
• A bit stream 10011101 is transmitted using the standard CRC method described in the text. The generator polynomial is x3 + 1. Show the actual bit string transmitted. Suppose the third bit from the left is inverted during transmission. Show that this error is detected at the receiver's end.
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1818
Elementary Data Link ProtocolsElementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
1919
Initial AssumptionsInitial Assumptions
• Physical, data link, network layers are independent processes
• Sender has infinite amount of data ready to send, supplied by network layer
• “wire-like” service: DLL provides reliable, source ordered delivery service to NL
• Packet from NL is treated as pure data• When sender accepts packet from NL, it
encapsulates in a frame with a header and trailer
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2020
Initial AssumptionsInitial Assumptions
• Receiver waits for arrived of frame, which generates an interrupt
• When frame arrives at receiver, hardware computes checksum– If error then DLL informed event = chksum_err– Else DLL informed event = frame_arrival
• DLL acquires frame from physical layer, checks control info in header
• If ok then passes packet to NL
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2121
Protocol DefinitionsProtocol Definitions
Continued
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2222
Protocol DefinitionsProtocol Definitions
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2323
Protocol DefinitionsProtocol Definitions
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2424
Unrestricted Simplex ProtocolUnrestricted Simplex Protocol
• Additional assumptions– Processing time insignificant– Infinite buffer space– Communication channel never loses or
damages frames
• Uses no sequence numbers or acks– Only event type frame_arrival
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2525
Unrestricted Simplex ProtocolUnrestricted Simplex Protocol
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2626
Unrestricted Simplex ProtocolUnrestricted Simplex Protocol
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2727
Simplex Stop-and-Wait ProtocolSimplex Stop-and-Wait Protocol
• Drop assumption– Receiver processing time insignificant, or,
equivalently, infinite input buffer at receiver• Main problem
– To prevent sender from overwhelming the receiver
• If receiver takes t time units to execute from physical layer to network layer, sender must not transmit more than one frame per time t
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2828
Simplex Stop-and-Wait ProtocolSimplex Stop-and-Wait Protocol• One solution – too conservative
– Restrict sender so transmits so slowly that even if frame undergoes max delay no buffer overflows
• Better solution– Receiver provides feedback to sender and gives
sender permission to send next frame
• Sender sends frame, stop and wait for ack• Alternates between sender and receiver
– Half-duplex
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
2929
Simplex Stop-and-Wait ProtocolSimplex Stop-and-Wait Protocol
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3030
Simplex Stop-and-Wait ProtocolSimplex Stop-and-Wait Protocol
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3131
• Drop assumption– Frames not damaged or lost
• Assumption– If frame is damaged, receiver will detect it when it
computes the checksum
• Possible solution– Receiver sends acknowledgement if receives
uncorrupted frame, discards frame if damaged– Sender sends frame again if doesn’t receive
acknowledgement before timeout
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3232
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
• Problem: duplicate messages– Receiver receives uncorrupted frame, sends
acknowledgement – Sender times out before receiving acknowledgement,
sends frame again– Receiver receives second copy uncorrupted – has
duplicate copies
• Solution– Use sequence numbers: 1 bit suffices
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3333
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
• How to determine timeout value– Timeout must be long enough so sender does
not send duplicate when ack is on its way– Timeout must allow
• Frame to get to receiver• Receiver to process frame• Ack to get to sender
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3434
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
• Acks need to be matched against frames– Sender remembers next_frame_to_send– Receiver remembers frame_expected
• Positive Acknowledgement with Retransmission (PAR), or, Automatic Repeat reQuest (ARQ)– Sender waits for a positive acknowledgement before
advancing to the next data item
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3535
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
Continued
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3636
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channelsend3() (cont’d)
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3737
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channel
Continued
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3838
Simplex Protocol for Noisy ChannelSimplex Protocol for Noisy Channelsend3() (cont’d)
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
3939
Example Data Link ProtocolsExample Data Link Protocols
• High-Level Data Link Control
• PPP
• Included for completeness, not required for quiz
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
4040
High-Level Data Link ControlHigh-Level Data Link Control
• Bit oriented, using bit-stuffing
• Address • Control – used for sequence numbers, acks, and other
purposes• Data – may contain any info. May be arbitrarily long• Checksum – cyclic redundancy code• Flag – 01111110• Types of frames: information, supervisory, unnumbered
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
4141
HDLC Information FrameHDLC Information Frame
• Uses a sliding window with a 3-bit sequence number– Seq – sequence number– Next – piggybacked ack– P/F – Poll/Final
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
4242
Point-to-Point ProtocolPoint-to-Point Protocol
• A framing method (using byte stuffing)• LCP (link control protocol) – for bringing
lines up, testing them, negotiating options and bringing them down again
• NCP (network control protocol) – to negotiate network-layer options in a way that is independent of the network layer protocol to be used
Spring Semester 2006Spring Semester 2006 EEC-484/584: Computer NetworksEEC-484/584: Computer Networks Wenbing ZhaoWenbing Zhao
4343
PPPPPP
• Frame format – resembles HDLC frame format• Major difference – byte stuffing, character oriented• Does not provide reliable transmission using
sequence numbers and acks as the default• Connection oriented service might not guarantee
reliability!