Presentation is loading. Please wait.

Presentation is loading. Please wait.

Univ. of TehranComputer Network1 Computer Networks Computer Networks (Graduate level) University of Tehran Dept. of EE and Computer Engineering By: Dr.

Similar presentations


Presentation on theme: "Univ. of TehranComputer Network1 Computer Networks Computer Networks (Graduate level) University of Tehran Dept. of EE and Computer Engineering By: Dr."— Presentation transcript:

1 Univ. of TehranComputer Network1 Computer Networks Computer Networks (Graduate level) University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 2: Link layer and reliable transmission

2 Univ. of TehranComputer Network2 Links How to make computers talk across a wire Assigned reading Chap. 2 of book.

3 Univ. of TehranComputer Network3 Physical Links Signals and waves Encoding, (Modulation) Technologies Protocols Framing Error Detection Error Correction Reliable transmission Outline

4 Univ. of TehranComputer Network4 Electromagnetic waves propagating in the light speed. Frequency Wavelength A (periodic) signal can be viewed as a sum of sine waves of different frequencies and strengths. Every signal has an equivalent representation in the frequency domain. » What frequencies are present and what is their strength (energy) Signals

5 Univ. of TehranComputer Network5 Sender changes the nature of the signal in a way that the receiver can recognize. » Similar to radio: AM or FM Digital transmission: encodes the values 0 or 1 in the signal. » It is also possible to encode multi-valued symbols Amplitude modulation: change the strength of the signal, typically between on and off. » Sender and receiver agree on a “rate” » On means 1, Off means 0 Similar: frequency or phase modulation. Can also combine different modulation types. Modulation

6 Univ. of TehranComputer Network6 Noise: “random” energy is added to the signal. Attenuation: some of the energy in the signal leaks away. We need repeaters. Dispersion: attenuation and propagation speed are frequency dependent. » Changes the shape of the signal Limits in sending signals

7 Univ. of TehranComputer Network7 Copper Wires Unshielded twisted pair » Two copper wires twisted - avoid antenna effect » Grouped into cables: multiple pairs with common sheath » Category 3 (voice grade) versus category 5 » 100 Mbps up to 100 m, 1 Mbps up to a few km » Cost: ~ 10cents/foot Coax cables. » One connector is placed inside the other connector » Holds the signal in place and keeps out noise » Gigabit up to a km Transmission Media

8 Univ. of TehranComputer Network8  High frequency electromagnetic waves (>1GHz) Line of sight terrestrial transmissions and for communications via satellites. Some atmospheric interference occurs but reliable transmission can be obtained over distances up to 50 Km. Microwaves can carry power, but for safety and legal reasons, this is impractical. Microwaves

9 Univ. of TehranComputer Network9  Thin thread of glass or plastic  Lightweight.  Fibres act as wave-guides for light which is usually produced by lasers.  Visible light has frequency around 5*10 15 Hz which ensures an extremely high bandwidth.  The raw materials are cheap.  Immune to electrical interference.  Difficult to join and tap. Fiber Optic

10 Univ. of TehranComputer Network10 Encoding Encode binary data onto signals Bits flow is between network adaptors. The simplest way is 0 as low signal and 1 as high signal. This is known as Non-Return to zero (NRZ) Used by Synchronous Optical Network (SONET) Bits NRZ 0010111101000010

11 Univ. of TehranComputer Network11 Clock Recovery When to sample voltage? How to send clock information? Extract from signals or data. Synchronized sender and receiver clocks Need easily detectible event at both ends Signal transitions help resync sender and receiver Need frequent transitions to prevent clock skew

12 Univ. of TehranComputer Network12 Problem with NRZ Consecutive 0’s or 1’s may create problems. Synchronization problem because of difference in the sender or receiver clocks. The average of signals which is used to distinguish between low or high may move and make the decoding difficult. This is called baseline wander Unable to recover clock

13 Univ. of TehranComputer Network13 Alternative Encodings Non-return to Zero Inverted (NRZI) 1- transition from current signal; 0= the same value solves the problem of consecutive 1s, but not 0s. Manchester encoding Used by Ethernet transmit XOR of the NRZ encoded data and the clock. 0 is being encoded as a low to high transition and 1 as high to low. It doubles the rate, then, it is only 50% efficient. The rate signal changing is called baud rate.

14 Univ. of TehranComputer Network14 Encodings (cont) Bits NRZ Clock Manchester NRZI 0010111101000010

15 Univ. of TehranComputer Network15 Encodings (cont) 4B/5B: Insert extra bits to break the consecutive bit patterns. 4 bits are encoded 5-bits. No more than one leading 0 or two trailing 0s Never get more than three consecutive 0s resulting 5-bit codes are transmitted using NRZI achieves 80% efficiency. Unused code are used for control. I.e. 11111 is for line is idle or 00000 for the line is dead. Used by FDDI.

16 Univ. of TehranComputer Network16 Outline Physical media is analog Modulation – signals to bits Bit stream vs. packets Framing – how to make packets Corruption Error detection & recovery Sharing Media access

17 Univ. of TehranComputer Network17 Framing How to distinguish between data and garbage. Break sequence of bits into a frame Typically implemented by network adaptor Problem? How distinguish start of frame? Frames Bits Adaptor Node BNode A

18 Univ. of TehranComputer Network18 Byte-oriented Approaches Sentinel-based delineate frame with special pattern: 01111110 or STX, ETX, etc characters. e.g., HDLC, SDLC, PPP problem: special pattern or characters appear in the payload Character escaping, in BISYNC with DLE character. HeaderBody 816 8 CRC Beginning sequenc e Ending sequence

19 Univ. of TehranComputer Network19 Byte-oriented Approaches(cont Byte stuffing Special start of frame byte (e.g. 0xFF) Special escape byte value (e.g. 0xFE) Values actually in text are replaced (e.g. 0xFF by 0xFEFF and 0xFE by 0xFEFE) Worst case – can double the size of frame Bit stuffing Special bit sequence (0x01111110) 0 bit stuffed after any 11111 sequence

20 Univ. of TehranComputer Network20 Byte-oriented Approaches (cont) Counter-based include payload length in the header e.g., DDCMP protocol from DEC. problem: count field corrupted solution: catch when CRC fails

21 Univ. of TehranComputer Network21 Clocked-based framing SONET: Synchronous Optical Network each frame is 125us or 810 byte long STS-n (STS-1 = 51.84 Mbps)

22 Univ. of TehranComputer Network22 Outline Physical media is analog Modulation – signals to bits Bit stream vs. packets Framing – how to make packets Corruption Error detection & recovery Sharing Media access

23 Univ. of TehranComputer Network23 Error Detection To send extra information to find error in the frame. The simplest form is sending two copies, inefficient. Sending the sum of values (?) in the frame, checksum. Consider 16 bits sequences and use one-complement to find the result. Relatively weak detection Sending parity, Odd or even parity. Two dimensional parity, adding one extra bit, parity bit, to code and also find the parity for each bit position for total data.

24 Univ. of TehranComputer Network24 Internet Checksum Algorithm View message as a sequence of 16-bit integers; sum using 16-bit ones-complement arithmetic; take ones- complement of the result. u_short cksum(u_short *buf, int count) { register u_long sum = 0; while (count--) { sum += *buf++; if (sum & 0xFFFF0000) { /* carry occurred, so wrap around */ sum &= 0xFFFF; sum++; } return ~(sum & 0xFFFF); }

25 Univ. of TehranComputer Network25 Error Detection – CRC Polynomial code Treat packet bits a coefficients of n-bit polynomial Choose r+1 bit generator polynomial (well known – chosen in advance) Add r bits to packet such that message is divisible by generator polynomial Better loss detection properties than checksums

26 Univ. of TehranComputer Network26 Cyclic Redundancy Code (CRC) T M m R MSB i.e. T = M.2 r + R Modulo-2 addition (XOR) Add k bits of redundant data to an n-bit message Where k << n e.g., k = 32 and n = 12,000 (1500 bytes)

27 Univ. of TehranComputer Network27 CRC(cont) Represent n-bit message as n-1 degree polynomial e.g., MSG=10011010 as M(x) = x 7 + x 4 + x 3 + x 1 Let k be the degree of some divisor polynomial e.g., C(x) = x 3 + x 2 + 1 Transmit polynomial T (x) that is evenly divisible by C(x) shift left k bits, i.e., M(x)x k subtract remainder of M(x)x k / C(x) from M(x)x k

28 Univ. of TehranComputer Network28 CRC (cont) Receiver polynomial T(x) + E(x) E(x) = 0 implies no errors Divide (T(x) + E(x)) by C(x); remainder zero if: E(x) was zero (no error), or E(x) is exactly divisible by C(x) All operation is done in modulo 2 in which there is no carry. Then, the operation can be done by XOR only.

29 Univ. of TehranComputer Network29 CRC(cont) Example: M(x)= 110101, C(x) = 1001 1 0 0 11 1 0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 1 0 1 1 R The final transmitted message is: T(x) = 1 1 0 1 0 1 0 1 1

30 Univ. of TehranComputer Network30 Selecting C(x) All single-bit errors, as long as the x k and x 0 terms have non-zero coefficients. All double-bit errors, as long as C(x) contains a factor with at least three terms Any odd number of errors, as long as C(x) contains the factor (x + 1) Any ‘burst’ error (i.e., sequence of consecutive error bits) for which the length of the burst is less than k bits. Most burst errors of larger than k bits can also be detected See Table 2.6 on page 102 for common C(x)

31 Univ. of TehranComputer Network31 Error Recovery Two forms of error recovery Forward Error Correction (FEC) Automatic Repeat Request (ARQ) FEC Use error correcting codes to repair losses ARQ Receiver sends acknowledgement (ACK) when it receives packet Sender waits for ACK and timeouts if it does not arrive within some time period

32 Univ. of TehranComputer Network32 Recovering from Error Packet ACK Timeout Packet ACK Timeout Packet Timeout Packet ACK Timeout Time Packet ACK Timeout Packet ACK Timeout ACK lostPacket lost Early timeout

33 Univ. of TehranComputer Network33 Stop and Wait Time Packet ACK Timeout Simplest ARQ protocol Send a packet, stop and wait until acknowledgement arrives SenderReceiver

34 Univ. of TehranComputer Network34 Problems with Stop and Wait How to recognize a duplicate Performance Can only send one packet per round trip

35 Univ. of TehranComputer Network35 How to Recognize Resends? Use sequence numbers both packets and acks Sequence # in packet is finite -- how big should it be? For stop and wait? One bit – won’t send seq #1 until received ACK for seq #0 Pkt 0 ACK 0 Pkt 0 ACK 1 Pkt 1 ACK 0

36 Univ. of TehranComputer Network36 Performance of Stop & Wait? Without Error T (total time) = 2t p + t f + 2t proc + t ack T proc and t ack are usually negligible. Take a= t p /t f, then utilization η= t f /( 2t p + t f ) =1/(2a+1) Then, utilization depends on a frame Sender Receiver t p = propagate time tftf

37 Univ. of TehranComputer Network37 Performance of Stop & Wait? a = (D/V)/(L/R) where D= distanceV= Velocity of light L= Length of packet R= Rate a= RD/VL Constant Then, L determines the link utilization, the longer the packet the more link utilization. frame Sender Receiver t p = propagate time tftf

38 Univ. of TehranComputer Network38 Performance of Stop & Wait? With Error N r is the expected value of sending a frame. η= 1/ N r (2a+1), Then what is N r ? ρ= prob. Of a frame in error N r = i ρ i-1 (1-ρ) =1/ (1-ρ) η= (1-ρ)/(2a+1), frame Sender Receiver t p = propagate time tftf

39 Univ. of TehranComputer Network39 How to Keep the Pipe Full? Send multiple packets without waiting for first to be acked Number of pkts in flight = window How large a window is needed Round trip delay * bandwidth = capacity of pipe Reliable, unordered delivery Several parallel stop & waits Send new packet after each ack Sender keeps list of unack’ed packets; resends after timeout Receiver same as stop&wait

40 Univ. of TehranComputer Network40 Sliding Window Reliable, ordered delivery Receiver has to hold onto a packet until all prior packets have arrived Sender must prevent buffer overflow at receiver Circular buffer at sender and receiver Packets in transit <= buffer size Advance when sender and receiver agree packets at beginning have been received

41 Univ. of TehranComputer Network41 Receiver Sender Sender/Receiver State …… Sent & AckedSent Not Acked OK to SendNot Usable …… Max acceptable Receiver window Max ACK receivedNext seqnum Received & AckedAcceptable Packet Not Usable Sender window Next expected

42 Univ. of TehranComputer Network42 Window Sliding – Common Case On reception of new ACK (i.e. ACK for something that was not acked earlier Increase sequence of max ACK received Send next packet On reception of new in-order data packet (next expected) Hand packet to application Send cumulative ACK – acknowledges reception of all packets up to sequence number Increase sequence of max acceptable packet

43 Univ. of TehranComputer Network43 Loss Recovery On reception of out-of-order packet Send nothing (wait for source to timeout) Cumulative ACK (helps source identify loss) Timeout (Go Back N recovery) Set timer upon transmission of packet Retransmit max ACK received sequence + 1 Restart from max ACK received sequence + 1 Performance during loss recovery No longer have an entire window in transit Can have much more clever loss recovery Covered in TCP lectures

44 Univ. of TehranComputer Network44 Sequence Numbers How large do sequence numbers need to be? Must be able to detect wrap-around Depends on sender/receiver window size E.g. Max seq = 7, send win=recv win=7 If pkts 0..6 are sent succesfully and all acks lost Receiver expects 7,0..5, sender retransmits old 0..6 Max sequence must be >= send window + recv window

45 Univ. of TehranComputer Network45 Concurrent Logical Channels Multiplex 8 logical channels over a single link Run stop-and-wait on each logical channel Maintain three state bits per channel channel busy current sequence number out next sequence number in Header: 3-bit channel num, 1-bit sequence num 4-bits total same as sliding window protocol Separates reliability from order

46 Univ. of TehranComputer Network46 Performance sliding window? Without Error, the same assumption as stop and wait. t p = a, t f =1 W ≥ 2a+1 => η= 1 W η= W/(2a+1) It is the same for selective repeat/reject. frame Sender Receiver 2a +1 for 1 st ack. tftf

47 Univ. of TehranComputer Network47 Performance of sliding window? With Error, W ≥ 2a+1 => η= 1/ N r, Then what is N r ? W η= W/ N r (2a+1) ρ= prob. Of a frame in error N r = i ρ i-1 (1-ρ) =1/ (1-ρ) W ≥ 2a+1 => η= 1- ρ, W η= W(1- ρ)/ (2a+1) frame Sender Receiver 2a +1 for 1 st ack. tftf

48 Univ. of TehranComputer Network48 Performance of sliding window? With Error, Go back N We assume window size is big and there is always packet to send, then, to send one frame: t ave = t f +t T i ρ i (1-ρ) = t f (1 +(1+2a)p/(1-p))= t f (1+ 2ap)/(1-p) η= (1- ρ)/ (2ap+1)

49 Univ. of TehranComputer Network49 Next Lecture: Performance How to evaluate the system Assigned reading Chapter 2 from Schwartz book


Download ppt "Univ. of TehranComputer Network1 Computer Networks Computer Networks (Graduate level) University of Tehran Dept. of EE and Computer Engineering By: Dr."

Similar presentations


Ads by Google