380 likes | 533 Views
An Introduction to Computer Networks. Lecture 4: Point-to-Point link. University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani. Outline. Concepts: Data signal Links Encoding Framing Error Detection Error correction or reliable transmission Stop and wait
E N D
An Introductionto Computer Networks Lecture 4: Point-to-Point link University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Introduction to Computer Network
Outline • Concepts: • Data • signal • Links • Encoding • Framing • Error Detection • Error correction or reliable transmission • Stop and wait • Sliding Window Algorithm Introduction to Computer Network
Data • Discrete data: an instance is binary. Computer works with discrete data. Discrete is encoded in 0s and 1s. • Continuous data: change with time or space. • It is converted to discrete data by sampling • The sampling rate must be at least 2 times the maximum frequency. • Data is delivered by signals in the links Introduction to Computer Network
Signals 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) Introduction to Computer Network
Signals (cont) Example- The following signal is the sum of sine waves. Introduction to Computer Network
Modulation • 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 method modulation types. Introduction to Computer Network
Channel capacity • Every transmission medium supports transmission in a certain frequency range. This is called channel capacity. » The channel bandwidth is determined by the transmission medium and the nature of the transmitter and receivers • A noiseless channel of width H can at most transmit a binary signal at a rate 2 x H. » E.g. a 3000 Hz channel can transmit data at a rate of at most 6000 bits/second Assumes binary amplitude encoding • Shannon extended this result by accounting for the effects of noise. • More aggressive encoding can increase the channel bandwidth. » Example: modems Introduction to Computer Network
Limits in sending signals • 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 Introduction to Computer Network
Copper Wire • 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 Introduction to Computer Network
Microwaves • High frequency electromagnetic waves (>1GHz) q Line of sight terrestrial transmissions and for communications via satellites. q Some atmospheric interference occurs but reliable transmission can be obtained over distances up to 50 Km. q Microwaves is absorbed by rain and does not penetrate obstacles. Introduction to Computer Network
Fiber Optic q Thin thread of glass or plastic q Lightweight. q Fibers act as wave-guides for light which is usually produced by lasers. q Visible light has frequency around 5*10 15 Hz, which ensures an extremely high bandwidth. q The raw materials are cheap. q Immune to electrical interference. q Difficult to join and tap. q Security advantages Introduction to Computer Network
Encoding • Encode binary data onto signals • Bits flow is between network adaptors. • Criteria for encoding: • Bit rate (in limited BW) • Recovering time information (in LAN) • Error detecting • Immunity to noise and interference • Complexity and cost of implementation. • Bit rates V.s Baud Rates • Baud rates is the number of pulses sent over the link or changing in signals. Introduction to Computer Network
Bits 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 NRZ Encoding • How to send clock information? • Extract from changes in signals. • The simplest way is 0 as low signal and 1 as high signal. This is known as Non-Return to zero (NRZ) Introduction to Computer Network
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 Introduction to Computer Network
Alternative Encodings • Try to solve the clock recovery problem. • Non-return to Zero Inverted (NRZI) • make a transition from current signal to encode a 1; stay at current signal to encode a zero • solves the problem of consecutive 1s • Manchester encoding • 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. Introduction to Computer Network
Bits 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 NRZ Clock Manchester NRZI Encodings (cont) Introduction to Computer Network
Encodings (cont) • 4B/5B: The idea is insert extra bits to break the consecutive bit patterns. • every 4 bits of data encoded in a 5-bit code • 5-bit codes selected to have no more than one leading 0 and no more than two trailing 0s • thus, 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. • FDDI is using this scheme. Introduction to Computer Network
Bits Node A Adaptor Adaptor Node B Frames Framing • How to distinguish between data and garbage. • Break sequence of bits into a frame • Typically implemented by network adaptor Introduction to Computer Network
8 16 16 8 Beginning Ending Header Body CRC sequence sequence 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 or stuffing: in BISYNC (from IBM) with DLE character. Introduction to Computer Network
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 Introduction to Computer Network
Bit-oriented Approaches • Frame is a collection of bits, SDLC (IMB) (synch. Data Link Control), later changed to HDLC (high) by OSI • Beginning and end with 01111110 • problem: How if the sequence appear in the body. • solution: Bit stuffing: add after 5 consecutive 1 a zero. 16 8 16 8 Introduction to Computer Network
Clock-Based Framing • e.g., SONET: Synchronous Optical Network • By Bellcore • Use NRZ , but scramble it for enough transition • Multiplex multiple low-speed links into a high sp • STS-n (STS-1 = 51.84 Mbps) Introduction to Computer Network
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. In Internet, consider 16 bits sequences and then use one-complement to find the result. • 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. Introduction to Computer Network
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); } Introduction to Computer Network
Cyclic Redundancy Code (CRC) • Add k bits of redundant data to an n-bit message • Where k << n • e.g., k = 32 and n = 12,000 (1500 bytes) T R M m MSB i.e. T = M.2r + R Modulo-2 addition (XOR) Introduction to Computer Network
CRC(cont) • Represent n-bit message as n-1 degree polynomial • e.g., MSG=10011010 as M(x) = x7 + x4 + x3 + x1 • Let k be the degree of some divisor polynomial • e.g., C(x) = x3 + x2 + 1 • Transmit polynomial T (x) that is evenly divisible by C(x) • shift left k bits, i.e., M(x)xk • subtract remainder of M(x)xk / C(x) from M(x)xk Introduction to Computer Network
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. Introduction to Computer Network
CRC(cont) Example: M(x)= 110101, C(x) = 1001 1 0 0 1 1 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 1 0 0 1 0 1 1 The final transmitted message is: T(x) = 1 1 0 1 0 10 1 1 R Introduction to Computer Network
Selecting C(x) • All single-bit errors, as long as the xk and x0 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) Introduction to Computer Network
Reliable Transmission • Error detection code. • Very costly • Acknowledgment and timeout • Send Acks in opposite direction. • Retransmit if sender did not receive Ack. Introduction to Computer Network
Acknowledgements & Timeouts Introduction to Computer Network
Stop-and-Wait Sender Receiver • Problem 1: keeping the pipe full • Example • 1.5Mbps link x 45ms RTT = 67.5Kb (8KB) • 1KB frames imples 1/8th link utilization • Problem 2: How about repeated frames? • Add a sequence number to frames. Introduction to Computer Network
Sender Receiver … ime T … Sliding Window • Allow multiple outstanding (un-ACKed) frames • Upper bound on un-ACKed frames, called window Introduction to Computer Network
£ SWS … … LAR LFS SW: Sender • Assign sequence number to each frame (SeqNum) • Maintain three state variables: • send window size (SWS) • last acknowledgment received (LAR) • last frame sent (LFS) • Maintain invariant: LFS - LAR <= SWS • Advance LAR when ACK arrives • Buffer up to SWS frames Introduction to Computer Network
£ RWS … … LFR LFA SW: Receiver • Maintain three state variables • receive window size (RWS) • largest frame acceptable (LFA) • last frame received (LFR) • Maintain invariant: LFA - LFR <= RWS • Frame SeqNum arrives: • if LFR < SeqNum < = LFA accept • if SeqNum < = LFR or SeqNum > LFA discarded • Send cumulative ACKs Introduction to Computer Network
Sequence Number Space • SeqNum field is finite; sequence numbers wrap around • Sequence number space must be larger then number of outstanding frames • SWS <= MaxSeqNum-1 is not sufficient • suppose 3-bit SeqNum field (0..7) • SWS=RWS=7 • sender transmit frames 0..6 • arrive successfully, but ACKs lost • sender retransmits 0..6 • receiver expecting 7, 0..5, but receives second incarnation of 0..5 • SWS < (MaxSeqNum+1)/2 is correct rule • Intuitively, SeqNum “slides” between two halves of sequence number space Introduction to Computer Network
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 Introduction to Computer Network