# Internet protocol Version 4 (IPV4)

- IP is the principal communications protocol in the network layer.
- IP has the task of delivering packets from source host to destination host based on IP addresses.

IP defines datagram structure that encapsulate the data to be delivered.

An IP datagram (packet) consists of a header part an a text part. (payload)

The header has a 20 byte fixed part an a variable length optional part.

![[IP-packet.png]]

Some of the fields in a packet are not always used.

## Packet encapsulation
Packets are encapsulated in data link frames (Ethernet)

![[packet-enscapsulation-2.png]]

## Fragmentation
Mostly, data link frames are smaller in size than IP Packets
So the IP Packet does not fit in the data link frame.

In these cases the packet is split up into multiple parts (fragments) and each fragment is send in a separate frame.

![[packet-fragmentation.png]]

The receiver host then combines all fragments before using them

Therefore the receiver should know which part of the message each fragment belongs (hence the fragment offset field in IP header)

![[packet-fragmentation-2.png]]

Ecapsulating a packet in a frame requires:

- Sender MAC Address (can be found out)
- Receiver MAC Address (Should be found out