# 2. Data link Layer
The Data Link Layer is responsible for handling the data transfer between two devices on the **same** network. (so a bit like the Network Layer)

The Data Link Layer also splits up packets into smaller chunks called a frame. The reverse happens on the receiving device (reassembling frames into packets).

Like the Network Layer the Data Link Layer is also responsible for flow control and error checking.

## Error Detection
Transmissions are not always error free. In case of an error, it should be detected and the message should be re transmitted (whenever possible)

Detecting errors are handled by different algorithms:
- Parity bits
- CRC

## Data Framing
Data is split up in smaller chunks called frames. For each frame we add some extra data:

- Who is sender?
- Who is receiver?
- Length of chunk
- Type of chunk (normal message, error message, control message)
- Error checking values (ex. CRC code)
- Data and metadata are put in single message called frame

## Ethernet Protocol
Ethernet is a protocol used at the data link layer of wired networks.

Ethernet uses specific hardware addresses to identify hosts on a network.
These 6-byte-integer addresses are names Medium Access Control (MAC Address)

Ethernet frame has the following format:
![[ethernet-frame.png]]

## Wireless networks
Wireless networks do not use a physical medium for data transmission. The data is send through radio waves.

- Each member of a wireless network is called a station.

Networks are implemented in different sizes:
- Wireless local area networks (WLAN)
- Wireless Metropolitan Area Networks (WMAN)
- Wireless Wide Area Networks (WWAN)

### BSS Network
A BSS is a network with a specific station called Access Point.

All transmissions from a station to another are trough the Access Point.

Access Points also connect the network (BSS) other networks, hence the name internet. 

### AD-HOC Networks
AD-HOC networks do not have a central node (access point).

Every station can send data directly to a other station.