710 likes | 756 Views
Direct Link Networks. Encoding and Framing Error Detection/Correction Reliable Transmission will be covered later (with TCP) Media Access Control (Wired) LAN Technologies Readings Chapter 2 except Section 2.5, which is delayed to the discusson on Transport layer. Bits. 0. 0. 1. 0. 1.
E N D
Direct Link Networks • Encoding and Framing • Error Detection/Correction • Reliable Transmission will be covered later (with TCP) • Media Access Control • (Wired) LAN Technologies • Readings • Chapter 2 except Section 2.5, which is delayed to the discusson on Transport layer. Direct Link networks
Bits 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 NRZ Encoding • Signals propagate over a physical medium • modulate electromagnetic waves (on amplitude, frequency, and phase): the process of encoding source data onto a carrier signal with frequency f_c • e.g., vary voltage (amplitude) • Encode binary data onto signals • e.g., 0 as low signal and 1 as high signal • known as Non-Return to zero (NRZ) Direct Link networks
Problems: Consecutive 1s or 0s • Low signal (0) may be interpreted as no signal • High signal (1) leads to baseline wander • Receiver keeps an average of the signal it has seen so far and uses this average to distinguish between low and high signals • Unable to recover clock • Clocks at the sender and receiver use signal transition to synchronize each other Direct Link networks
Alternative Encodings • Non-return to Zero Inverted (NRZI) • make a transition from current signal to encode a one; stay at current signal to encode a zero • solves the problem of consecutive ones • Manchester • transmit XOR of the NRZ encoded data and the clock • only 50% efficient. Direct Link networks
Encodings (cont) • 4B/5B • 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 Direct Link networks
Bits 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 NRZ Clock Manchester NRZI Encodings (cont) Direct Link networks
Bits Node A Adaptor Adaptor Node B Frames Framing • Break sequence of bits into a frame – why? determine where a frame starts and ends • Typically implemented by network adaptor Direct Link networks
8 16 16 8 Beginning Ending Header Body CRC sequence sequence Approaches • Sentinel-based • delineate frame with special pattern: 01111110 • e.g., HDLC, SDLC, PPP • problem: special pattern appears in the payload • solution: bit stuffing • sender: insert 0 after five consecutive 1s • receiver: delete 0 that follows five consecutive 1s • What if the receiver sees a 1? Direct Link networks
Approaches (cont) • Couter-based • include payload length in header • e.g., DDCMP • problem: count field corrupted • solution: catch when CRC fails • How many frames are affected when counter or sentinel is corrupted? Direct Link networks
Approaches (cont) • Clock-based • each frame is 125us long • e.g., SONET: Synchronous Optical Network Special bit pattern Direct Link networks
Handling Errors • Data can be corrupted during transmission • Bit values changed • Frame includes additional information • Set by sender • Checked by receiver • Error-detection vs error-correction • Both need redundant information • Detection: error exists or not. • Correction: repair if there was an error • Statistical guarantee Direct Link networks
Error Detecting and Correcting Codes • How many check/redundancy bits? • To detect single-bit error • 1 bit: even/odd parity • To correct a single-bit error in m-bit message • Need a minimum of r bits such that • (m + r + 1) 2r • Example: 3-bit message needs 3-bit redundancy • Correction or detection+retransmission? Direct Link networks
Error Detection Techniques • Checksum • Treat data as sequence of integers • Compute and send arithmetic sum • Detects some multiple bit errors not all • Internet Checksum • Cyclic Redundancy Check • Mathematical function of data • More complex to compute • Handles more errors Direct Link networks
Cyclic Redundancy Check • Add k bits of redundant data to an n-bit message • want k << n • e.g., k = 32 and n = 12,000 (1500 bytes) • 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 Direct Link networks
CRC (cont) • Transmit polynomial P(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 • Receiver polynomial P(x) + E(x) • E(x) = 0 implies no errors • Divide (P(x) + E(x)) by C(x); remainder zero if: • E(x) was zero (no error), or • E(x) is exactly divisible by C(x) Direct Link networks
11111001 Generator Message 1101 10011010000 1101 1001 1101 1000 1101 1011 1101 1100 1101 1000 1101 101 Remainder CRC Example Direct Link networks
Choice of C(x) • Want to ensure C(x) doesn’t divide E(x) • We can detect • All single-bit errors if • C(x) has at least 2 terms • All double-bit errors if • C(x) doesn’t divide xj + 1 • X15 + x14 + 1 doesn’t divide xj + 1 for any j below 32768 • Any odd number of errors if • C(x) contains the factor x+1 • Any “burst” error of length less than or equal to k bits • Most burst errors of length greater than k bits Direct Link networks
Error Detection Summary • To detect data corruption • Sender adds additional information to packet • Receiver checks • Techniques • Parity bit • Checksum • Cyclic Redundancy Check Direct Link networks
Hamming Error Correcting Code • Achieve the theoretical lower limit of the number of redundant bits • Correcting single-bit errors • Method: • Put information bits at positions that are not equal to powers of two • Compute the check bits at positions that are power of two • A check bit at position 2^j, where j=0, 1, …, checks an information bit at position i if and only if the binary representation of i contains a 1 at position j. • The value of an “even” check bit equals the xor of all checked information bits • At the receiver side, all checked bits and the check bit are xored and a zero indicates error free; otherwise, the sum of the positions of the check bits with a non-zero value indicates the bit that is in error • Example • Information bits: 1001000 • Coded bits: 00110010000 Direct Link networks
Error Recovery • Reliable delivery over unreliable channel • How to recover from corrupted/lost packets • Error detection and retransmission • With acknowledgements and timeouts • Also called Automatic Repeat Request (ARQ) • Retransmission incurs round trip delay • Error correcting codes • Also called Forward Error Correction (FEC) • No sender retransmission required Direct Link networks
Summary • Encoding • Framing • Error correction/detection codes • Parity/Checksum/CRC Direct Link networks
Shared Media andLocal Area Networks • Shared Media Access Problem • Media access control (MAC) and LAN • MAC addresses and network adaptors (NICs) • MAC protocols: random access vs. controlled access • Ethernet • Token Ring and FDDI (read yourself) • 802.11 Wireless LAN (WiFi and WiMAX) (next lecture) Direct Link networks
Multiple Access Links and LANs Two types of “links”: • point-to-point, e.g., • PPP for dial-up access, or over optical fibers • broadcast (shared wire or medium), e.g. • traditional Ethernet • 802.11 wireless LAN Direct Link networks
RAM RAM Typical LAN Structure • Transmission Medium • Network Interface Card (NIC) • Unique MAC “physical” address Ethernet Processor ROM Direct Link networks
link layer implemented in “adaptor” (aka NIC), with “transceiver” in it Ethernet card, dial-up modem, 802.11 wireless card sending side: encapsulates packet in frame adds error checking bits, flow control, reliable data transmission, etc. receiving side looks for errors, flow control, reliable data transmission, etc extracts packet, passes to receiving node data link & physical layers are closely coupled! frame frame Adaptors Communicating network packet rcving node link layer protocol sending node adapter adapter Direct Link networks
MAC (Physical) Addresses • Addressing needed in shared media • MAC (media access control) or physical addresses • To identify source and destination interfaces and get frames delivered from one interface to another physically-connected interface (i.e., on same physical local area network!) • 48 bit MAC address (for most LANs) • fixed for each adaptor, burned in the adapter ROM • MAC address allocation administered by IEEE • 1st bit: 0 unicast, 1 multicast. • all 1’s : broadcast • MAC flat address -> portability • can move LAN card from one LAN to another Direct Link networks
MAC (Physical, or LAN) Addresses MAC addressing operations on a LAN: • each adaptor on the LAN “sees” all frames • accept a frame only ifdest. (unicast) MAC address matches its own MAC address • accept all broadcast (MAC= all 1’s) frames • accept all frames if set in “promiscuous” mode • can configure to accept certain multicast addresses (first bit = 1) Direct Link networks
OSI IEEE 802 Network layer Network layer 802.2 Logical link control LLC Data link layer 802.11 Wireless LAN Other LANs 802.3 CSMA-CD 802.5 Token Ring MAC Physical layer Various physical layers Physical layer MAC Sub-layer Direct Link networks
Broadcast Links: Multiple Access Single shared communication channel • Only one can send successfully at a time • Two or more simultaneous transmissions • interference! • How to share a broadcast channel • media access control uses same shared media • Humans use multi-access protocols all the time Direct Link networks
Random Access • Stations contend for channels • Overlapping transmissions (collisions) can occur • Carrier sensing? • Collision detection? • Protocols • Aloha • Slotted Aloha • Carrier Sense Multiple Access: Ethernet Direct Link networks
Controlled Access • Stations reserve or are allocated channel • No collisions • Allocation: static or dynamic • Protocols • Static channel allocation • Time division multiple access • Demand adaptive channel allocation • Reservation protocols • Token passing (token bus, token ring) Direct Link networks
Taxonomy of MAC Protocols WiFi (802.11) Direct Link networks
Pure (unslotted) Aloha • Simpler, no synchronization • Just send: no waiting for beginning of slot Direct Link networks
Slotted Aloha • Time is divided into equal size slots • Nodes transmit at the beginning of a slot • If collision, retransmit later Success (S), Collision (C), Empty (E) slots Direct Link networks
0.4 0.3 Slotted Aloha 0.2 0.1 Pure Aloha 1.5 2.0 0.5 1.0 G = offered load = Np Performance of Aloha Protocols S = throughput = “goodput” (success rate) Direct Link networks
Carrier Sense Multiple Access • Aloha is inefficient (and rude) • Doesn’t listen before talking • CSMA: Listen before transmit • If channel idle, transmit entire packet • If busy, defer transmission • How long should we wait? • Human analogy: don’t interrupt others • Can carrier sense avoid collisions completely? Direct Link networks
Persistent and Non-persistent CSMA • Non-persistent • If idle, transmit • If busy, wait random amount of time • If collision, wait random amount of time • p-persistent • If idle, transmit with probability p • If busy, wait till it becomes idle • If collision, wait random amount of time Direct Link networks
CSMA/CD CSMA with collision detection (CD) • Listen while talking • Stop transmitting when collision detected • Compare transmitted and received signals • Save time and bandwidth • Improvement over persistent and nonpersistent protocols • Human analogy • Polite conversationalist • Worst case time to detect a collision? Direct Link networks
Collisions A B A B A B A B Direct Link networks
Worst Case Collision Detection Time Direct Link networks
CSMA/CD: Illustration Direct Link networks
64 48 48 16 32 Src Dest Preamble Type Body CRC addr addr Ethernet Overview • History • developed by Xerox PARC in mid-1970s • roots in Aloha packet-radio network • standardized by Xerox, DEC, and Intel in 1978 • similar to IEEE 802.3 standard • CSMA/CD • carrier sense • multiple access • collision detection • Frame Format Direct Link networks
Ethernet “Dominant” LAN technology: • cheap $20 for 100Mbs! • first widely used LAN technology • Simpler, cheaper than token ring LANs and ATM • Kept up with speed race: 10, 100, 1000 Mbps Metcalfe’s Ethernet sketch Direct Link networks
8 bytes 6 6 2 0-1500 4 Src Dest Type Data Preamble CRC addr addr 8 bytes 6 6 2 0-1500 4 Src Dest Length Data Preamble CRC addr addr Ethernet Frame Format DIX frame format Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame IEEE 802.3 format • Ethernet has a maximum frame size: data portion <=1500 bytes • It imposes a minimum frame size: 64 bytes (excluding preamble) • If data portion <46 bytes, pad with “junk” to make it 46 bytes • Q: Why minimum frame size in Ethernet? Direct Link networks
Fields in Ethernet Frame Format • Preamble: • 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 (SoF: start-of-frame) • used to synchronize receiver, sender clock rates, and identify beginning of a frame • Addresses: 6 bytes • if adapter receives frame with matching destination address, or with broadcast address (eg ARP packet), it passes data in frame to network layer protocol (specified by TYPE field) • otherwise, adapter discards frame • Type: indicates the higher layer protocol, mostly IP but others may be supported such as Novell IPX and AppleTalk • 802.3: Length gives data size; “protocol type” included in data • CRC: checked at receiver, if error is detected, the frame is simply dropped Direct Link networks
IEEE 802.3 MAC: Ethernet MAC Protocol: • CSMA/CD • Truncated binary exponential backoff • for retransmission n: 0 < r < 2k *ASlotTime, where k=min(n,10) • give up after 16 retransmissions • Slot Time is the critical system parameter • upper bound on time to detect collision • upper bound on time to acquire channel • upper bound on length of frame segment generated by collision • quantum for retransmission scheduling • max{round-trip propagation, MAC jam time} Direct Link networks
IEEE 802.3 Parameters • 1 bit time = time to transmit one bit • 10 Mbps 1 bit time = 0.1 s • Maximum network diameter 2.5km • Maximum 4 repeaters • “Collision Domain” • Distance within which collision can occur and be detected • IEEE 802.3 specifies: worst case collision detection time: 51.2 s • Slot time • 51.2 s = 512 bits = 64 bytes • Why minimum frame size? • 51.2 s => minimum # of bits can be transited at 10Mpbs is 512 bits => 64 bytes is required for collision detection Direct Link networks
Ethernet MAC Protocol: Basic Ideas 1-persistent CSMA/CD • Carrier sense: station listens to channel first • Listen before talking • If idle, station may initiate transmission • Talk if quiet • Collision detection: continuously monitor channel • Listen while talking • If collision, stop transmission • One talker at a time • Exponential binary back-off algorithm Direct Link networks
Ethernet CSMA/CD Alg. Flow Chart Direct Link networks
1. Adaptor gets datagram and creates frame 2. If adapter senses channel idle, it starts to transmit frame. If it senses channel busy, waits until channel idle and then transmits 3. If adapter transmits entire frame without detecting another transmission, the adapter is done with frame ! Signal to network layer “transmit OK” 4. If adapter detects another transmission while transmitting, aborts and sends jam signal 5. After aborting, adapter enters exponential backoff: after the mth collision, adapter chooses a K at random from {0,1,2,…,2m-1}. Adapter waits K*512 bit times and returns to Step 2 6. Quit after 16 attempts, signal to network layer “transmit error” Ethernet CSMA/CD Algorithm Direct Link networks