640 likes | 751 Views
Chapter 2: Direct Link Networks. Hardware Building Blocks. Networks constructed from 2 types of Building blocks - Nodes and Links Nodes: - A host/ general propose computer running application programs or - A PC or workstation configured as a switch or router to forward packets.
E N D
Hardware Building Blocks • Networks constructed from 2 types of Building blocks - Nodes and Links • Nodes: - A host/ general propose computer running application programs or - A PC or workstation configured as a switch or router to forward packets. -switch/router implemented by special purpose hardware. - Better performancethangeneral purpose computer • Links: • Wired or wireless • Shared or dedicated
Direct Link Networks • 2 Nodes can successfully exchange packets if the following 5 operations can be performed. • Encoding: Convert bits to signals on the link (wire or fiber) so they can be understood by the receiving host • Framing: Delineate the sequence of bits transmitted over link. • detecting the beginning and end of a frame • Error Detection: Detect errors (may be correction also ) introduced in the transmission medium due to noise/distortion. • Reliable delivery: Make link appear reliable even though it can introduce errors • Media Access Control: Specify how individual host can access a shared medium fairly.
NRZ Encoding • Signal propagates over links; bits transmitted between nodes. • Binary data needs to be encoded into signals the links can carry, then decoded into binary data at receiver. • Network adaptor: A piece of hardware that connects node to a link • Encoding: Map data value=1 to “high” signal; data value=0 to “low” signal
NRZ Encoding • Disadvantages: long strings of 1’s or 0’s cause problems • Receiver cannot distinguish between long string of 0’s & dead line (unipolar encoding) • Receiver uses average signal level (baseline) to differentiate between high & low signal. Too many consecutive 1’s change baseline • Frequent transitions from high to low & low to high are needed for clock recovery. • Whenever the signal changes(0 to 1, 1 to 0) the receiver knows it is at a clock boundary & resynchronizes itself. • A long period w/o transitions leads to clock drift. • Advantage:NRZ is very simple
NRZI Encoding • Non return zero inverted (NRZI): • make a transition from current signal to encode a 1, • stays at current signal to encode a 0 • Advantage: Solves problem of consecutive 1’s • Disadvantage: does not solve problem consecutive 0’s.
Manchester Encoding • Transmits exclusive-OR of NRZ signal & clock • 0 is low to high transition • 1 is high to low transition • Disadvantage: Requires double the rate of signal transitions over the link. • Receiver has half the time to detect each pulse. • If the Receiver can keep up, NRZ & NRZI could transmit twice as many bits • Manchester encoding only 50% efficient.
Example Encode:001011110100
4b/5bEncoding • Insert extra bits to break up long sequences of 0’s and 1’s • Every 4 bits of data encoded into 5 bits, hence the name 4B/5B. • The 5 Bit codes are selected, so that each one has at most 1 leading & 2 trailing 0’s. • Maximum 3 consecutives 0’s. • The 5 bit encoded using NRZI. • Consecutives 1’s not a problem. • This scheme has 80% efficiency.
4b/5b Codes • 16 bits codes are left over from these • 11111 idle line • 00000 dead line • 00100 halt • Of the remaining 13,7 are invalid,(violate 1 leading & 2 trailing 0’s condition) others represent various control symbols. Maybe used by some framing protocols
Direct Link Networks * Encoding:Convert bits to signals on the link (wire or fiber) so they can be understood by the receiving host Framing: Delineate the sequence of bits transmitted over link. detecting the beginning and end of a frame Error Detection: Detect errors (may be correction also ) introduced in the transmission medium due to noise/distortion. Reliable delivery: Make link appear reliable even though it can introduce errors Media Access Control: Specify how individual host can access a shared medium fairly.
Framing • In a packet switched network blocks of data (called “frames” at link level) are exchanged between hosts. • Network adaptor enables hosts to exchange frames. • The adaptor at node A transmits a frame from its memory . • The adaptor at B collects the arriving bits to form a frame & puts it in memory of B. • Recognizing what sequence of bits constitute a frame - detecting beginning & end of a frame is the main challenge for adaptor.
Framing • Sentinel based • Uses special characters or bit patterns to denote start/end of frame. 8 8 8 8 8 16 BISYNC Header Body CRC • Main Disadvantage: Sentinel Characters may occur in body of message. • Solution: Escape sentinel characters in body by inserting DLE (Data-Link Escape)
Framing Counting • Counts number of characters (or bits) • Frame includes a special ‘count’ field. DDCMP header • Transmission error can corrupt count field frame not correctly detected. • The receiver will collect as many bytes as bad count indicates • Framing error: One signal error may corrupt up to two consecutive frames
Direct Link Networks * Encoding:Convert bits to signals on the link (wire or fiber) so they can be understood by the receiving host. * Framing: Delineate the sequence of bits transmitted over link. detecting the beginning and end of a frame Error Detection: Detect errors (may be correction also ) introduced in the transmission medium due to noise/distortion. Reliable delivery: Make link appear reliable even though it can introduce errors Media Access Control: Specify how individual host can access a shared medium fairly.
Error Detection • Bit errors are sometimes introduced into frames due to electrical interference, thermal noise, etc. • We need to detect such errors so corrective action can be taken • The most popular method is CRC-it is used in IMP IMP,HDLC, DDCMP, CSMA & token ring. • Other methods include parity checking, Error correcting codes (ECC) etc.
Cyclic Redundancy Check • Main Idea in error detection : Add redundant bits (info) which can be used to detect errors. • e.g. Transmit 2 sets of data → if both identical at receiver → high probability that no error was introduced. • This method is very inefficient: n redundant bits for n bits of data. • In general send only k bits for n bits of data, where k<<n e.g. Ethernet frame with 12000 bits require only 32 bit CRC code.
CRC • A message containing n-bits →represented by polynomial M(x) of degree n-1. e.g. for 10011010 M(x)=x7+x4+x3+x1 • We also choose a divisor polynomial C(x) of degree k for some value of k<<n • e.g. k=3 C(x)=x3+x2+1 • C(x) for different values of k given in table 3-4 x8+x2+x1+1 x10+x9+x5+x4+x1+1 x12+x11+x3+x2+1 x16+x15+x2+1 x32+x26+x23+x22+x16+x12+x11+x10+x8 +x7+x5+x4+x2+x+1 CRC-8 CRC-10 CRC-12 CRC-16 CRC-32
CRC • Instead of transmitting M(x) we transmit a polynomial P(x) which is exactly divisible by C(x). • If there is error, a term E(x) has been added to it • At receiver if P(x)+E(x) exactly divisible by C(x): • either E(x)=0 or • E(x) exactly divisible by C(x) • 2nd case very rare, 0 →no error
Steps for CRC: • At transmitter: • Calculate xk.M(x) by appending k 0’s to M(x) • Calculate remainer (R) of xk.M(x)/C(x) • P(x) = xk. M(x)- R is exactly divisible by C(x) • Obtain P(x) by appending R to M(x) • Transmit P(x)
Example • M(x)=10011010 → x7+x4+x3+x1, k=3 • xk.M(x)= x10+x7+x6+x4 → 10011010000 • K=3 : C(x)=1101 • Calculate R by polynomial division • Rules: C(x) divides any polynomial B(x) of same degree & remainder=B(x) + C(x)
Example 1 1 1 1 1 0 0 1 Generator Message 1101 10011010000 1101 1001 1101 1000 1101 1011 1101 1100 1101 1 0 0 0 1101 Remainder 101
Transmit P(x)= xk.M(x)-R append R to M(x). • So, P(x)=10011010101 • The Receiver divides the received value P(x)+E(x) by C(x). If Remainder=0 → E(x)=0 → no error. • With some codes it is possible to correct small errors → error correcting code(ECC)
Example (continued) 1 1 1 1 1 0 1 0 Divisor Message 1101 10011000000 1101 1001 1101 1000 1101 1010 1101 1110 1101 11 0 0 1101 10 Remainder
In general it can be shown • C(x) detect all single bit error if xk and x0 have non-zero coefficients • All double bit errors if C(x) has a factor at least 3 terms • Any odd no of errors if C(x) has factor (x+1) • Any ‘burst’ error if length of burst <k bits
Direct Link Networks * Encoding:Convert bits to signals on the link (wire or fiber) so they can be understood by the receiving host. * Framing: Delineate the sequence of bits transmitted over link. detecting the beginning and end of a frame * Error Detection: Detect errors (may be correction also ) introduced in the transmission medium due to noise/distortion. Reliable delivery: Make link appear reliable even though it can introduce errors Media Access Control: Specify how individual host can access a shared medium fairly.
Reliable Transmission • Frames are corrupted due to transmission errors and corrupted frames must be discarded. • A link level protocol that wants to deliver frames reliably must be able to recover from these errors. • This is done by using 2 mechanisms: • Acknowledgements • Timeouts
Reliable Transmission • ACK: A control frame that a protocol sends back to its peer indicating it has received an earlier frame. • Control Frame: Header without any data. ACK can also be sent as part of a data frame that was being sent anyway. • Getting ACK means frames was successfully delivered; • Timeout: waiting for a reasonable amount of time before retransmission. • Using ACK & timeout to implement reliable delivery → automatic repeat request (ARQ)
Stop and Wait (S&W) • S&W → simplest method; sender waits for ACK before Transmitting next frame. • If no ACK in a certain period of time → timeout & retransmit original frame
Stop and Wait (S&W) ACK received before timeout b) Original frame is “lost” “lost” → error detected in frame at receiver & frame is discarded
Disadvantages: • Allows senders to have only one outstanding frame on a link → does not efficiently utilize the links capacity. • E.g. Consider a 1.5Mbps link with 45ms RTT • Delay*BW= ? • 1.5*106*45x10-3=67.5kbits=8kbytes • Let frame size =1kB; • Sender can send only 1 frame per RTT. • Max sending rate = 1kB/45*10-3=1024x8/(45*10-3)=182*103 bps • Which is approx one-eighth of the link capacity.
In figures c & d sender times out & retransmits original frame. But receiver has already sent ACK for that frame, so receiver thinks it is the next frame
Solution: headers include a 1 bit sequence number → can have value 0&1 and alternate for successive frames. • When sender retransmits frame 0, Receiver knows it is a copy of frame 0 & not the next frame (frame 1)
Sliding Window • Sender assigns a sequence number to each frame. • Sender maintains 3 variables • Send Window Size (SWS) → max number of outstanding (unacknowledged) frames the sender can transmit • LAR → denotes sequence number of Last frame for which ACK Received. • LFS →sequence number of Last Frame Sent. • The sender ensures the following condition is always satisfied :LFS-LAR ≤ SWS
< SWS ─ ■ ■ ■ ■ ■ ■ LAR LFS Sliding Window • When an ACK is received sender moves LAR 1 position to the right, allowing next frame (after LFS) to be transmitted • Also sender has a timer for each frame; • if timer expires before ACK received → retransmit frame • Sender has to buffer SWS frames since it may have to retransmit any one of them
Receiver maintains 3 variables. • Receive Windows Size (RWS): Max number of out of order frames receiver is willing to accept. • LFA: Sequence number of Last Frame Acceptable • NFE: Sequence Next Frame Expected. • Must have LFA-NFE+1 ≤ RWS
< ─ RWS 6 7 9 ■ ■ ■ ■ ■ ■ NFE LFA • Example: • For NFE=5 (last ACK sent for frame 4) & RWS=8 • LFA=12 • When Receiver gets a frame with sequence number = n • If n < NFE or n > LFA → Frame is discarded • If NFE ≤ n ≤ LFA → Frame is accepted. 12
Updating NFE & LFA • Sequence Number To ACK: • Largest sequence number not yet ACK’ed • All frames with sequence number <Sequence number to ACK have been received • The receiver ACK’s receipt of sequence Number to Ack even if higher numbered packets have been received. • It then sets: • NFE = Sequence number to ACK + 1 & • LFA = Sequence number to ACK + RWS
Example NFE LFA • For NFE=5 & RWS=8 LFA=12 • Let frame 6,7&9 arrive before 5 • Now when 5 arrives: • Sequence Number To Ack = 7 • Receiver sends ACK for frame 7 and sets • NFE = 8 • LFA=15 • If frame8 arrives next what will be the values for NFE and LFA ? RWS RWS 5 6 7 ■ ■ ■ ■ ■ ■ 9 4 ■ ■ ■ ■ ■ ■ NFE LFA NFE LFA
Variations on ACK Receiver can send negative ACK(NAK) for 5 as soon as 6 arrives → unnecessary as senders timeout can catch this & it adds complexity to receiver. Send additional ACK for frame 4 when 6&7 arrive duplicate ACK’s (eg for 4) help sender to know a frame was lost Selective ACK’s : Receiver ACK each frame received receiver would ACK 6&7 as soon as they arrive → More info for sender → easier to keep pipe full → but more complex implementation. • SWS depends on delayXBW(RTT) • RWS can be anything: usually RWS=1 , or RWS =SWS
Finite Sequence Numbers • Sequence number specified by a header field of finite size: • can’t go infinitely high • e.g. 3 bit field → 8 sequence number • Sequence numbers wrap around. • Problem: differentiate between different incarnations of same sequence number. • SWS < (Max sequence number +1) /2 • So, protocol alterates between 2 halves of the sequence number space. • Actually continually slides between 2 halves sliding window protocol
Direct Link Networks * Encoding:Convert bits to signals on the link (wire or fiber) so they can be understood by the receiving host. * Framing: Delineate the sequence of bits transmitted over link. detecting the beginning and end of a frame * Error Detection: Detect errors (may be correction also ) introduced in the transmission medium due to noise/distortion. * Reliable delivery: Make link appear reliable even though it can introduce errors. Media Access Control: Specify how individual host can access a shared medium fairly.
Shared Media Access • Two nodes should not transmit at the same time • Each node should have a fair chance to access the media • Wired • Ethernet • Token Ring • Wireless • 802.11
Physical properties • EN segments can be joined by repeaters: • no more than 4 repeater between any 2 hosts→ • maximum reach of EN=2500m. • Any signal placed on the EN by a host is broadcast over entire network • signal propagated in both directions and • repeaters forward signals on all outgoing segments. • Terminators at end of each segment to absorb signals and keep them from “bouncing back” and interfering with other signals.
Ethernet 8 • Uses CSMA/CD • Preamble: sequence of alternating 0’s and 1’s • allows receiver to synch with clock. • Source and Destination Address: • Each 48-bits; globally unique • Type: Identifies the higher level protocol • Body: • up to 1500 bytes of data • minimum 46 bytes data – why? • required to detect collision • host may have to pad frame Post amble
Token Rings (FDDI) • consists of a set of nodes connected in a ring, e.g. FDDI (Fiber Distributed Data Interface). • data flows in one particular direction around ring, each node receives data from its upstream neighbor. • a single shared medium rather than a set of point-to-point links connected in a ring. • distributed algorithm controls who gets to transmit and • all nodes see all frames. • Token: • A special sequence of bits circulating around the ring. • Each node receives and than forwards the token.
Frame Format • Unique bit sequence denoting begin & end of frame. • Frame up to 4500 bytes long including header info →4500-22=4478 bytes of data. • Control field: 1st bit indicates asynch (0) or synch (1) data 2nd bit indicates 16 bits (0) or 48 bit(1) address being used Last 6 bit indicates demux key similar to type field in EN Certain frame types do not identify a hlp but are used internally, e.g. token itself, claim frame • Status: used by destination to send info back e.g. If there was an error. If it copied frame (i.e. had enough buffer space).
Transmission Protocol • When a node with frame to transmit sees the token, it takes it off the ring (i.e. does not forward) and inserts its frame into the ring. • Each node forwards the frame and destination node saves a copy before forwarding. • When frame reaches source, it takes frame off ring and reinserts token. • Now some downstream node has chance to transmit frame. • Fair: each node (eventually) gets chance to transmit • node serviced in round–robin fashion.
Timed-Token Algorithm • Token Holding Time (THT): max amount of time a node is allowed to hold token. • THT = a means a node transmits as much data as it has before releasing token. • More bytes a node can send each time it has token (i.e. a higher THT)->higher utilization of ring. • disadvantages: not good if multiple nodes have data to send • favors nodes with more data, even if a small message needs to be delivered as soon as possible. ∴Balance is needed