15-744: computer networking l-2 links. l -2; 1-17-01© srinivasan seshan, 20012 links how to make...
Post on 21-Dec-2015
218 views
TRANSCRIPT
15-744: Computer Networking
L-2 Links
L -2; 1-17-01© Srinivasan Seshan, 2001 2
Links
• How to make computers talk across a wire• How to share the wire• How to extend to multiple segments• Assigned reading
• [MB76] ETHERNET: Distributed Packet Switching for Local Area Networks
• [B+88] Measured Capacity of an Ethernet: Myths and Reality
L -2; 1-17-01© Srinivasan Seshan, 2001 3
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
L -2; 1-17-01© Srinivasan Seshan, 2001 4
Modulation
• Non-Return to Zero (NRZ)• Used by Synchronous Optical Network
(SONET)• 1=high signal, 0=low signal• Long sequence of same bit cause difficulty
• DC bias hard to detect – low and high detected by difference from average voltage
• Clock recovery difficult
• SONET XOR’s bit sequence to ensure frequent transitions
L -2; 1-17-01© Srinivasan Seshan, 2001 5
Clock Recovery
• When to sample voltage?• 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
L -2; 1-17-01© Srinivasan Seshan, 2001 6
Modulation
• Non-Return to Zero Inverted (NRZI)• 1=inversion of current value, 0=same value• No problem with string of 1’s• NRZ-like problem with string of 0’s
L -2; 1-17-01© Srinivasan Seshan, 2001 7
Modulation
• Manchester• Used by Ethernet• 0=low to high transition, 1=high to low transition• Transition for every bit simplifies clock recovery• Not very efficient
• Doubles the number of transitions• Circuitry must run twice as fast
L -2; 1-17-01© Srinivasan Seshan, 2001 8
Modulation
• 4b/5b• Used by FDDI• Uses 5bits to encode every 4bits• Encoding ensures no more than 3 consecutive
0’s• Uses NRZI to encode resulting sequence• 16 data values, 3 “special” illegal values, 6
“extra” values, 7 illegal values
L -2; 1-17-01© Srinivasan Seshan, 2001 9
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
L -2; 1-17-01© Srinivasan Seshan, 2001 10
Framing
• Length delimited• Beginning of frame has length• Single corrupt length can cause problems
• Must have start of frame character to resynchronize• Resynchronization can fail if start of frame character
is inside packets as well
L -2; 1-17-01© Srinivasan Seshan, 2001 11
Framing
• 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
L -2; 1-17-01© Srinivasan Seshan, 2001 12
Clock-Based Framing
• Used by SONET• Fixed size frames (810 bytes)• Look for start of frame marker that appears
every 810 bytes• Will eventually sync up
L -2; 1-17-01© Srinivasan Seshan, 2001 13
Consistent Overhead Byte Stuffing
• Run length encoding applied to byte stuffing• Encoding
• Add implied 0 to end of frame• Each 0 is replaced with (number of bytes to
next 0) + 1• What if no 0 within 255 bytes? – 255 value
indicates 254 bytes followed by no zero• Worst case – no 0’s in packet – 1/254 overhead• Possible optimization to encode series of 0’s
L -2; 1-17-01© Srinivasan Seshan, 2001 14
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
L -2; 1-17-01© Srinivasan Seshan, 2001 15
Error Detection - Checksum
• Used by TCP, UDP, IP, etc..• Ones complement sum of all
words/shorts/bytes in packet• Simple to implement• Relatively weak detection
• Easily tricked by typical loss patterns
L -2; 1-17-01© Srinivasan Seshan, 2001 16
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
L -2; 1-17-01© Srinivasan Seshan, 2001 17
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
L -2; 1-17-01© Srinivasan Seshan, 2001 18
Stop and Wait
Time
Packet
ACKTim
eou
t
• Simplest ARQ protocol
• Send a packet, stop and wait until acknowledgement arrives
Sender Receiver
L -2; 1-17-01© Srinivasan Seshan, 2001 19
Recovering from Error
Packet
ACK
Tim
eou
t
Packet
ACK
Tim
eou
t
Packet
Tim
eou
t
Packet
ACKT
ime
out
Time
Packet
ACK
Tim
eou
t
Packet
ACK
Tim
eou
t
ACK lost Packet lost Early timeout
L -2; 1-17-01© Srinivasan Seshan, 2001 20
Problems with Stop and Wait
• How to recognize a duplicate
• Performance• Can only send one packet per round trip
L -2; 1-17-01© Srinivasan Seshan, 2001 21
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 1ACK 0
L -2; 1-17-01© Srinivasan Seshan, 2001 22
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
L -2; 1-17-01© Srinivasan Seshan, 2001 23
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
L -2; 1-17-01© Srinivasan Seshan, 2001 24
ReceiverReceiverSenderSender
Sender/Receiver State
… …
Sent & Acked Sent Not Acked
OK to Send Not Usable
… …
Max acceptable
Receiver window
Max ACK received Next seqnum
Received & Acked Acceptable Packet
Not Usable
Sender window
Next expected
L -2; 1-17-01© Srinivasan Seshan, 2001 25
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
L -2; 1-17-01© Srinivasan Seshan, 2001 26
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
L -2; 1-17-01© Srinivasan Seshan, 2001 27
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
L -2; 1-17-01© Srinivasan Seshan, 2001 28
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
L -2; 1-17-01© Srinivasan Seshan, 2001 29
Broadcast Network Arbitration
• Like sharing a single cpu must share a link • Give everyone a fixed time/freq slot?
• Ok for fixed bandwidth (e.g., voice)• What if traffic is bursty?
• Centralized arbiter• Ex: cell phone base station• Single point of failure
• Distributed arbitration• Aloha/Ethernet
L -2; 1-17-01© Srinivasan Seshan, 2001 30
Multiplexing/Media Access/Sharing
• FDMA• Different freq
• CDMA (covered in wireless lecture)• Different codes • Direct sequence• Frequency hopping
• TDMA• Different times• Synchronous TDMA• CSMA, etc
L -2; 1-17-01© Srinivasan Seshan, 2001 31
Ethernet
• First practical local area network, built at Xerox PARC in 70’s
• Carrier sense• Check to see if active transmission
• Collision detect• Sender checks for collision; wait and retry
• Adaptive randomized wait to avoid collisions
L -2; 1-17-01© Srinivasan Seshan, 2001 32
Ethernet MAC Protocol
Packet?
Sense Carrier
Discard Packet
Send Detect Collision
b=CalcBackoff(); wait(b);
attempts++;
No
Yes
attempts < 16
attempts == 16
L -2; 1-17-01© Srinivasan Seshan, 2001 33
Ethernet Backoff Calculation
• If deterministic delay after collision, collision will occur again in lockstep
• If random delay with fixed mean• Few senders needless waiting• Too many senders too many collisions
• Exponentially increasing random delay• Infer senders from # of collisions• More senders increase wait time
L -2; 1-17-01© Srinivasan Seshan, 2001 34
Minimum Packet Size
• What if two people sent really small packets• How do you find
collision?• None in paper – but
is one in reality
L -2; 1-17-01© Srinivasan Seshan, 2001 35
Ethernet Collision Detect
• Min packet length > 2x max prop delay• If A, B are at opposite sides of link, and B starts
one link prop delay after A
• Jam network for 32-48 bits after collision, then stop sending• Ensures that everyone notices collision
L -2; 1-17-01© Srinivasan Seshan, 2001 36
End to End Delay
• 1Km, c in cable = 60% * c in vacuum = 1.8 x 10^8 m/s• 1000/1.8 x 10^8 ~= 5 x 10^-6 = 5us• 5us * 3Mbps = 15bits in flight!
• Modern 10Mb Ethernet {• 2.5km, 10Mbps • ~= 12.5us delay• +introduced repeaters (max 5 segments)• worst case – 51.2us round trip time!
L -2; 1-17-01© Srinivasan Seshan, 2001 37
Minimum Packet Size
• Slot time = 51.2us = 512bits in flight• After this amount, sender is guaranteed sole access to
link• 51.2us = slot time for backoff
• What about scaling? 100Mbit, 1Gbit...• Make network smaller?
• Solution for 100BaseT• Make min pkt size larger?
• 512bits @ 1Gbps = 512ns• 512ns * 1.8 * 10^8 = 92meters• Gigabit ethernet uses collision extension for small pkts
L -2; 1-17-01© Srinivasan Seshan, 2001 38
Ethernet Packet Format
• Preamble – 8 byte• 101010…1011
• Src/Dst Address – 6 bytes• Globally unique• Allocated to manufacturers
• Type – 2 bytes• Data – 46 to 1500 bytes• CRC – 4 bytes
Preamble Dst. Addr. TypeSrc. Addr. Data CRC
L -2; 1-17-01© Srinivasan Seshan, 2001 39
Interaction with Layering
• TYPE field• Identifies upper layer protocol• Enables the multiplexing of protocols
• ARP• Broadcast search for IP address• Destination responds with appropriate 48-bit
Ethernet address
L -2; 1-17-01© Srinivasan Seshan, 2001 40
Simple Analysis of Efficiency
• If pkt size/link speed = P/C = slot time = T• Minimum packet size• E = 1/(1+W) = 1/ (1 + (1-A)/A) = A• A = (1-(1/Q))^(Q-1)• If Q >>1 the E = A = 1/e = well known Ethernet limit
• Assumptions • Single pkt size• Always have pkt to send• Master slot clock, all transmissions start a slot start• Q is estimated well by exponential backoff
L -2; 1-17-01© Srinivasan Seshan, 2001 41
Ethernet Problems
• Ethernet unstable at high loads• Peak utilization = 1/e = 37%
• Peak throughput worse with• More hosts – more collisions needed to identify
single sender• Smaller packet sizes – more frequent
arbitration• Longer links – collisions take longer to observe,
more wasted bandwidth
L -2; 1-17-01© Srinivasan Seshan, 2001 42
Source of Myths
• Assumptions in various analyses• Static parameters
• Maximum propagation time and slot time• Maximum packet size• 1-persistence
• Workload parameters• Packet length distribution• Number of hosts• Length of cable and placement of hosts• Load
• Evaluated under unreasonable high load
L -2; 1-17-01© Srinivasan Seshan, 2001 43
Measurement of Real Ethernet
• Evaluate performance in some typical scenarios• Scenario 1
• Topology: 4 clusters of 6 hosts – similar to office configuration
• Fixed pkt size• Throughput decreases with number of hosts &
increases with pkt size – as expected• Fairness improves with number of hosts – capture
effects less likely• Only linear increase in delay with number of hosts -
unexpected
L -2; 1-17-01© Srinivasan Seshan, 2001 44
Measurement of Real Ethernet
• Scenario 2• Topology: 23 hosts on short net• Load: fixed pkt size• Improvement in bit rate over scenario 1
• Scenario 3• Topology: 4 clusters• Load: bimodal pkt size• 7/1 ratio of small to large pkts is sufficient to
greatly improve total bit rate
L -2; 1-17-01© Srinivasan Seshan, 2001 45
How to Improve Performance
• No long cables• Fewer hosts per cable• Use large packets• Don't mix real-time w/ bulk-data if possible
• Can’t provide good efficiency/throughput and good latency
L -2; 1-17-01© Srinivasan Seshan, 2001 46
Ethernet Packet Traces
• Ethernet traffic is “self-similar” (fractal)• Bursty at every time scale (msecs to months)
• Implication?• On average, low load• Occasional peaks
L -2; 1-17-01© Srinivasan Seshan, 2001 47
Token Rings
• Packets broadcast around ring• Token “right to send” rotates around ring
• Fair, real-time bandwidth allocation• Every host holds token for limited time• Higher latency when only one sender
• Higher bandwidth• Point to point links electrically simpler than bus
L -2; 1-17-01© Srinivasan Seshan, 2001 48
Why Did Ethernet Win?
• Failure modes• Token rings – network unusable• Ethernet – node detached
• Good performance in common case• Volume lower cost higher volume ….• Adaptable
• To higher bandwidths (vs. FDDI)• To switching (vs. ATM)
• Completely distributed, easy to maintain/administer• Easy incremental deployment• Cheap cabling, etc
L -2; 1-17-01© Srinivasan Seshan, 2001 49
LAN Switching
• Extend reach of a single shared medium• Connect two or more “segments” by
copying data frames between them
LAN 1 LAN 2
L -2; 1-17-01© Srinivasan Seshan, 2001 50
Switched Network Advantages
• Higher link bandwidth• Point to point electrically simpler than bus
• Much greater aggregate bandwidth• Separate segments can send at once
• Improved fault tolerance• Redundant paths
• Challenge• Learning which packets to copy across links• Avoiding forwarding loops
L -2; 1-17-01© Srinivasan Seshan, 2001 51
Learning Bridges
• Basic idea: build cache of which nodes are downstream of which ports
• Monitor source address on all packets bridge forwards
• Insert reverse path to source into cache• What to do with unknown sources?
• Flood network
L -2; 1-17-01© Srinivasan Seshan, 2001 52
Bridges with Loops
B1 B2
LAN 1
LAN 2
Port 21
Port 22
Port 11
Port 12
S
Node
S
Port
11
Cache at B1
Node
S
Port
21
Cache at B2
S D Type DataPacket from S on LAN 1
L -2; 1-17-01© Srinivasan Seshan, 2001 53
Loop Solution: Spanning Tree
• Only want a single spanning tree• First step agree on a root• Lowest node ID
• Each bridge announces its current root and distance to root
• Lowest distance become responsible for link
• Ties go to lower bridge ID
L -2; 1-17-01© Srinivasan Seshan, 2001 54
Next Lecture: Layer Functionality
• How to determine split of functionality• Across protocol layers• Across network nodes
• Assigned Reading• [SRC84] End-to-end Arguments in System
Design• [Cla88] Design Philosophy of the DARPA
Internet Protocols• [CT90] Architectural Consideration for a New
Generation of Protocols