Data Link Layer

Data link layer algorithms
may be embedded in the network hardware
(rather than running as software process on a machine).

In general,
computer algorithms don't have
to be run as software on general-purpose machines.
You can design dedicated hardware to run them.
Often done to increase speed
for fundamental algorithms run constantly.
Or some combination of dedicated hardware
plus limited-programmable.

What does data link layer have to do?

Assume a single link from A to B.
Assume service provided by physical layer
is that it will
deliver bits to B in the order in which they are sent.

So what does data link layer have to do?

Error checking - all circuits have errors occasionally.

Flow regulation
- Line has finite data rate, and machines have finite rate at which
they can process incoming.
Regulate flow so that slow receivers are not swamped by fast senders.

As a packet travels across the Internet from A to B,
it may go along multiple types of links (phone, fiber, wireless),
each with different frame sizes and formats.
Packet may be encoded in a different way for each link
it travels on.

Small packet: Goes in 1 frame.

Larger packet (quite normal):
Multiple frames per packet.
Packet has to be broken up, sent as multiple frames, re-assembled.

Do error checking in what layer?

High error rate (e.g. wireless): Do error-checking in data link layer,
on every single frame.

Example

Imagine average 10 frames per packet.

high error rate:
Imagine average 20 percent of frames are lost.

Error-check in higher layer:
Packet-by-packet checking.
Send packet. If didn't get through, higher layer
sends entire packet again.
Average packet will lose 2 frames.
Will take a while on average to get clear run of 10 frames in a row
without error.
prob. of frame getting through = 0.8.
If send frame 100 times, 80 will get through, 20 will fail.
prob. of 10 in a row ok = (0.8)10 = 0.1 approx.If send packet 100 times, only 10 will get through, 90 will fail.

Error-check in data link layer is best:
Frame-by-frame checking.
Packets will get through much faster.

low error rate:

Error-check in higher layer is best:
Packets will get through quicker if there
is no frame checking, and complete re-send of the (very rare)
bad packet.

Error-check in data link layer:
Frame-by-frame checking is obviously more costly.
So don't use it unless the error rate is high enough
to make it worthwhile.

e.g.
Imagine average 0.1 percent of frames are lost.
1 in 1000 frames lost.
prob. of frame getting through = 0.999
prob. of 10 in a row ok = (0.999)10 = 0.99 approx.
If do packet-level error checking,
approx
1 in 100 packets lost and has to be re-sent

3.2 Error detection / correction

Error:

Error rates:

Errors may come in isolated single bits
or in bursts (lots of bits in a row lost).
Radio has a lot of burst errors.
Technically, a burst error
doesn't mean every single bit in the burst is precisely flipped.
Burst errors look more like this
(dash "-" means data got through ok, B means bit was flipped):

Inside burst, signal may be distorted but (by chance) the bit
comes out reading the same.
Technically, a burst error
means first and last bits flipped,
not necessarily all ones in between.

Burst errors:

Advantage - Might get few bad blocks.
e.g. Block size 1000 bits. Error rate 1 in 1000.
If errors random, average block will have error.
If errors in bursts of 100, will get a burst of 100 in a row for every 100,000 bits (100 blocks).
This burst will cover only 1 or 2 blocks.
So on average, only 1 or 2 blocks per 100 has error.

Error-detecting codes
- just include enough redundant info with the block
for the receiver to be able to deduce that there was an error
(then asks for re-transmit).
Used when error rate low (e.g. fiber).
Recall discussion in 3.1.1.

Error-correcting codes
- include more info - include enough redundant info with the block
for the receiver to be able to deduce what bits are wrong
and reconstruct original.
Used when error rate high (e.g. wireless).
Detect plus re-transmit no good because re-transmit will have errors too.