Presentation is loading. Please wait.

Presentation is loading. Please wait.

EEC-484/584 Computer Networks

Similar presentations


Presentation on theme: "EEC-484/584 Computer Networks"— Presentation transcript:

1 EEC-484/584 Computer Networks
Lecture 8 Wenbing Zhao (Part of the slides are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall)

2 Outline Data Link layer Error Detection and Correction
Elementary data link protocols DLL Data Link Medium Access Control (MAC) We Study This SubLayer in This Lecture Spring Semester 2007 EEC-484/584: Computer Networks

3 Error Detection and Correction
Causes of errors Transmission errors on phone lines due to thermal noise Data transmission errors due to impulse noise Signals are separated, distorted, recombined Crosstalk between physically adjacent wires Compression and decompression Receiver out of synch with sender Errors usually occur in bursts Spring Semester 2007 EEC-484/584: Computer Networks

4 Error-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 2007 EEC-484/584: Computer Networks

5 Error-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 2007 EEC-484/584: Computer Networks

6 Error-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 , but not all 2n possible codewords are used Spring Semester 2007 EEC-484/584: Computer Networks

7 Error-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 2007 EEC-484/584: Computer Networks

8 Error-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 2007 EEC-484/584: Computer Networks

9 Error-Correcting Codes: Example
Consider a code with only four valid codewords , , , This code has a distance 5  can correct double errors If arrives, receiver knows the original must have been However, if triple error changes to , the error will not be corrected properly Spring Semester 2007 EEC-484/584: Computer Networks

10 EEC-484/584: Computer Networks
Parity 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 With even parity  With odd parity  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 2007 EEC-484/584: Computer Networks

11 Error-Detecting Codes
If a single parity bit is appended to a block, error detecting probability is only 0.5 if burst error occurs (why?) This can be improved by treating a block as a matrix, n bits wide and k bits high, A parity bit is computed for each column and affixed to the matrix as the last row The matrix is transmitted one row at a time Probability of accepting bad block is 2-n Spring Semester 2007 EEC-484/584: Computer Networks

12 Error-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.: => M(x) = x7 + x6 + x4 + x3 + x1 Use modulo 2 arithmetic No carries or borrows: XOR The degree of a polynomial is the maximum of the degrees of all terms in the polynomial Spring Semester 2007 EEC-484/584: Computer Networks

13 EEC-484/584: Computer Networks
Cyclic 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 2007 EEC-484/584: Computer Networks

14 Algorithm 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 2007 EEC-484/584: Computer Networks

15 EEC-484/584: Computer Networks
Compute CRC Checksum XOR Spring Semester 2007 EEC-484/584: Computer Networks

16 International Standard Polynomials
CRC-12 G(x) = x12 + x11 + x3 + x2 + x1 + 1 Used for 6-bit characters CRC-16 G(x) = x16 + x15 + x2 + 1 CRC-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 No need to remember these generator polynomials Spring Semester 2007 EEC-484/584: Computer Networks

17 EEC-484/584: Computer Networks
Exercise Q5. 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 2007 EEC-484/584: Computer Networks

18 EEC-484/584: Computer Networks
Exercise Q6. A bit stream is transmitted using the standard CRC method described in the text. The generator polynomial is x 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 2007 EEC-484/584: Computer Networks

19 Elementary Data Link Protocols*
An Unrestricted Simplex Protocol A Simplex Stop-and-Wait Protocol Simplex Protocols for a Noisy Channel *Materials taken from: Spring Semester 2007 EEC-484/584: Computer Networks

20 Data Structure and Library Routines for DLL
Routines for host communications: transfer an array of data between host system and DLL: FromHost(message) Fetch message (to be transmitted) from host ToHost(message) Deliver message (received) to host where message is an array of information to be passed Spring Semester 2007 EEC-484/584: Computer Networks

21 Data Structure and Library Routines for DLL
Physical layer to DLL interface: routines that transfer data frames between physical layer and data link layer  SendFrame (frame) send a frame GetFrame (frame) get a frame Spring Semester 2007 EEC-484/584: Computer Networks

22 Data Structure and Library Routines for DLL
Frame: a data structure composed of four fields kind: variable of type FrameKind identifies the type of frame (control or data frame) seq: the sequence number of this frame (if any) ack: sequence number of frame to acknowledge (if any) info: the data message (if any) Spring Semester 2007 EEC-484/584: Computer Networks

23 Data Structure and Library Routines for DLL
StartTimer: starts an internal timer StopTimer: stops the timer   WaitEvent(event): is called by the receiver to wait for an event, where the value returned by event indicates the type of event which occurred: FrameArrival to indicate the arrival of an error free frame ChSumErr to indicate a checksum error occurred on the frame TimeOut the timer has 'timed out' Spring Semester 2007 EEC-484/584: Computer Networks

24 Unrestricted Simplex Protocol
Assumptions messages one way only physical channel with no errors both hosts are always ready (to receive and transmit) A communications protocol is the set of rules which define how the flow of data between the transmitter and receiver is controlled. Spring Semester 2007 EEC-484/584: Computer Networks

25 Unrestricted Simplex Protocol
Sender pseudo code LOOP forever FromHost(frame.info) frame.kind = data SendFrame(frame) ENDLOOP Spring Semester 2007 EEC-484/584: Computer Networks

26 Unrestricted Simplex Protocol
Receiver pseudo code LOOP forever WaitEvent (event) /*wait for FrameArrival */ GetFrame (Rfraxne) /* get info frame from receiver */ ToHost(Rframe. info) /* pass message to host */ ENDLOOP Only possible event is FrameArrival and type of frame received is data Spring Semester 2007 EEC-484/584: Computer Networks

27 Unrestricted Simplex Protocol
message a3 is corrupt when passed to host B and message a6 is totally lost. In addition, if a slow receiver is connected to a fast transmitter, data would be lost due to overflow Spring Semester 2007 EEC-484/584: Computer Networks

28 Simplex Stop and Wait Protocol
Add flow control: receiver provide feedback Sender pseudo code LOOP forever FromHost (Sframe.info) /*get message from host */ Sframe.kind = data /* set up data frame with message */ SendFrame (Sframe) /* and transmit frame */ WaitEvent (event) /* STOP and WAIT for ack frame */ GetFrame (Rframe) /* get it and discard it */ ENDLOOP Only possible event is FrameArrival and type of frame received is ack. Spring Semester 2007 EEC-484/584: Computer Networks

29 Simplex Stop and Wait Protocol
Receiver pseudo code LOOP forever WaitEvent (event) /* wait for FrameArrival */ GetFrame (Rframe) /* get the frame from receiver */ ToHost (Rframe.info) /* pass message to host */ Sframe.kind = ack /* build ack frame */ SendFrame (sframe) /* and transmit frame */ ENDLOOP Only possible event is FrameArrival and type of frame received is data. Spring Semester 2007 EEC-484/584: Computer Networks

30 Simplex Stop and Wait Protocol
Effect of a damaged frame: passes a corrupt message to the host Effect of a lost message or ack: causes lockup - A waiting for ack from B and B waiting for data from A Spring Semester 2007 EEC-484/584: Computer Networks

31 Simplex ARQ Protocol for a Noisy Channel
Dealing with lost of data frame with retransmission Receiver: check event, if it is not FrameArrival ignore it Sender: send data frame and if an ack is not received within a certain time retransmit it Need two new functions StartTimer: starts an internal timer StopTimer: stops the timer If the timer 'times out’ WaitEvent returns an event value of TimeOut Spring Semester 2007 EEC-484/584: Computer Networks

32 Simplex ARQ Protocol for a Noisy Channel
Sender pseudo code LOOP forever FromHost (Sframe.info) /* get message from host */ Sframe.kind = data /* set up data frame with message */ REPEAT /* until ack arrives */ SendFrame (Sframe) /* and transmit frame */ StartTimer /* start the timre */ WaitEvent (event) /* stop and wait for ack frame */ UNTIL event = FrameArrival /* ack frame arrived ? */ StopTimer /* stop the timer */ GetFrame (Rframe) /* get ack frame and discard it */ ENDLOOP In this case event may be FrameArrival or TimeOut Spring Semester 2007 EEC-484/584: Computer Networks

33 Simplex ARQ Protocol for a Noisy Channel
Receiver pseudo code LOOP forever REPEAT /* until frame OK */ WaitEvent(event) /* wait for FrameArrival */ GetFrame(Rframe) /* get the frame from receiver */ UNTIL event = FrameArrival /* data frame arrived ? */ ToHost(Rframe.info) /* pass message to host */ Sframe.kind = ack /* build ack frame */ SendFrame(Sframe) /* and transmit frame */ ENDLOOP In this case event maybe FrameArrival or ChSumErr Spring Semester 2007 EEC-484/584: Computer Networks

34 Simplex ARQ Protocol for a Noisy Channel
Problem: duplicate delivery Spring Semester 2007 EEC-484/584: Computer Networks

35 Simplex ARQ Protocol for a Noisy Channel
Problem: duplicate delivery Spring Semester 2007 EEC-484/584: Computer Networks

36 Simplex ARQ Protocol for a Noisy Channel
Problem: duplicate delivery Spring Semester 2007 EEC-484/584: Computer Networks

37 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Each frame must carry a sequence number Sender: sets up the seq number in the data frame and keeps transmitting it until it gets an ack Receiver: when it gets a data frame with a particular sequence number: sends an acknowledgement frame checks that the sequence number of the frame is the expected sequence number: if so it is passed to the host and the expected sequence number incremented else the frame is discarded Spring Semester 2007 EEC-484/584: Computer Networks

38 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Sender psuedo code SeqSend = 0 LOOP forever FromHost(Sframe.info) Sframe.kind = data Sframe.seq = SeqSend REPEAT SendFrame (Sframe) StartTimer WaitEvent(event) UNTIL event FrameArrival SeqSend = SeqSend StopTimer GetFrame(Rframe) ENDLOOP /* initial sequence number */   /* get message from host */ /*set up data frame with message */ /* set up sequence number */ /* until ack arrives */ /* transmit frame */ /* start the timer */ /* STOP and WAIT for ack frame */ /* ack frame arrived? */ /* set up next sequence number */ /* stop the timer */ /* get it and discard it */ In this case event may be FrameArrival or TimeOut Spring Semester 2007 EEC-484/584: Computer Networks

39 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Receiver pseudo code SeqExpected = 0 LOOP forever REPEAT WaitEvent (event) GetFrame (Rframe) UNTIL event = FrameArrival if (SeqExpected = Rframe.seq) {     ToHost (Rframe. info)     SeqExpected = SeqExpected } Sframe.kind = ack SendFrame (Sframe) ENDLOOP /* initial sequence number */   /* until frame OK */ /* wait for Frame Arrival */ /* get the frame from receiver */ /* frame OK? */ /* yes, frame expected? */ /* yes, pass message to host */ /* next sequence number */ /* build ack frame */ /* and transmit frame */ In this case event may be FrameArrival or ChSumErr Spring Semester 2007 EEC-484/584: Computer Networks

40 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
The sequence numbers for this protocol can be held in a single bit with a sequence of frames having the numbers etc. Spring Semester 2007 EEC-484/584: Computer Networks

41 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Spring Semester 2007 EEC-484/584: Computer Networks

42 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Spring Semester 2007 EEC-484/584: Computer Networks

43 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
Spring Semester 2007 EEC-484/584: Computer Networks

44 Simplex ARQ Protocol with Sequence Numbers for a Noisy Channel
This protocol still has a problem Identify the problem How to fix it? Spring Semester 2007 EEC-484/584: Computer Networks


Download ppt "EEC-484/584 Computer Networks"

Similar presentations


Ads by Google