# Internet Protocol Version 4
IPv4 packet construction — TCP, UDP, ICMP flows and IP-level fragmentation.
## Index
### Modules
| [icmp](icmp/README.md) | Internet Control Message Protocol (ICMP) |
| [proto](proto/README.md) | IP Protocols |
| [tcp](tcp/README.md) | Transmission Control Protocol (TCP) |
| [udp](udp/README.md) | User Datagram Protocol (UDP) |
### Classes
| [IpFrag](IpFrag.md) | IP Packet Fragment Builder |
### Functions
| [datagram](#datagram) | `Pkt` | Create a raw IPv4 header or datagram |
| [frag](#frag) | [IpFrag](../ipv4/IpFrag.md) | Create a context for a packet which can be arbitrarily fragmented |
## datagram
```resynth
resynth fn datagram (
src: Ip4,
dst: Ip4,
id: u16 = 0x0000,
evil: bool = false,
df: bool = false,
mf: bool = false,
ttl: u8 = 0x40,
frag_off: u16 = 0x0000,
proto: u8 = 0x11,
=>
*collect_args: bytes,
) -> Pkt;
```
Create a raw IPv4 header or datagram
### Parameters
| `src` | `Ip4` | Source IPv4 address |
| `dst` | `Ip4` | Destination IPv4 address |
| `id` | `u16` | IP identification field _(default: `0x0000`)_ |
| `evil` | `bool` | Set the evil bit (RFC 3514) _(default: `false`)_ |
| `df` | `bool` | Set the Don't Fragment (DF) flag _(default: `false`)_ |
| `mf` | `bool` | Set the More Fragments (MF) flag _(default: `false`)_ |
| `ttl` | `u8` | IP Time-To-Live value _(default: `0x40`)_ |
| `frag_off` | `u16` | Fragment offset field (in 8-byte units) _(default: `0x0000`)_ |
| `proto` | `u8` | IP protocol number _(default: `0x11`)_ |
| `…` | `bytes` | Zero or more additional values |
### Returns
| `Pkt` |
## frag
```resynth
resynth fn frag (
src: Ip4,
dst: Ip4,
id: u16 = 0x0000,
evil: bool = false,
df: bool = false,
ttl: u8 = 0x40,
proto: u8 = 0x11,
=>
*collect_args: bytes,
) -> IpFrag;
```
Create a context for a packet which can be arbitrarily fragmented
### Parameters
| `src` | `Ip4` | Source IPv4 address |
| `dst` | `Ip4` | Destination IPv4 address |
| `id` | `u16` | IP identification field _(default: `0x0000`)_ |
| `evil` | `bool` | Set the evil bit (RFC 3514) _(default: `false`)_ |
| `df` | `bool` | Set the Don't Fragment (DF) flag _(default: `false`)_ |
| `ttl` | `u8` | IP Time-To-Live value _(default: `0x40`)_ |
| `proto` | `u8` | IP protocol number _(default: `0x11`)_ |
| `…` | `bytes` | Zero or more additional values |
### Returns
| [IpFrag](../ipv4/IpFrag.md) |