1) Character count: • This framing method uses a field in the header to specify the number of characters in the frame
Computer and Data Networks, 3 Date Link Layer Framing – Character count (b) Four examples of byte sequences before and after stuffing
Computer Communication Networks Lecture No 6 Computer Network Lectures 1- Data link Layer:- For example, if the character count of 5 in the second
24 jui 2021 · 1 Implementing the data link layer framing methods i Character count 2 Character Stuffing and destuffing 3 Bit Stuffing
When the data link layer at the destination sees the character count, it knows how many characters follow and hence where the end of the frame is This
To provide service to the network layer, the data link layer must use the service example, if the character count of 5 in the second frame of Fig
The trouble with this algorithm is that the count can be garbled by a transmission error For example, if the character count of 5 in the second frame of fig (b)
If ETX appears in the data introduce a special character DLE (Data No bit or byte stuffing ? Example: ? Synchronous Optical Network (SONET)
23 nov 2021 · Include the character count in the header of the frame Example: the byte-oriented Digital Data Communications
Character count with some other mechanisms 4 Physical Layer Coding Violation A Flag Byte or Byte Stuffing: Examples ® “To stop input please enter X and
43798_3123f09_Lec4.pdf
CSE 123CSE 123
Computer Networks
Computer Networks
Fall 2009
Fall 2009
Lecture 4:
Lecture 4:
DataData--Link I: Framin
g and ErrorsLink I: Framin g and Errors g g
Some portions courtesy
Robin Kravets and Steve Lumetta
Administrative updatesAdministrative updatesAdministrative updatesAdministrative updates I ' m out all next week - no lectures, but ... Im out all next week no lectures, but ...
You will have work
HW #1: will be posted by 10pm tonight, will be due HW #1: will be posted by 10pm tonight, will be due next Wed (Frank will collect) Project #1: will also be posted by 10pm tonight, will b d th M d ft t ( l t i t i b e d ue th e M on d ay a ft er nex t ( e l ec t ron i c t urn- i n before class) We ' re stuck with this room We re stuck with this room
Last timeLast timeLast time
...
Last time
...
How to send a signal from here to there
How to send a signal from here to there
Today: DataToday: Data
-- link layerlink layer
Today: DataToday: Data
-- link layerlink layer
Framing
Framing
Error detection/correction
Media Access
Media
Access
Bridging/Switching
FramingFramingFramingFraming
Goal: se
p arate bitstream into distinct units of transfer p (a frame) Why?
Synchronization recovery
Link multiplexing
Efficient error detection
Challenges
How can we determine exactly what set of bits constitute a frame?frame? How do we determine the beginning and end of a frame?
FramingFramingFramingFraming
App roaches pp
Sentinel (like C strings)
Length-based (like Pascal strings)Clock based
Clock based
Characteristics
Bit- or byte-oriented
Fixed or variable length
Data-dependent or data-independent length
SentinelSentinel
--
Based FramingBased Framing
SentinelSentinel
--
Based FramingBased Framing
Basic idea: identif
y start/end of frame with y special "marker"
Byte pattern, bit pattern, signal pattern
Challenge: what if marker is in data stream
Solution: "stuffing" recode data to prevent marker from occurringmarker from occurring
ByteByte
-- oriented Sentintelsoriented Sentintels
ByteByte
-- oriented Sentintelsoriented Sentintels
STX - start of textETX
df ETX - en d o f text Problem: what if ETX appears in the data portion of the frame?
Solution
If ETX appears in the data introduce a special character DLE (Data If ETX appears in the data , introduce a special character DLE (Data Link Escape) before it If DLE appears in the text, introduce another DLE character before it
Efficiency can be only 50%
Pt l l
P ro t oco l examp l es
BISYNC, PPP, DDCMP
ETX STX
ETXBODY
HEADER
0x48 0x69 ETX DLE 0x69 0x48 ETX 0x48 0x69 ETX DLE 0x69 0x48
ConsistentConsistent--Overhead Byte Overhead Byte Stuffing (COBS)Stuffing (COBS)Stuffing (COBS)Stuffing (COBS)
Run length encoding applied to byte stuffing
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 zerobytes followed by no zero
Worst case - no 0's in packet - 1/254 overhead
Appropriate for very low-bandwidth links
Code Followed by Meaning0x00
(not applicable) (not allowed) 0x00 (not applicable) (not allowed)
0x01No data bytes A single zero byten(n-1) data bytes Data followed by 00xFF
254 data bytes
Data, no following 0
0xFF 254
data bytes Data, no following 0
LengthLength
--
Based FramingBased Framing
LengthLength
--
Based FramingBased Framing
End of frame
Calculated from length sent at start of frame
Challenge: Corrupt length markers
Examples
DECNET's DDCMP:
»Byte-oriented, variable-length
RS-232 framing:
» Bit oriented implicit fixed length » Bit - oriented , implicit fixed - length
LENGTH
BODY
HEADER
ClockClock
--
Based FramingBased Framing
ClockClock
--
Based FramingBased Framing
Continuous stream of fixed-len
g th frames g
Clocks must remain synchronized
No bit or byte stuffing
Example:
Synchronous Optical Network (SONET)
Problems:
Frame synchronization
Clock synchronization
SONETSONETSONETSONET
All frames (STS formats) are 125 ȝsec long
Problem: how to recover frame synchronization
2-byte synchronization pattern starts each frame (unlikely in data)
Wait until pattern appears in same place repeatedly
Problem: how to maintain clock synchronization
NRZ encoding, data scrambled (XOR'd) with 127-bit pattern
Creates transitionsAl d h f fi di f l tt
Al so re d uces c h ance o f fi n di ng f a l se sync. pa tt ern .........
Overhead Payload
s .....................
9 rows
90 bytes
SONET MultiplexingSONET MultiplexingSONET MultiplexingSONET Multiplexing STS - 1 FH STS 1 FH
STS-1FH
STS-3FH
STS -
3 has the payloads of three STS
- 1 ' sbyte -
STS-1FH
STS - 3 has the payloads of three STS - 1s byte - wise interleaved.
For STS
-
N frame size is always 125 microsec
For STS N , frame size is always 125
microsec
STS-1 frame is 810 bytes
STS-3 frame is 810x3 =2430 b
y tes y
SONETSONETSONETSONET
STS-1 merged bytewise round-robin into STS-3
Unmerged (single-source) format called STS-3c
Problem: simultaneous synchronization of many distributed clocks not too difficult to synchronize clocks such that first b y te of y all incoming flows arrives just before sending first 3 bytes of outgoing flow
SONETSONETSONETSONET
... but now try to synchronize this network ' s clocks network s clocks Error DetectionError DetectionError DetectionError Detection
Goal: validate "correctness" of frame
Idea: send additional redundant data with frame to check if it has been damaged
Checked at many layers
Physical (e.g. modulation)
Datalink (e.g. cyclic redundancy check)
Network/Transport (e.g. IP Checksum)
Application (e.g. MD5 hash)
Today: simple parity, redundancy w/voting, 2
dimensional p arit y, IP checksum , CRCs py, , Error Detection from 10 000 feetError Detection from 10 000 feetError Detection from 10 ,
000 feetError Detection from 10
,
000 feet
• EDC= Error Detection bits (redundancy)• D = Data protected by error checking may include header fields • D = Data protected by error checking , may include header fields • Error detection not 100% reliable! • Protocol may miss some errors, but rarely •
Larger EDC field yields better detectionLarger
EDC field yields better detection
ParityParityParityParity
1-bit error detection with
p arit y py Add an extra bit to a code to ensure an even (odd) number of 1sEvery code word has an even (odd) number of 1s Every code word has an even (odd) number of 1s 011 111
01 1110
00Valid
code words 010
110100
000
Parity
Encoding:
White - invalid
() 101
001 ( error )
VotingVotingVotingVoting
1 - bit error correction with voting 1 bit error correction with voting
Every codeword is transmitted n times
011 111
010
110100
000 V oting:
White - correct to 1
Blue - correct to 0
0
1Valid
code words 101
001 Hamming DistanceHamming DistanceHamming DistanceHamming Distance
The Hamming distance between two code words is the minimum number of bit flips to move from one to the othernumber
of bit flips to move from one to the other
Example:
00101 and 00010
Hammin
g distance of 3 g The minimum Hamming distance of a code is the minimum distance over all pairs of codewords
Minimum Hamming Distance for parity 2
Minimum
Hamming
Distance
for parity = 2
Minimum Hamming Distance for voting = 3
N-bit error detection
No code word changed into another code word
Requires Minimum Hamming Distance of N+1
TwoTwo
--
Dimensional ParityDimensional Parity
TwoTwo
--
Dimensional ParityDimensional Parity
Use 1-dimensional parity
Add one bit to a 7-bit code to ensure an even/odd number of 1s
Parity
Bits even/odd number of 1s
Add 2nd dimension
Add an extra byte to frame
»Bits are set to ensure even/odd number of
101
010100111010011011110Data
1s in that position across all bytes in
frame
Comments
Catches all 1
- 2 - and 3 - bit and most 4 - bit 110
00011100110100
1011111
Catches
all 1 , 2 and 3 bit and most 4 bit errors 0
1111011
0Parity
Byte
1011111
Internet ChecksumInternet ChecksumInternet ChecksumInternet Checksum Idea
Add ll th d
Add up a ll th e wor d s
Transmit the sum
Internet Checksum
1 ' s complement of the 1 ' s complement sum on 16bit codewords 1s complement of the 1s complement sum on 16bit codewords
Example
»Message: e34f 2396 4427 99f3
»2s complement sum is 1e4ff»
1s complement sum is e4ff + 1 = e500
» 1s complement sum is e4ff + 1 = e500
»Checksum is 1aff
Comments
VERY easy to implement, fast incremental updates
Not very robust
IP ChecksumIP ChecksumIP ChecksumIP Checksum
u_short cksum(u_short *buf, int count) { register u _ long sum = 0; while (count--) { sum += *buf++; if (sum & 0xFFFF0000) {if (sum &
0xFFFF0000)
{ /* carry occurred, so wrap around */ sum &= 0xFFFF; sum++;} } return ~(sum & 0xFFFF); } Cyclic Redundancy Check Cyclic Redundancy Check (CRC)(CRC)(CRC)(CRC)
Polynomial code
Treat packet bits a coefficients of n-bit polynomial
»Message = 10011010
»Polynomial
=1 x 7 0 x 6 0 x 5 1 x 4 1 x 3 0 x 2 1 x 0 = 1 x 7 0 x 6 0 x 5 1 x 4 1 x 3 0 x 2 1 x 0 = x 7 x 4 x 3 x Choose r+1 bit generator polynomial (well known - chosen in advance) Add r bits to packet such that message is divisible by generator polynomial Note: easy way to think of polynomial arithmetic mod 2 »
Multiplication: binary addition without carries
»
Multiplication:
binary addition without carries
»Division: binary subtraction without carries
Better loss detection properties than checksums
Error Detection Error Detection
--
CRCCRC
Error Detection Error Detection
--
CRCCRC
View data bits, D, as a binary number
Choose r+1 bit pattern (generator)
G
Choose
r+1 bit pattern (generator) , G
Goal: choose r CRC bits, R, such that
exactly divisible by G (modulo 2) Receiver knows G divides by G If non
zero remainder: error Receiver
knows G , divides by G . If non - zero remainder: error detected! Can detect all burst errors less than r+1 bits
Widely used in practice (Ethernet FDDI ATM)
Widely
used in practice (Ethernet , FDDI , ATM) Common Generator PolynomialsCommon Generator PolynomialsCommon Generator PolynomialsCommon Generator Polynomials
CRC-8 x 8 x 2 x 1 1 CRC 10 x 10 x 9 x 5 x 4 x 1 1 CRC - 10 x 10 x 9 x 5 x 4 x 1 1 CRC-12
x 12 x 11 x 3 x 2 x 1 1 CRC-16
x 16 x 15 x 2 1 CRC-CCITT
x 16 x 12 x 5 1 CRC-32
x 32
x 26
x 23
x 22
x 16 x 12 x 11 x 10 x 8 x 7 x 5 x 4 x 2 x 1 1 CRC CRC
-- Example EncodingExample Encoding
CRC CRC
-- Example EncodingExample Encoding
x 3 x 2 1 = 1101 Generator
1101
1101
10011010000Message plus k
x 3 x 2 1 = 1101
Generator
x 7 x 4 x 3 x = 10011010 Message 1001
1101
10001101
k + 1 bit check sequence c, e q uivalent to a zeros Rlt 10111101
1100
1101
q degree-k polynomial R esu lt : Transmit message
followed by 1100
10001101
101
1101
Remainder
followed by remainder: 10011010101
101
m mod c 10011010101
CRC CRC
- - Example Decoding
Example Decoding
- - No Errors
No ErrorsNo ErrorsNo Errors
x 3 x 2 1 = 1101 Generator
1101
10011010101Received
x 3 x 2 1 = 1101
Generator
x 10 x 7 x 6 x 4 x 2 1 = 10011010101 Received Message
10011101
1000
1101
k + 1 bit check sequence c, equivalent to a message, no errors Rlt 1000
10111101
1100
1101
equivalent to a degree-k polynomial R esu lt : CRC test is passed
1100
11011101
1101
Remainder
0m mod c
CRC CRC
- - Example Decoding
Example Decoding
- - with Errors with Errorswith Errorswith Errors x 3 x 2 1 = 1101 Generator
1101
1101
10010110101Received
message x 3 x 2 1 = 1101
Generator
x 10 x 7 x 5 x 4 x 2 1 = 10010110101 Received Message
1000
1101
10111101
k + 1 bit check sequence c, e q uivalent to a message Rlt Two bit errors
11011101
q degree-k polynomial 0101
1101
R esu lt : CRC test failed
0101
Remainder
m mod c SummarySummarySummarySummary
Framin
gg Bunching bits into distinct messages (frames)
Challenge is in finding where one frame starts and another beginsbegins Error detection
Determine if frame is corrupted by checking it against redundant data N e xt tim e (o n e w ee k fr o m n e xt M o n day) : m o r e o n th e e e (o e ee o e o day) oeo e datalink layer Media accessRead26 27 28
Read 2 . 6 , 2 . 7 , 2 . 8