Illustration of "Network security, data link layer"

From my man pages.

From my man pages.

Revision sheet-2 Data_link_layer

Services

  • Encapsulates data into frames
  • Handles detection and correction of transmission errors
  • Regulates the flow of data
  • High-level link management

Service types

Unacknowledged connectionless (CL)

  • Frames are transmitted independently
  • Error may be detected
  • No recovered nor notification

Acknowledged connection-oriented (CO)

  • Connection established before data-exchange
  • Protocol guarantees success, order, no duplicates
  • Retransmit if lost/damaged
  • Notifications

Communication techniques

  • Synchronisation with flag bytes
  • Byte and bit stuffing
  • Error-detecting codes: parity bits, checksums, CRCs
  • Error-correcting codes
  • Framing (long physical message -> short ones named frames -> restore)

Framing

[BEGIN FRAME END] ...

Byte counts

[N] [1 2 3 4 ... n]

Flags / Byte Stuffing / Bit Stuffing

  • Flags (FLAG) (BYTES) (FLAG)
  • Byte S (FLAG) (BYTES ESC FLAG ESC ESC) (FLAG)
  • Bit S (111111 -> 1111101)
  • Bit S (111110 -> 1111100)

Errors

Error detecting codes

  • (FLAG) (DATA) (ERROR DET CODE) (FLAG)

Parity check

  • Number of 1 (or 0) is odd (or even)
  • Detect 1 bit error

Modular checksum

  • Sum of the bytes % 256
  • detect 8 bits errors

CRC (Cyclic Redundancy Check)

  • 16-32 bits long
  • all single-bit errors
  • all double-bit errors
  • all odd numbers of bit errors
  • all error bursts ≤ N bits
  • most error bursts > N bits

Error correction

Backward Error Correction

  • detect error, send notification, retransmit frames
  • duplex

Forward Errr Correction

  • very efficient if rate error high or high ping
  • frames contain extra-bits
  • simplex

Hamming codes

  • replace A bits with a B bits lenght code
  • Detect: B - A - 1
  • Correct: (B - A - 1) / 2
  • Size of hamming code is logarithmic
  • Multiplexing + Hamming code = optimisation

example

Data to be sent 01, 11, 00, 10

Hamming codes 00111, 11110, 00000, 11001

After multiplexing 0101, 0101, 1100, 1100, 1001

Noise burst corrupts several adjacent bits during transmission

Multiplexed codes received 0101, 0101, 0011, 1100, 1001

                                        XXXX

After demultiplexing 00011, 11010, 00100, 11101

                              X      X      X      X

Stop-And-Wait

  • sender transmit frames
  • receiver accept (ACK / RR)

Efficiency

  • LAN: 100m cable, 1 Gpbs, Frame = 1000 Bytes delay = 0.5µs, frame duration = 8µs, RR = 9µs efficiency = 0.889 Gbps = 88.9%
  • WAN: 100 km, delay = 1009 µs, efficiency = 0,0079 Gpbs

Sliding window flow control

  • W: window size. Max = (2^k) - 1 (k = size of sequence number fields, in bits)
  • Each frame has 1 number in 0..2^W-1
  • Periodical RR sent to sender with the next frame id

Error control

  • Posifive AK: RR (every N frames received)
  • No AK: has to resend every frame not AK
  • Negative AK: REJ, NAK = has to resent (damaged / out of seq frame)
  • SREJ selective reject
  • Save out-of-sequences frames (and reorder them after) Note: maximum window size = 2^(k-1), k = 1/2 bits numbers

HDLC (High-Level Data Link Control)

  • PPP: (point-to-point protocol) (dial-up, broadband)
  • LLC: (logical link control) (ethernet, wifi)
  • Point to Point, Multi Point, Half-duplex, Full-Duplex, Connection Oriented, Connectionless

Frame Structure

| Flag | address | control | data | FCS | FLAG | | 8 | 8 | 8/16 | ~ | 16/32 | 8 |

  • FLAG = 01111110
  • Control = seq number
  • FCS Frame check sequence (CRC-32, CRC-CCITT)

Other

  • SABM: set asynchronous balanced mode
  • DISC: disconnect
  • UI: Unnumbered information
  • UA: Unnumbered acknowledgment