Data Communication Networks: Saad Mneimneh Computer Science Hunter College of CUNY New York
Data Communication Networks: Saad Mneimneh Computer Science Hunter College of CUNY New York
Lecture 2
Saad Mneimneh
Computer Science
Hunter College of CUNY
New York
DLC . . . . . . . . . . . . . . . . . . . . . .
Framing . . . . . . . . . . . . . . . . . . . .
Character based framing . . . . . . . . .
Character based framing (cont.) . . . .
Length field . . . . . . . . . . . . . . . . .
Maximum frame size . . . . . . . . . . .
Maximum frame size (cont.) . . . . . .
Fixed length packets/frames . . . . . .
Bit oriented framing . . . . . . . . . . . .
Bit stuffing . . . . . . . . . . . . . . . . . .
Overhead of bit stuffing . . . . . . . . .
Overhead of bit stuffing (cont.) . . . .
Can we do better? . . . . . . . . . . . . .
Error detection . . . . . . . . . . . . . . .
How to detect errors? . . . . . . . . . . .
Single parity check . . . . . . . . . . . . .
Horizontal and vertical parity checks .
Horizontal and vertical parity checks .
Horizontal and vertical parity checks .
Arbitrary parity check codes . . . . . .
Effectiveness of a code . . . . . . . . . .
Effectiveness of a code (cont.) . . . . .
Cyclic Redundancy Check . . . . . . . .
Obtaining c(x) . . . . . . . . . . . . . . .
Another example . . . . . . . . . . . . . .
Using bits only . . . . . . . . . . . . . . .
Using bits only (cont.) . . . . . . . . . .
Using bits only (cont.) . . . . . . . . . .
Feedback shift register . . . . . . . . . .
How does c(x) help? . . . . . . . . . . .
Undetected errors . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
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.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
DLC
We are not going to study the physical layer and how communication signals are sent and received
We will assume that we are capable of sending bits over a link
DLC is responsible for reliable transmission of packets over a link
Framing
Recall that DLC adds its own header and trailer to the packet frame
header
packet
trailer
frame
in some cases, there is a period of idle fills between successive frames (e.g. synchronous bit
pipe)
it is also necessary to separate idle fills from frames
even when idle fill are replaces by dead periods (intermittent bit pipe), problem is not
simplified, e.g. often no dead periods
. . . 01011010110010110101101110101110 . . .
SYN: a string of SYN characters provide idle fill between frames when a sending DLC has no data to
send (but a synchronous modem requires bits)
STX: start of text
ETX: end of text
frame
SYN
SYN
STX
header
packet
ETX
CRC
SYN
SYN
A special control character DLE (Data Link Escape) is inserted before any intentional use of
communication control characters
e.g. DLE is not inserted before the possible appearance these characters as part of the binary
data
e.g. DLE ETX (but not DLE DLE ETX): end of frame
e.g. DLE DLE ETX (but not DLE DLE DLE ETX): DLE ETX in data
frame
SYN
SYN
DLE
STX
header
packet
DLE
ETX
CRC
SYN
SYN
Length field
The basic problem is to inform the receiving DLC where each idle fill ends and where each frame
ends
Idle fill
|||||
packet
CRC
Idle fill
header
packet
CRC
header
Once synchronized, DLC can always tell where next frame starts
Length field restricts packet size
length field must be blog 2 M axF rameSizec + 1 bits (thats the overhead)
Let Kmax be the maximum packet size. Assume V overhead bits. Let M be the message length.
Then we have
M
M +d
eV
Kmax
bits to send
Kmax
Kmax
Therefore,
Kmax
Rest V
sender
M
(Kmax + V )(j 1) M + d Kmax eV
+
+P +Q
c
c
E[M ]V
j1
E[M ]
V
Kmax
In bit oriented framing, a special binary flag indicates the end of frame
avoided within frame using a technique called bit stuffing
The difference is that a flag can be of any length (later we see how to set length to minimize overhead)
Standard protocols use 01111110, we denote it by 01 6 0
The same flag can be used to indicate start of frame
01111110 . . . . . . . . . . . . . . . . . . 01111110
Standard DLCs have also an abort capability in which a frame can be aborted by sending 7 or more
consecutive 1s (15 consecutive 1s link is idle)
Therefore, 0111111, i.e. 016 is the actual bit string that must be avoided in data
Bit stuffing
Sender DLC
Receiver DLC
0
0
0
0
1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0
Which ones of these stuffed bits can be avoided (provided receivers rule for deleting stuffed bits is
changed accordingly)?
Overhead
of overhead
bit stuffing
What is the
of bit stuffing (assume flag = 01j 0)?
if j % less stuffing but longer flag
if j & more stuffing but shorter flag
For the sake of analysis, assume a random string of bits with p(0) = p(1) = 1/2
insertion after ith bit occurs with probability (1/2)j
01
. . 1}
| .{z
j1
j1
since (1/2)2j1 << (1/2)j , we can ignore such event and events of insertion dur to yet longer strings
of 1s
The probability of stuffing after the ith bit is approximately 2j , which is also E[stuf f ed @ i]
By linearity of expectation, E[stuf f ed|K] K2j (be careful at boundary), where K is the length of the
frame
Overhead
of bit
stuffing (cont.)
From previous
slide
f lag
j+1
E[k]2(j+1) < 1
Can we do better?
Length field based framing and bit oriented framing are comparable in their overhead
log 2 K
KX
max
p(k) log 2
k=1
1
Kmax ,
1
p(k)
H = log2 Kmax .
Error detection
Flag approach is least sensitive to errors because a flag will eventually appear
Assume that DLC knows where frames begin and end (solved earlier)
Determine which frames contain errors
Parity check
single parity
multiple parity (e.g. horizontal and vertical)
e.g. 1001010 1
e.g. 0111010 0
0
1
1
0
0
0
1
1
0
1
1
1
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
1
1
1
0
1
1
0
0
0
0
1
1
0
1
1
1
1
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
1
0
0
1
1
1
1
1
0
0
0
1
0
horizontal checks
vertical checks
0
1
1
0
0
0
0
1
1
0
1
1
1
1
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
1
0
0
1
1
1
1
1
0
0
0
1
0
horizontal checks
vertical checks
ci =
K
X
ij sj
j=1
where
s1 is
0
0
0
0
1
1
1
1
an
s2 L
s3K
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0-1
c1
0
1
0
1
1
0
1
0
matrix
c2 c3
0
0
1
0
1
1
0
1
1
1
0
1
0
0
1
0
c4
0
1
1
0
0
1
1
0
c1
c2
c3
c4
= s1 + s3
= s1 + s2 + s3
= s1 + s2
= s2 + s3
1
1
=
1
0
0
1
1
1
1
1
0
1
Effectiveness of a code
K
|
L
{z
codeword
minimum distance of the code d: the smallest number of errors that can convert one code word
into another
burst detecting capability
useful when framing is lost, e.g. check code is random with respect to received frame
We have 2K codewords (why?) and 2K+L random strings
therefore, the probability is 2L
Minimum distance d
single parity:
single parity:
Why this polynomial representation? because we are going to obtain c as c(x) by dividing s(x)x L by some
polynomial g(x)
Obtaining c(x)
s(x) =?
s(x)xL =?
divide s(x)xL by g(x) and obtain remainder (ill do it on the board?)
Another example
s = 110101
g(x) = x3 + 1
s(x) = x5 + x4 + x2 + 1
s(x)xL = x8 + x7 + x5 + x3
x8 + x 7 + x 5 + x 3
x8 + x 5
x7 + x 3
x7 + x 4
x4 + x 3
x4 + x
x3 + x
x3 + 1
x+1
x3 + 1
x5 +x4 +x+1
x3
x2
x1
x0
L
s(x)xL
x8
x7
x6
x5
x4
x3
x2
}|
x1
x0
1 0 0 1
1 0 0 1
1 1 0 0 1 1
1 0 0 0
1 0 0 1
0 0 1 1
0 0 0 0
0 1 1 0
0 0 0 0
1 1 0 0
1 0 0 1
1 0 1 0
1 0 0 1
0 1 1
1 0 0 1
1 0 0 1
1 1 0 0 1 1
1 0 0 0
1 0 0 1
0 0 1 1
0 0 0 0
0 1 1 0
0 0 0 0
1 1 0 0
1 0 0 1
1 0 1 0
1 0 0 1
0 1 1
g0
g1
g2
gL-2
gL-1
s0 sK-L-1
sK-L
sK-L+1
sK-2
{z
0
sK-1
Undetected errors
Assume error is e(x), i.e. y(x) = f (x) + e(x)
f (x)
e(x)
Then, y(x)
g(x) = g(x) + g(x)
Therefore, we have undetected errors iff e(x) 6= 0 divisible by g(x)
Single errors are always detected