function · Browser and Node

# fragment

Cuts a packet into DATA frames of at most `mtu` bytes. Throws when it needs more than 64.

`@toip-tools/mesh-transport` · [View source](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/mesh-transport/src/frame.ts#L76)

Import:

```ts
import { fragment } from "@toip-tools/mesh-transport";
```

## Declaration

Signature:

```ts
fragment(packet: Uint8Array, mtu: number, hdr: {
    ttl: number;
    hops: number;
    attempt: number;
}): Uint8Array[];
```

### Parameters

- **`packet` (required)**: `Uint8Array<ArrayBufferLike>`
- **`mtu` (required)**: `number`
- **`hdr` (required)**: `{ ttl: number; hops: number; attempt: number; }`

### Returns

`Uint8Array<ArrayBufferLike>[]`

[Usage guide](https://toip.tools/toolkit/mesh-transport/#usage) · [Error handling](https://toip.tools/toolkit/mesh-transport/#errors) · [All exports](https://toip.tools/toolkit/mesh-transport/api/)

---

This is the Markdown version of https://toip.tools/toolkit/mesh-transport/api/fragment/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
