digital communication networks - mit.edumedard/6.02s/6.02sday1.pdf · layering topology design ......
TRANSCRIPT
Eytan ModianoSlide 1
Digital Communication Networks
MIT PROFESSIONAL INSTITUTE, 6.20sJuly 24 - 28, 2006
Professor Muriel Medard, MITProfessor Eytan Modiano, MIT
Eytan ModianoSlide 2
Digital Communication Networks
Introduction
Eytan Modiano
Eytan ModianoSlide 3
Course syllabus
• Monday– AM: Introduction to layering, the physical layer– PM: The data link layer
• Tuesday– AM: Delay models and queueing– PM: Higher layer protocols: TCP/IP, ATM
• Wednesday– AM: Routing– PM: More routing, flow control
• Thursday– AM: Multiple access– PM: LANs, MANs, SANs, and switching
• Friday– AM: Wireless Networks– PM: Optical Networks
Eytan ModianoSlide 4
Logistics
• Morning lectures: 9:00am - 12:00pm (break around 10:15)
• Lunch: on your own, 12:00 - 1:30pm
• Afternoon lecture: 1:30 - 4:30 (break around 2:45)
• Friday: start at 9:00 and end at 3:30pm (lunch: 11:45 - 12:30)
• Social: Dinner on Thursday evening
Eytan ModianoSlide 5
Reference textbooks
• Computer Networks, by Peterson and Davie– Most current on the internet
• Data Networks, by Bertsekas and Gallager– Strong on probabilistic modeling and analysis
• Network Optimization: Continuous and Discrete Models, by DimitriP. Bertsekas
– Network algorithms and routing, network flows, optimization theory
• Introduction to Probability, by Dimitri P. Bertsekas and John N.Tsitsiklis
Eytan ModianoSlide 6
Data Networks
• Fundamental aspects of network Design and Analysis:
– Architecture Layering Topology design
– Protocols Pt.-to-Pt. Multiple access End-to-end
– Algorithms Error recovery Routing Flow Control
– Analysis tools Probabilistic modeling Queueing Theory
Eytan ModianoSlide 7
Network Applications
• Resource sharing– Computing– Mainframe computer (old days)
Today, computers cheaper than comm (except LANS) Printers, peripherals
– Information DB access and updates
E.g., Financial, Airline reservations, etc.
• Services– Email, FTP, Telnet, Web access– Video conferencing– DB access– Client/server applications
Eytan ModianoSlide 8
Network coverage areas
• Wide Area Networks (WANS)– Span large areas (countries, continents, world)– Use leased phone lines (expensive!)
1980’s: 10 Kbps, 2000’s: 2.5 Gbps
User access rates: 56Kbps – 155 Mbps typical
– Shared comm links: switches and routers E.g, IBM SNA, X.25 networks, Internet
• Local Area Networks (LANS)– Span office or building– Single hop (shared channel) (cheap!)– User rates: 10 Mbps – 1 Gbps
E.g., Ethernet, Token rings, Apple-talk
• Metro Area networks (MANS)• Storage area networks
Eytan ModianoSlide 9
Network services
• Synchronous– Session appears as a continuous stream of traffic (e.g, voice)– Usually requires fixed and limited delays
• Asynchronous– Session appears as a sequence of messages
– Typically bursty– E.g., Interactive sessions, file transfers, email
• Connection oriented services– Long sustained session– Orderly and timely delivery of packets– E.g., Telnet, FTP
• Connectionless services– One time transaction (e.g., email)
• QoS
Eytan ModianoSlide 10
Switching Techniques
• Circuit Switching– Dedicated resources
• Packet Switching– Shared resources– Virtual Circuits– Datagrams
Eytan ModianoSlide 11
Circuit Switching
• Each session is allocated a fixed fraction of the capacity on eachlink along its path
– Dedicated resources– Fixed path– If capacity is used, calls are blocked
E.g., telephone network• Advantages of circuit switching
– Fixed delays– Guaranteed continuous delivery
• Disadvantages– Circuits are not used when session is idle– Inefficient for bursty traffic– Circuit switching usually done using a fixed rate stream (e.g., 64
Kbps) Difficult to support variable data rates
Eytan ModianoSlide 12
Problems with circuit switching
• Many data sessions are low duty factor (bursty), (message transmission time)/(message interarrival time) << 1 Same as: (message arrival rate) * (message transmission time) << 1
• The rate allocated to the session must be large enough to meet thedelay requirement. This allocated capacity is idle when the sessionhas nothing to send
• If communication is expensive, then circuit switching isuneconomic to meet the delay requirements of bursty traffic
• Also, circuit switching requires a call set-up during whichresources are not utilized. If messages are much shorter than thecall set-up time then circuit switching is not economical (or evenpractical)
– More of a problem in high-speed networks
Eytan ModianoSlide 13
Circuit Switching Example
L = message lengths λ = arrival rate of messagesR = channel rate in bits per secondX = message transmission delay = L/R
– R must be large enough to keep X small– Bursty traffic => λx << 1 => low utilization
• Example– L = 1000 bytes (8000 bits)– λ = 1 message per second– X < 0.1 seconds (delay requirement)– => R > 8000/0.1 = 80,000 bps
Utilization = 8000/80000 = 10%
• With packet switching channel can be shared among manysessions to achieve higher utilization
Eytan ModianoSlide 14
Packet Switched Networks
Packet NetworkPS
PS PS
PS
PSPS
PSBuffer Packet
Switch
Messages broken intoPackets that are routed To their destination
Eytan ModianoSlide 15
Packet Switching
• Datagram packet switching– Route chosen on packet-by-packet basis– Different packets may follow different routes– Packets may arrive out of order at the destination– E.g., IP (The Internet Protocol)
• Virtual Circuit packet switching– All packets associated with a session follow the same path– Route is chosen at start of session– Packets are labeled with a VC# designating the route– The VC number must be unique on a given link but can change from
link to link Imagine having to set up connections between 1000 nodes in a mesh Unique VC numbers imply 1 Million VC numbers that must be represented
and stored at each node– E.g., ATM (Asynchronous transfer mode)
Eytan ModianoSlide 16
Virtual Circuits Packet Switching
• For datagrams, addressing information must uniquely distinguisheach network node and session
– Need unique source and destination addresses
• For virtual circuits, only the virtual circuits on a link need bedistinguished by addressing
– Global address needed to set-up virtual circuit– Once established, local virtual circuit numbers can then be used to
represent the virtual circuits on a given link: VC number changes fromlink to link
• Merits of virtual circuits– Save on route computation
Need only be done onceat start of session
– Save on header size– Facilitate QoS provisioning– More complex– Less flexible
3
6
5 8
2
9
Node 5 table
(3,5) VC13 -> (5,8) VC3(3,5) VC7 -> (5,8) VC4(6,5) VC3 -> (5,8) VC7
VC3
VC13
VC7
VC4
VC3
VC7
Eytan ModianoSlide 17
Circuit vs packet switching
• Advantages of packet switching– Efficient for bursty data– Easy to provide bandwidth on demand with variable rates
• Disadvantages of packet switching– Variable delays– Difficult to provide QoS assurances (Best-effort service)– Packets can arrive out-of-order
Switching Technique Network service
Circuit switching => Synchronous (e.g., voice)Packet switching => Asynchronous (e.g., Data) Virtual circuits => Connection oriented Datagram => Connectionless
Eytan ModianoSlide 18
Circuit vs Packet Switching
• Can circuit switched network be used to support data traffic?
• Can packet switched network be used for connection orientedtraffic (e.g., voice)?
• Need for Quality of service (QoS) mechanisms in packet networks
– Guaranteed bandwidth– Guaranteed delays– Guaranteed delay variations– Packet loss rate– Etc...
Eytan ModianoSlide 19
7 Layer OSI Reference Model
Virtual link for
reliable packets
Application
Presentation
Session
Transport
Network
Data link
Control
Application
Presentation
Session
Transport
Network
Data link
Control
Network Network
DLC DLC DLC DLC
Physical link
Virtual bit pipe
Virtual link for end to end packets
Virtual link for end to end messages
Virtual session
Virtual network service
ExternalSite
subnetnode
subnetnode
Externalsite
physical
interfacephys. int. phys. int. phys. int. phys. int.physical
interface
Eytan ModianoSlide 20
Layers
• Presentation layer– Provides character code conversion, data encryption, data compression,
etc.
• Session layer– Obtains virtual end to end message service from transport layer
– Provides directory assistance, access rights, billing functions, etc.
• Standardization has not proceeded well here, since transport toapplication are all in the operating system and don't really needstandard interfaces
• Focus: Transport layer and lower
Eytan ModianoSlide 21
Transport Layer
• The network layer provides a virtual end to end packet pipe to thetransport layer.
• The transport layer provides a virtual end to end message serviceto the higher layers.
• The functions of the transport layer are:1) Break messages into packets and reassemble
packets of size suitable to network layer2) Multiplex sessions with same source/destination nodes3) Resequence packets at destination4) recover from residual errors and failures5) Provide end-to-end flow control
Eytan ModianoSlide 22
Network layer
• The network layer module accepts incoming packets from thetransport layer and transit packets from the DLC layer
• It routes each packet to the proper outgoing DLC or (at thedestination) to the transport layer
• Typically, the network layer adds its own header to the packetsreceived from the transport layer. This header provides theinformation needed for routing (e.g., destination address)
DLC layerlink 1
DLC layerlink 2
DLC layerlink 3
Networklayer
Transportlayer
Each node contains one networkLayer module plus one Link layer module per link
Eytan ModianoSlide 23
Link Layer
• Responsible for error-free transmission of packets across asingle link
– Framing Determine the start and end of packets
– Error detection Determine which packets contain transmission errors
– Error correction Retransmission schemes (Automatic Repeat Request (ARQ))
Eytan ModianoSlide 24
Physical Layer
• Responsible for transmission of bits over a link
• Propagation delays– Time it takes the signal to travel from the source to the destination
Signal travel approximately at the speed of light, C = 3x108 meters/second– E.g.,
LEO satellite: d = 1000 km => 3.3 ms prop. delay GEO satellite: d = 40,000 km => 1/8 sec prop. delay Ethernet cable: d = 1 km => 3 µs prop. delay
• Transmission errors– Signals experience power loss due to attenuation– Transmission is impaired by noise– Simple channel model: Binary Symmetric Channel
P = bit error probability Independent from bit to bit
– In reality channel errors are often bursty
0
1
0
1
1-P
1-P
P P
Eytan ModianoSlide 25
Internet Sub-layer
• A sublayer between the transport and network layers is requiredwhen various incompatible networks are joined together
• This sublayer is used at gateways between the different networks
• It looks like a transport layer to the networks being joined
• It is responsible for routing and flow control between networks, solooks like a network layer to the end-to-end transport layer
• In the internet this function is accomplished using theInternet Protocol (IP)
– Often IP is also used as the network layer protocol, hence only oneprotocol is needed
Eytan ModianoSlide 26
Internetworking with TCP/IP
FTP client
FTPserver
FTP Protocol
TCP TCP Protocol
IP IP Protocol IP Protocol
Ethernet Ethernet Protocol
token ring driver
token ringProtocol
Ethernet
driver
TCP
IPROUTER
IP
Ethernetdriver
token ring driver
token ring
Eytan ModianoSlide 27
Encapsulation
Ethernet
Ethernet
Application
user data
Appluser dataheader
TCPheader application data
headerIP TCP
header application data
IP datagram
TCPheader application dataheader
IPEthernetheader
Ethernettrailer
Ethernet frame
46 to 1500 bytes
14 420 20
driver
IP
TCP
TCP segment
MIT
Physical Layer and Coding
Muriel MédardEECSLIDS
MIT
Overview
• A variety of physical media: copper, free space, optical fiber• Unified way of addressing signals at the input and the output
of these media:– basic models– Nyquist sampling theorem
• How we use the channels: modulation• Modeling the net effect of channels: transition probabilities
and errors• Making up for channel errors:
– principles of coding– theoretical limits
MIT
Signals
• Channel has a physical signal traversing a physical medium• Electromagnetic signal• Polarization of the wave
TM TE
Propagation of the wave
MIT
Signals
• What do we mean by frequency?• We can express a signal by a superposition of sinusoids, each
of them with its own frequency• A continuous signal is bandlimited to a bandwidth W at
carrier frequency f0 if it can be expressed in terms ofsinusoids in a range of frequencies of width W around afrequency f0
• If we multiply the signal by a frequency shift, then weoperate around 0, the baseband representation
f0 f0 +W/2 f0 -W/2 0 W/2 -W/2
passband baseband
MIT
Nyquist sampling theorem
• We can wholly reconstruct a signal from its periodic samples aslong as those samples are within 1/W of each other
• Continuous signal x(t), discrete time signal is x[n] = x(n T)where T = 1/W
t
x(t)
0 T 2T 3T 4T 5T 6T
MIT
Modulation: creating signals
• How we generate signals, by varying amplitude, phase, frequency• On-off keyed (OOK): send 1, 0, a special case of amplitude
modulation
• Frequency-shift keyed (FSK), change frequencies:
• Phase-shift key (PSK):2 PSK 4 PSK
MIT
Modulation
• Pulse position modulation (PPM)
• Combining phase and amplitude, for instance:
0 +1 +2
+2
+1
-1
-2
-2 -1
PAM 5x5 symbol code for 100BASE-T2 PHY
MIT
Channels
• Canonical channel model: signal goes into channel, there is anon-additive effect and addition of noise
• Very commonly, G is a multiplicative effect:• Y[n] = g X[n] + N[n]• Y[n] = g-1 X[n-1] + g0 X[n] + N[n]
INTERSYMBOL-INTERFERENCE (ISI)
GTxX[n]
Rx
N[n]
G(X[n]) Y[n]
MIT
Effect of the channel
• If we put in a certain string of input signals X[1], X[2], …,then we have a certain probability of having a certain outputstring Y[1], Y[2], …
• The net effect is what is the probability of having a certainoutput when a given input is given
MIT
Channel model
• The channel is described by an input alphabet, an outputalphabet, a set of probabilities on the input alphabet and a setof channel transitions, for a memoryless channel (on every bitthe channel behaves independently of other times):
• Channel with input alphabet of size k+1 and output alphabetof size m+1
• p(y | x) is transition probability, probability of getting outputy for input x
0
k m
0Tx Rx
... ...
MIT
How do we determine the probabilities?
• We want to get to p(x | y)• Use Bayes’s rule: p(x | y) = p( x, y) / p(y)• Also p(x, y) = p(y | x) p(x)• p(y) = p(y | xi) p(xi)• For the case where all the inputs have the same probability,
then p(x | y) = 1/n p(y | x) / p (y | xi)• How can we try to make up for the effect of the channel?
i!
i!
MIT
When do we use codes
• Two different types of codes:– source codes: compression– channel codes: error-correction– Source-channel separation theorem says the two can be
done independently for a large family of channels
Sour
ceen
code
r
Channelencoder
Channel decoder
stream
Modulator, channel, receiver, etc...
Sour
cede
code
rs x y
MIT
What is a reasonable way to construct codes?
• Suppose that errors occur independently from symbol tosymbol: a reasonable way to code is to make codewords asdissimilar as possible
• Number of bits in red: Hamming distance
• If we received y = 01000101001111, we would map to thefirst codeword - we’ll make this more precise later
x1 = 01000101001110
x2 = 01001100000111
MIT
What do we mean by constructing a code?
• Block code: map a block of bits to another, generally larger,block of bits
• (n, k) linear block code encodes k-bit message into n-bit codevector, rate of code is R = n/k
• In general, code maps a message from set M= 2k onto acodeword of length n
• Every codeword is one-to-one correspondence with amessage
• An error occurs in decoding if we map a received codewordto the wrong message or to more than one message
MIT
What do we mean by decoding?
• We choose most likely input to have yielded observed output- Maximum Likelihood Decoding
• Given that we observe the output vector y, the probabilitythat x1 was transmitted is p(x1 | y) and the probability that x2was transmitted is p(x2 | y) (let’s look at 2 codewords)
• Then we pick x1 when p(x1 | y) / p(x2 | y) > 1 or equivalentlywhen ln(p(x1 | y) ) - ln(p(x1 | y) ) > 0 in terms of loglikelihoods
MIT
Decoding example
• Consider the binary symmetric channel (BSC)
• The probabilities are:– p(x1| y) = (1-p)13 p 13 no errors and 1 error– p(x1| y) = (1-p)11 p3 11 no errors and 3 errors
• The BER is p
0
1 1
0Tx Rx1-p
1-p
p
p
MIT
Hamming distance and code capability
• Minimum Hamming Distance dmin of a code is the minimumHamming Distance between any two codewords
• A code can detect up to t errors iff dmin t + 1• A code can correct up to t errors iff dmin 2t + 1• A code can correct up to t errors and detect up to t’ > t errors iff
dmin 2t + 1 and dmin t + t’ + 1• How does dmin relate to r = n-k, the number of redundant bits?• Singleton bound: r + 1 dmin
• Example take strings of k bits and add a parity check code: r is 1and dmin is 2
• These are bounds, most codes don’t achieve these bounds
!
!
! !
!
MIT
Linear codes: how do we build them?
• Code word x = s G where for (n,k) code G is a matrix with krows and n columns
• Linear code because sums of codewords are codewords• How can we find dmin ? The Hamming distance between two
binary codewords is the same as the Hamming weight of theirsum
• Thus, the minimum Hamming distance is the minimumweight of non-zero code vectors
MIT
Syndromes and parity-check
• For any code, it is always possible to find a systematic code,i.e. a code for which G = [I k x k P k x r ]by manipulating therows using linear operations
• We define the parity-check matrix H to be:
• We have x H = 0• Syndrome s = y H• Define error sequence e = y + x• Then s = e H• Decoding is done by finding the minimum Hamming weight
sequence that satisfies s = e H and decoding to the codewordy + z
I-
P
kk x
kr x
!"
#$%
&
MIT
Let’s think in 3-D
• Hamming distance between codes is related to t, the numberof errors to correct in a (n, k) linear block code
• Example: rate (3,1) repetition code: can correct at most 1error and detect 2 errors
000
111
100
010110
010
011
MIT
Further bounds
• Hamming bound: r
• Gilbert bound: there exists a code such that:
MIT
Cyclic Codes
• Cyclic codes are codes with cyclic shift property in code words:if (a, b, c, d, e) is a codeword, so is (b, c, d, e, a)
• A generator matrix is then
• Can we make use of the regular structure of this matrix to simplifythings?
MIT
Polynomials on fields
• Galois field: a field with a finite number of elements• We can define a polynomial over a finite field (Galois Field)
GF(q) as f(D) = fn Dn + fn-1 Dn-1 + … + f0
• D is not a variable in the field, it is an indeterminate - think of theD-transform or the Z-transform
• For polynomials, addition and multiplication can be defined, theyare commutative, associative, closure holds, an addition inverse isdefined BUT NO MULTIPLICATIVE INVERSE
• Instead, we have the following theorem: let f(D) and g(D) bepolynomials over GF(q) and let g(D) have degree at least 1. Thenthere exist unique polynomials h(D) and r(D) over GF(q) for whichthe degree of r(D) is less than that of g(D) and
f(D) = g(D) h(D) + r(D) (Euclidean division algorithm)
MIT
Relation between polynomials and cyclic codes
• Represent a vector x = (xn-1 … x0 ) as x(D) = xn-1 Dn-1 + … + x0
• We say that x(D) is a codeword when the coefficients for theletters of a codeword
• If we have a cyclic code, then it is the case that the remainder ofdividing D x(D) by Dn - 1 ( also called the remainder of D x(D)modulo Dn - 1 ) is also a code word
• To see this: Dx(D) = xn-1 Dn + … + x0 D = xn-1(Dn - 1) + … + x0 D + xn-1
• Define g(D) to be the lowest degree monic polynomial which is acode word in a cyclic code define m to be its degree
• Because of linearity, any Dj g(D) is also a codeword, so in generala(D) g(D) is a codeword
• Moreover all code words have this form
MIT
Implementing systematic cyclic codes
• In polynomial form, a systematic binary code is of the form:x(D) = Dr t(D) - d(D) = Dr t(D) + d(D)
• The check bits are d(D) and d(D) has degree less than r• Let’s take d(D) to be the remainder of Dr t(D) / g(D)• What about the syndrome?• s(D) = x(D) / g(D) = Dr t(D) / g(D) + d(D) / g(D) = 2 d(D) = 0• For some q(D), we have g(D) q(D) + d(D) = Dr t(D)• So g(D) q(D) = Dr t(D) - d(D) = Dr t(D) + d(D) which is our
codeword x(D)
MIT
Implementing cyclic codes
Divide by g(D) circuit
+.... . .
g0 g1 gr-1
s1+
s2 ... +sr-1
Dr s(D)
Dr s(D)
+
Divide by g(D)
...
Encoder
Circuits are easily implementedusing shift registers to represent polynomials in D
MIT
Decoding
• Brute force: divide y(D) by g(D), from there get syndrome, checksyndrome against syndrome table, generate n-bit error pattern, thenadd to y(D) to obtain corrected word
• However, we know that we can only correct a number t of errors• Let’s define the Meggitt set to be the set of error patterns such that
en-1 = 1• Use Meggitt’s theorem: suppose that g(D) h(D) = Dn - 1 and
e(D) / g(D) = s(D) then[Db e(D) mod (Dn - 1)]/g(D) = [Db s(D)]/g(D)
• So only need to store syndromes for error patterns in the Meggittset
MIT
Different types of codes: Hamming codes
• Hamming codes are some of the few “perfect” codes• Sphere of radius v: set of all sequences at distances v or less from a
sequence• A v-error-correcting sphere-packed code has the property that the
spheres of size v around the code are non-overlapping and thatevery sequence is at most v+1 in distance from some code word
• A v-error-correcting sphere-packed code for which every sequenceis at most v+1 in distance from some code word is perfect
• Hamming codes: rows of H are all the different nonzero sequencesof length n-k
• Thus n = 2 n-k -1• For all Hamming codes, the minimum Hamming distance is 3, so
they can correct 1 error or detect 2• The rate of a Hamming code is R = (2 r - r -1 )/(2 r -1 )
MIT
Cyclic Redundancy Check Codes (CRCs)
• Normally look only to see whether the syndrome is 0 or not,which is why they are error-detecting
• This is not a function of the CRC code, it’s more of the wayit’s decoded
• Usually used in a concatenated fashion with an errorcorrecting code
• g(D) = (x+1) p(D) where p(D) is a primitive polynomial,which means that it divides D2r-1-1 -1but no lower orderpolynomial of the form Dv -1
• Length n = 2 r-1 - 1• Usually used in shortened mode: for a systematic code, stuff
with 0s and those 0s need not be transmitted but must betaken into account at the decoding
MIT
Convolutional codes
• Rather than map a block to a block, we code continuously• Tend to be used in lower BER channels• We can define the code as a set of states: for M memory
elements in the encoder, there are 2 M states• The trellis structure is as follows, say M=2
11
0100
10t t + 1
Trellis
Decoding•We use a time between known states•Possible ways of getting from one state to another are called the adversary paths•Viterbi algorithm is a means of applying dynamic programming to path selection
MIT
Beyond codes based on distance
• What is the best performance we can get with a coded system?• Let us consider a channel with bandwidth W, with noise energy N
per Hz, and with a maximum E on the mean transmitted• Shannon’s limit is that if we have no delay constraint and no
complexity constrain on the coder and decoder, the best achievableerror-free rate (capacity) is given by
Bits per second
• A modulation to achieve this limit is a one that itself looks likenoise and the codes are random
MIT
• Recall the BSC
• Capacity is: I(X; Y) = H(Y) - H(Y|X)• H is entropy H(Z) = - Σ pZ(z) log(pZ(z) )• Let’s work it out ...
0
1 1
0X Y1-p
1-p
p
p
MIT
Random codes
• The codes are random in that the codewords are selected atrandom from a large number of codewords
• The coding theorem gives results based on the fact that anerror is unlikely because the for long enough codewords, twocodewords are unlikely to be the close enough to be confused
• Codes have emerged which work on that principle• Examples: Turbo Codes and Low Density Parity Check
Codes
Eytan ModianoSlide 1
Data Link Layer (DLC)
• Responsible for reliable transmission of packets over a link
– Framing: Determine the start and end of packets
– Error Detection: Determine when a packet contains errors
– Error recovery: Retransmission of packets containing errors DLC layer recovery
May be done at higher layer
Eytan ModianoSlide 2
Framing
_____________________________________ 010100111010100100101010100111000100
Where is the DATA??
• Three approaches to find frame and idle fill boundaries:
1) Character oriented framing
2) Length counts- fixed length
3) Bit oriented protocols (flags)
Eytan ModianoSlide 3
Character Based Framing
• Standard character codes such as ASCII and EBCDIC containspecial communication characters that cannot appear in data
• Entire transmission is based on a character code
Frame
SYN SYN STX Header Packet ETX CRC SYN SYN
SYN is synchronous idleSTX is start textETX is end text
Eytan ModianoSlide 4
Issues With Character Based Framing
• Character code dependent
– How do you send binary data?
• Frames must be integer number of characters
• Errors in control characters are messy
NOTE: Primary Framing method from 1960 to ~1975
Eytan ModianoSlide 5
Length field approach (DECNET)
• Use a header field to give the length of the frame (in bits or bytes)– Receiver can count until the end of the frame to find the start of the next
frame– Receiver looks at the respective length field in the next packet header to
find that packet’s length
• Length field must be log2 (Max_Size_Packet) + 1 bits long– This restricts the packet size to be used
• Issues with length counts– Difficult to recover from errors– Resynchronization is needed after an error in the length count
Eytan ModianoSlide 6
Fixed Length Packets (e.g., ATM)
• All packets are of the same size– In ATM networks all packets are 53 Bytes
• Requires synchronization upon initialization
• Issues:– Message lengths are not multiples of packet size
Last packet of a message must contain idle fill (efficiency)
– Synchronization issues
– Fragmentation and re-assembly is complicated at high rates
Eytan ModianoSlide 7
Bit Oriented Framing (Flags)
• A flag is some fixed string of bits to indicate the start and end of a packet– A single flag can be used to indicate both the start and the end of a packet
• In principle, any string could be used, but appearance of flag must beprevented somehow in data– Standard protocols use the 8-bit string 01111110 as a flag– Use 01111111..1110 (<16 bits) as abort under error conditions– Constant flags or 1's is considered an idle state
• Thus 0111111 is the actual bit string that must not appear in data
• INVENTED ~ 1970 by IBM for SDLC (synchronous data link protocol)
Eytan ModianoSlide 8
BIT STUFFING (Transmitter)
• Used to remove flag from original data
• A 0 is stuffed after each consecutive five 1's in the original frame
• Why is it necessary to stuff a 0 in 0111110?
1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 00 0 0 0
Stuffed bits
Original frame
Eytan ModianoSlide 9
DESTUFFING (Receiver)
• If 0 is preceded by 011111 in bit stream, remove it
• If 0 is preceded by 0111111, it is the final bit of the flag.
Example: Bits to be removed are underlined below
1001111101100111011111011001111110flag
Eytan ModianoSlide 10
Overhead
• In general with a flag 01K0 the bit stuffing is require whenever 01k-1
appears in the original data stream• For a packet of length L this will happen about L/2k times
E{OH} = L/ 2k + (k+ 2) bits
• For 8 bit flag OH ~ 8 + L/64– For large packets efficiency ~ 1 - 1/64 = 98.5 (or 1.5% overhead)
• Optimal flag length– If packets are long want longer flag (less stuffing)– If packets are short want short flag (reduce overhead due to flag)
Kopt ~ log2(L)
Eytan ModianoSlide 11
Framing Errors
• All framing techniques are sensitive to errors
– An error in a length count field causes the frame to be terminated at thewrong point (and makes it tricky to find the beginning of the next frame)
– An error in DLE, STX, or ETX causes the same problems
– An error in a flag, or a flag created by an error causes a frame to disappearor an extra frame to appear
• Flag approach is least sensitive to errors because a flag will eventuallyappear again to indicate the end of a next packet
– Only thing that happens is that an erroneous packet was created– This erroneous packet can be removed through an error detection
technique
Eytan ModianoSlide 12
Error detection techniques
• Used by the receiver to determine if a packet contains errors• If a packet is found to contain errors the receiver requests the
transmitter to re-send the packet
• Error detection techniques
– Parity check single bit Horizontal and vertical redundancy check
– Cyclic redundancy check (CRC)
Eytan ModianoSlide 13
Effectiveness of error detection technique
• Effectiveness of a code for error detection is usually measured by threeparameters:
1) minimum distance of code (d) (min # bit errors undetected)The minimum distance of a code is the smallest number of errors that can mapone codeword onto another. If fewer than d errors occur they will alwaysdetected. Even more than d errors will often be detected (but not always!)
2) burst detecting ability (B) (max burst length always detected)
3) probability of random bit pattern mistaken as error free (goodestimate if # errors in a frame >> d or B)
– Useful when framing is lost
– K info bits => 2k valid codewords
– With r check bits the probability that a random string of length k+rmaps onto one of the 2k valid codewords is 2k/2k+r = 2-r
Eytan ModianoSlide 14
Parity check codes
• Each parity check is a modulo 2 sum of some of the data bits
Example:
c1 = x1 + x2 + x3c2 = x2 + x3 + x4c3 = x1 + x2 + x4
k Data bits r Check bits
Eytan ModianoSlide 15
Single Parity Check Code
• The check bit is 1 if frame contains odd number of 1's; otherwise it is 0
1011011 -> 1011011 11100110 -> 1100110 0
• Thus, encoded frame contains even number of 1's• Receiver counts number of ones in frame
– An even number of 1’s is interpreted as no errors– An odd number of 1’s means that an error must have occured
A single error (or an odd number of errors) can be detected An even number of errors cannot be detected Nothing can be corrected
• Probability of undetected error (independent errors)
P(undet ected ) =N
i
!
" #
$
% &
i even
' pi(1 ( p)N (i
N = packet size p = error prob.
Eytan ModianoSlide 16
Horizontal and Vertical Parity
• The data is viewed as a rectangular array (i.e., a sequence of words)
• Minimum distance=4, any 4 errors in a rectangular configuration isundetectable
• Can you find an example of a pattern of 6 errors that cannot bedetected?
1 0 0 1 0 1 0 1
0 1 1 1 0 1 0 0
1 1 1 0 0 0 1 0
1 0 0 0 1 1 1 0
0 0 1 1 0 0 1 1
1 0 1 1 1 1 1 0
1 0 0 1 0 1 0 1
0 1 1 1 0 1 0 0
1 1 1 0 0 0 1 0
1 0 0 0 1 1 1 0
0 0 1 1 0 0 1 1
1 0 1 1 1 1 1 0
Vertical checks
Horizontal
checks
Eytan ModianoSlide 17
Cyclic Redundancy Checks (CRC)
• A CRC is implemented using a feedback shift register
Bits in Bits out
k Data bits r Check bitsM = info bitsR = check bitsT = codeword
M R
T
T = M 2r + R
Eytan ModianoSlide 18
Cyclic redundancy checks
• How do we compute R (the check bits)?– Choose a generator string G of length r+1 bits– Choose R such that T is a multiple of G (T = A*G, for some A)– Now when T is divided by G there will be no remainder => no errors– All done using mod 2 arithmetic
T = M 2r + R = A*G => M 2r = A*G + R (mod 2 arithmetic)
Let R = remainder of M 2r/G and T will be a multiple of G
• Choice of G is a critical parameter for the performance of a CRC
T = M 2r + R
Eytan ModianoSlide 19
Example
r = 3, G = 1001M = 110101 => M2r = 110101000
110101000100110010100010010001100
1001010101001011 = R (3 bits)
110011
Modulo 2Division
Eytan ModianoSlide 20
Checking for errors
• Let T’ be the received sequence• Divide T’ by G
– If remainder = 0 assume no errors– If remainder is non zero errors must have occurred
Example: Send T = 110101011 Receive T’ = 110101011 (no errors)
110101011100110010100010010001101
100101001
1001000 => No errors
No way of knowing how manyerrors occurred or which bits areIn error
Eytan ModianoSlide 21
Performance of CRC
• For r check bits per frame and a frame length less than 2r-1, thefollowing can be detected
1) All patterns of 1,2, or 3 errors (d > 3)2) All bursts of errors of r or fewer bits3) Random large numbers of errors with prob. 1-2-r
• Standard DLC's use a CRC with r=16 with option of r=32
– CRC-16, G = X16 + X15 + X2 +1 = 11000000000000101
Eytan ModianoSlide 22
Physical Layer Error Characteristics
• Most Physical Layers ( communications channels) are not welldescribed by a simple BER parameter
• Most physical error processes tend to create a mix of random & burstsof errors
• A channel with a BER of 10-7 and a average burst size of1000 bits is very different from one with independent random errors
• Example: For an average frame length of 104 bits– random channel: E[Frame error rate] ~ 10-3
– burst channel: E[Frame error rate] ~ 10-6
• Best to characterize a channel by its Frame Error Rate
• This is a difficult problem for real systems