OSI and TCP/IP models
| OSI | Five-layer | TCP/IP | ||
|---|---|---|---|---|
| Data | Application | Application | Software | |
| Data | Presentation | |||
| Data | Session | |||
| Segment | Transport (תעבורה, תובלה) | Hardware/Software | ||
| Packet | Network | Internet (or Network) | Hardware | |
| Frame | Data Link (קו, ערוץ) | Link (or Network Access) (קשר, ערוץ) | ||
| Bit | Physical | |||
Link layer
-
Link Classification
- Last-Mile
- Backbone
- LAN
-
Connection-oriented service
-
Connection-less service
Framing
- A frame
Point-to-Point Protocol (PPP)
Byte-Oriented
| 1 byte | 1 | 1 | 2 | 2 | 1 byte | |
|---|---|---|---|---|---|---|
| Flag (0x7E) | Address (0xFF) | Control (0x03) | Protocol | Information (payload) | FCS (Frame Check Sequence) | Flag (0x7E) |
| Header | Data | Footer | ||||
- Link Control Protocol (LCP)
High-Level Data Link Control (HDLC)
bit-oriented
Error detection and correction
-
A message (סיביות מידע, מילת מידע) of length .
-
Redundant bits (סיביות ביקורת) of length (where ).
-
The sender transmits the codeword (מילת קוד) of length .
-
The receiver receives and checks if , if yes, assume no error with high probability, else, error detected.
-
(code rate)
-
(overhead, תקורה)
-
(redundancy)
-
A bit error is when a bit is received incorrectly (0 instead of 1 or vice versa)
-
A burst error is when a sequence of bits is received incorrectly
-
(bit error ratio)
-
(bit error probability)
נצילות השידור
parity checks
- even parity: if number of 1s in is even, else
- odd parity: if number of 1s in is odd, else
- two-dimensional parity check:
- is an matrix of bits
- row parity bits for each row
- column parity bits for each column
- overall parity bit
internet checksum
(note: used in IP, not used in link layer)
- message is divided into words of 16 bits:
- the checksum is (where is the bitwise NOT operation. The sum is done using ones’ complement addition)
- the sender sends
- the receiver computes (using ones’ complement addition) and checks if , if yes, assume no error, else, error detected
cyclic redundancy check (CRC)
- the message has bits
- is the generator polynomial of degree
- is the message polynomial of degree
- the transmitted word will be a polynomial of degree such that .
- construction:
- multiply by to get
- divide by to get the remainder
- compute
- the receiver receives where is the error polynomial (non-zero coefficients indicate bit errors)
- the receiver checks if , if yes, it means that (no error), else, error detected
Error control
Stop-and-wait ARQ
sender:
n = 0
while true:
send frame[n]
if ack[n] received within T time:
n = n + 1
else: # timeout, we start over
receiver:
expected = 0
while true:
receive frame[n]
if n == expected:
deliver data to upper layer
expected = expected + 1
send ack[n]
Sliding window protocol
-
sender:
- constants:
- SWS: send window size
- variables:
- LFS: last frame sent
- LAR: last frame acknowledged
- invariant:
- algorithm:
- if ack for frame k received and :
- set
- if :
- send frame
- increment
- if timeout for frame k:
- resend frame k
- if ack for frame k received and :
- constants:
-
receiver:
- constants:
- RWS: receive window size, s.t.
- variables:
- LAF: last acceptable frame
- LFR: last frame received
- invariant:
- constants:
-
-
negative acknowledgment
-
selective acknowledgments
- the receiver could acknowledge exactly those frames it has received rather than just the highest numbered frame received in order
-
Go-Back-N ARQ
-
Selective Repeat ARQ
Ethernet
Frame format (Ethernet II)
| Ethernet frame (64–1522 bytes) | |||||
| Ethernet packet (72–1530 bytes) | |||||
| Preamble | Dest addr | Src addr | EtherType | Payload | CRC |
| 8 (bytes) | 6 | 6 | 2 | 46-1500 | 4 |
MAC address
| MAC address (12 hex digits = 6 bytes = 48 bits) | |
|---|---|
| XX:XX:XX:XX:XX:XX | |
| XX:XX:XX | XX:XX:XX |
| OUI (Organizationally Unique Identifier) | NIC (Device Identifier) |
-
unicast address:
-
broadcast address: FF:FF:FF:FF:FF:FF = all 1s
- an adpaptor will pass all frames addressed to this address up to host
-
multicast address: the first bit is 1 but the address is not the broadcast address
- an adpaptor can be configured to accept frames addressed to set of multicast addresses
-
Ethernet adaptor receives all frames, but accepts only:
- frames addressed to its unicast address
- frames addressed to the broadcast address
- frames addressed to multicast addresses it is configured to accept
- (all frames if in promiscuous mode)
-
Classic Ethernet uses the 1-persistent CSMA/CD
CSMA
- Carrier Sense Multiple Access (CSMA)
- CSMA/CD (Collision Detection)
- CSMA/CA (Collision Avoidance)
- The slot time is the time to transmit the minimum frame size, given by
- is the maximum distance of the Ethernet segment (in meters)
- is the minimum frame size (in Ethernet, 512 bits (= 64 bytes))
- (10 Mbps Ethernet)
- (100 Mbps Ethernet)
- backoff time = ,
- is a random integer in
- is the number of collisions for the frame (up to a maximum value, e.g., 10)
- algo:
- while not transmitted:
- choose random in
- wait
- try to transmit
- if collision:
access methods
1-persistent
flowchart TD
C{Channel Status?} -->|Busy| C
C -->|Idle| F[Transmit Frame]
F -->|successful transmission| A[done]
F -->|collision| R[Wait random time] --> C
p-persistent
flowchart TD
C{Channel Status?}
C -->|Busy| D[Wait for Next Time Slot]
D --> C
C -->|Idle| E{Random}
E -->|Random ≤ p| F[Transmit Frame]
E -->|Random > p| D
F -->|successful transmission| A[done]
F -->|failed transmission| C
non-persistent
flowchart TD
A[has data to send?] -->|yes| C
C{Sense: Channel Status?}
C -->|Busy| D[Wait random time] --> C
C -->|Idle| F
E{Random}
F[Transmit Frame]