Computer Network Direct Link Networks Reliable Transmission rev 1.01 24/2/2004 1
Outline Direct link networks (Ch. 2) Encoding Framing Error detection Reliable delivery Media access control Network Adapter rev 1.01 24/2/2004 2
Hardware Building Blocks Nodes Hosts: General-purpose computers Switches: Typically special-purpose H/W Routers Links Cooper with electronic signaling Glass fibre with optical signaling Wireless with electromagnetic (radio, Infra Red, Microwave) signaling rev 1.01 24/2/2004 3
rev 1.01 24/2/2004 4
Link Cooper Based Media Cat 5 Twisted Pair 10 100 Mbps 100m Thin Net Coax 10 100 Mbps 200m Thick Net Coax 10 100 Mbps 500m rev 1.01 24/2/2004 5
Link Optical Media Multimode Fibre 100 Mbps 2Km Singlemode Fibre 100-2400 Mbps 40Km rev 1.01 24/2/2004 6
Link Comparison Of Octical Media Single mode Lower attenuation (longer distances) Lower dispersion (higher data rates) Multi mode Cheap (IF vs Laser) Easier to terminate rev 1.01 24/2/2004 7
Link Advantages of optical communication higher bandwidths superior attenuation properties immune from electromagnetic interference no crosstalk between fibers thin, lightweight, and cheap (the fiber, not the optical-electrical interfaces) rev 1.01 24/2/2004 8
Link Wireless transmission 2.4 GHz radio 11 Mbps 7Km Infrared (IR) link 1 Mbps 9 m Geosynchronous satellite 600-1000 Mbps continent rev 1.01 24/2/2004 9
Services available from carriers rev 1.01 24/2/2004 10
rev 1.01 24/2/2004 11
Encoding (line coding) problems with signal transmission attenuation: signal power absorbed by medium dispersion: a discrete signal spreads in space noise: random background signals Problem is how are 0 s and 1 s detected at receiving node in a robust fashion rev 1.01 24/2/2004 12
Encoding Taxonomy Digital data, digital signal codes which represent bits our focus many strategies! Analog data, digital signal sampling to represent voltages Digital data, analog signal modulation to represent bits Analog data, analog signal modulation to represent voltages rev 1.01 24/2/2004 13
Non-Return to Zero (NRZ) 0 low signal; 1 high signal Poor clock synchronization when there is a long string of 1 s or 0 s rev 1.01 24/2/2004 14
NRZ-Inverted (NRZI) 1 make transition; 0 stay at the current level Addresses clock synchronization problem for long strings of 1 s still out of luck on consecutive strings of 0 s rev 1.01 24/2/2004 15
rev 1.01 24/2/2004 16
Manchester Encoding Each bit contains a transition 0 high-to-low transition 1 low-to-high transition Enables effective clock recovery at receiver Used by 802.3-10 Mbps Ethernet rev 1.01 24/2/2004 17
Manchester Encoding contd. Disadvantage: needs a clock that is twice as fast as the transmission rate 1 1 0 1 0 1 0 0 1 Manchester Clock rev 1.01 24/2/2004 18
4B/5B Encoding Tries to address inefficiencies in Manchester Idea is to insert extra bits in bit stream to break up long strings of 0 s or 1 s Every 4 bits of data are encoded in 5 bit code (see text for details) at most one leading 0 at most two trailing 0 s therefore never more than three consecutive 0 s Uses NRZI to put bits on wire reason why code focused on zeros rev 1.01 24/2/2004 19
Framing Blocks of data (not just sequences of bits) are exchanged across links --- frames Problem: how to tell where a frame begins and where it ends rev 1.01 24/2/2004 20
Character-Based Framing Special characters (tags) are used to indicate idle fill (ASCII SYN), start of text (STX) and end of text (ETX) Used by PPP (point-to-point protocol) Problem: what if tag characters occur in packet data rev 1.01 24/2/2004 21
Character-Based Framing contd. Solution: Insert extra escape characters when a tag appears in data field rev 1.01 24/2/2004 22
Bit-Oriented Framing Each frame begins with a start and end bit sequence (flag) 01111110 = 01 6 0 is the usual flag Example: HDLC (high-level data link protocol) Problem: what if flag appears in body rev 1.01 24/2/2004 23
Bit Stuffing Sender: inserts a 0 after five consecutive 1s Receiver: when it sees five 1s makes decision based on next two bits if next bit 0 (this is a stuffed bit), remove it if next bit 1, look at next bit if 0 this is end of frame (receiver has seen 01111110) if 1 this is an error, discard frame (receiver has seen 01111111) rev 1.01 24/2/2004 24
Bit Stuffing Example rev 1.01 24/2/2004 25
Framing with Length Fields Detecting the end of the frame done by sending length information (e.g. number of bytes in the frame) in the header Used by DECNET s DDCMP Q: Is a flag still needed at the start of the frame? rev 1.01 24/2/2004 26
Digital transmission over analog modulation to represent bits amplitude (AM) frequency (FM) phase/phase shift combinations of these rev 1.01 24/2/2004 27
rev 1.01 24/2/2004 28
rev 1.01 24/2/2004 29
rev 1.01 24/2/2004 30
Error Detection Bit errors can be introduced in packets This problem has been studied for a long time Error detection (and correction) codes Cyclic redundancy check (CRC) is a common error detection method Basic idea of any scheme is to add redundant data A primary goal is to send minimal amount of redundant data Another goal is to make generation of code fast rev 1.01 24/2/2004 31
Error Detection We use error-detecting codes to help detect errors Example code: Consider the function that duplicates each bit in the message E.g. the message 1011001 would be mapped to the code 11001111000011, and then transmitted to the sender. The receiver knows that bits come in pairs. If the two bits in a pair are different, it declares that there was a bit error. rev 1.01 24/2/2004 32
Parity Parity added to make @ 1s even/odd If parity is wrong 0 1 1 1 0 1 0 1 1 ERROR If parity is right NO ERROR (or an even number of errors has occurred) rev 1.01 24/2/2004 33
Two-Dimensional Parity Q: If an error is detected in this scheme, is it also correctable? rev 1.01 24/2/2004 34
Two-Dimensional Parity 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 1 One error Example Three errors 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 1 Arrows indicate failed check bits 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 1 1 Two errors Four errors rev 1.01 24/2/2004 35
Internet Checksum Used by IP, TCP, UDP,... Method Break message as a sequence of 16-bit integers Add these integers using 16-bit one s complement arithmetic Take the one s complement of the result Resulting 16-bit number is the checksum It s simple to implement Reason why it s used despite relatively weak detection capability rev 1.01 24/2/2004 36
Reliable Transmission Big Q: How do we send a packet reliably when it can be lost and/or corrupted in the network? Mechanisms Acknowledgements Timeouts Simplest reliable protocol: Stop and Wait send a packet stop and wait until an ACK arrives from the receiver retransmit if timeout occurs before ACK arrives rev 1.01 24/2/2004 37
Stop and Wait rev 1.01 24/2/2004 38
Recovering from Errors rev 1.01 24/2/2004 39
Reliable Transmission How does the receiver recognize a duplicate transmission (e.g. in the case of a lost ACK)? Solution: Put sequence number in packet Performance No pipeline effect Example For a l.5 Mbps link with 45 ms RTT Bandwidth-delay product = 67.5 Kb (8KB) 1KB packets imply 1/8th link utilization Solution: Sliding Window Protocols rev 1.01 24/2/2004 40
How do we keep the pipe full? Send multiple packets without waiting for the first to be ACKed Upper bound on un-acked packets, called Sender Receiver window Time rev 1.01 24/2/2004 41
Sliding Windows: Sender State Packets sent and ACKed (LAR = last ACK received) Packets sent but not ACKed (buffer for SWS packets) Packets not yet sent (LFS = last packet sent) Keep LFS - LAR SWS SWS LAR LFS Advance LAR when ACK arrives rev 1.01 24/2/2004 42
State Sliding Windows: Receiver Packets received and ACKed (NFE = next frame expected, LFR = last packet received) Packets received out of order (buffer for RWS packets) Packets not yet received (LFA = last frame acceptable) Keep LFA - LFR RWS RWS LFR LFA rev 1.01 24/2/2004 43
What if we lose a packet? Selective repeat/ack (SACK) Receiver sends ACK for each packet in window On timeout, sender resends only the missing packet Proposed for TCP Go back N with buffering out-of-order packets (TCP) Receiver ACKs got up through packet k If multiple packets are received, only one ACK is needed On timeout, sender restarts from k + 1 Different from traditional Go back N rev 1.01 24/2/2004 44
Traditional Go back N window size 4 Go back N with buffering window size 4 rev 1.01 24/2/2004 45
Sender Algorithm Send full window, set timeout On ACK If it increases LAR (packets sent and ACKed) send remaining packets in window On timeout Resend all outstanding packets starting from LAR + 1 (first packet not yet ACKed) rev 1.01 24/2/2004 46
Receiver Algorithm On packet arrival If packet is the NFE (next frame expected) Else Send ACK Increase NFE Deliver packet(s) to the upper layer (could fill hole in buffer) Send ACK Discard if < NFE or > LFA rev 1.01 24/2/2004 47
How to determine timeouts? Problem: If timeout too small, useless retransmits If timeout too large, low utilization (pipe not full) Solution: On direct link, timeout 2 x PROP Trickier to estimate at transport layer RTT varies with congestion, route changes, etc. rev 1.01 24/2/2004 48
Sequence Number Space Recall seq # (SeqNum) cannot grow arbitrarily SWS MaxSeqNum - 1 is not sufficient Suppose 3-bit SeqNum field (0 7) SWS = RWS = 7 sender transmits packets 0..6 arrive successfully, but ACKs lost sender retransmits 0..6 receiver expecting 7, 0..5, but receives the original incarnation of 0..5 SWS (MaxSeqNum + 1)/2 is correct rule rev 1.01 24/2/2004 49
Sliding Window Summary Sliding window is best known algorithm in networking First role is to enable reliable delivery of packets Timeouts and acknowledgements Second role is to enable in order delivery of packets Receiver doesn t pass data up to app until it has packets in order Third role is to enable flow control Prevents sender from overflowing receiver s buffer rev 1.01 24/2/2004 50