---
title: llarp::iwp

---

# llarp::iwp



## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::iwp::LinkLayer](Classes/structllarp_1_1iwp_1_1LinkLayer.md)**  |
| struct | **[llarp::iwp::OutboundMessage](Classes/structllarp_1_1iwp_1_1OutboundMessage.md)**  |
| struct | **[llarp::iwp::InboundMessage](Classes/structllarp_1_1iwp_1_1InboundMessage.md)**  |
| struct | **[llarp::iwp::Session](Classes/structllarp_1_1iwp_1_1Session.md)**  |

## Types

|                | Name           |
| -------------- | -------------- |
| enum| **[Command](Namespaces/namespacellarp_1_1iwp.md#enum-command)** { ePING = 0, eXMIT = 1, eDATA = 2, eACKS = 3, eNACK = 4, eMACK = 5, eCLOS = 0xff} |
| using std::shared_ptr< [LinkLayer](Classes/structllarp_1_1iwp_1_1LinkLayer.md) > | **[LinkLayer_ptr](Namespaces/namespacellarp_1_1iwp.md#using-linklayer-ptr)**  |

## Functions

|                | Name           |
| -------------- | -------------- |
| LinkLayer_ptr | **[NewInboundLink](Namespaces/namespacellarp_1_1iwp.md#function-newinboundlink)**(std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > keyManager, std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > loop, [GetRCFunc](Namespaces/namespacellarp.md#using-getrcfunc) getrc, [LinkMessageHandler](Namespaces/namespacellarp.md#using-linkmessagehandler) h, [SignBufferFunc](Namespaces/namespacellarp.md#using-signbufferfunc) sign, [BeforeConnectFunc_t](Namespaces/namespacellarp.md#using-beforeconnectfunc-t) before, [SessionEstablishedHandler](Namespaces/namespacellarp.md#using-sessionestablishedhandler) est, [SessionRenegotiateHandler](Namespaces/namespacellarp.md#using-sessionrenegotiatehandler) reneg, [TimeoutHandler](Namespaces/namespacellarp.md#using-timeouthandler) timeout, [SessionClosedHandler](Namespaces/namespacellarp.md#using-sessionclosedhandler) closed, [PumpDoneHandler](Namespaces/namespacellarp.md#using-pumpdonehandler) pumpDone, [WorkerFunc_t](Namespaces/namespacellarp.md#using-workerfunc-t) work) |
| LinkLayer_ptr | **[NewOutboundLink](Namespaces/namespacellarp_1_1iwp.md#function-newoutboundlink)**(std::shared_ptr< [KeyManager](Classes/structllarp_1_1KeyManager.md) > keyManager, std::shared_ptr< [EventLoop](Classes/classllarp_1_1EventLoop.md) > loop, [GetRCFunc](Namespaces/namespacellarp.md#using-getrcfunc) getrc, [LinkMessageHandler](Namespaces/namespacellarp.md#using-linkmessagehandler) h, [SignBufferFunc](Namespaces/namespacellarp.md#using-signbufferfunc) sign, [BeforeConnectFunc_t](Namespaces/namespacellarp.md#using-beforeconnectfunc-t) before, [SessionEstablishedHandler](Namespaces/namespacellarp.md#using-sessionestablishedhandler) est, [SessionRenegotiateHandler](Namespaces/namespacellarp.md#using-sessionrenegotiatehandler) reneg, [TimeoutHandler](Namespaces/namespacellarp.md#using-timeouthandler) timeout, [SessionClosedHandler](Namespaces/namespacellarp.md#using-sessionclosedhandler) closed, [PumpDoneHandler](Namespaces/namespacellarp.md#using-pumpdonehandler) pumpDone, [WorkerFunc_t](Namespaces/namespacellarp.md#using-workerfunc-t) work) |
| ILinkSession::Packet_t | **[CreatePacket](Namespaces/namespacellarp_1_1iwp.md#function-createpacket)**(Command cmd, size_t plainsize, size_t min_pad =16, size_t pad_variance =16)<br>creates a packet with plaintext size + wire overhead + random pad  |

## Attributes

|                | Name           |
| -------------- | -------------- |
| constexpr size_t | **[FragmentSize](Namespaces/namespacellarp_1_1iwp.md#variable-fragmentsize)** <br>max size of data fragments  |
| constexpr size_t | **[CommandOverhead](Namespaces/namespacellarp_1_1iwp.md#variable-commandoverhead)** <br>plaintext header overhead size  |
| constexpr size_t | **[PacketOverhead](Namespaces/namespacellarp_1_1iwp.md#variable-packetoverhead)** <br>packet crypto overhead size  |
| constexpr std::chrono::milliseconds | **[DeliveryTimeout](Namespaces/namespacellarp_1_1iwp.md#variable-deliverytimeout)** <br>Time how long we try delivery for.  |
| constexpr auto | **[ReceivalTimeout](Namespaces/namespacellarp_1_1iwp.md#variable-receivaltimeout)** <br>Time how long we wait to recieve a message.  |
| constexpr auto | **[ReplayWindow](Namespaces/namespacellarp_1_1iwp.md#variable-replaywindow)** <br>How long to keep a replay window for.  |
| constexpr auto | **[ACKResendInterval](Namespaces/namespacellarp_1_1iwp.md#variable-ackresendinterval)** <br>How often to acks RX messages.  |
| constexpr auto | **[TXFlushInterval](Namespaces/namespacellarp_1_1iwp.md#variable-txflushinterval)** <br>How often to retransmit TX fragments.  |
| constexpr std::chrono::milliseconds | **[PingInterval](Namespaces/namespacellarp_1_1iwp.md#variable-pinginterval)** <br>How often we send a keepalive.  |
| constexpr auto | **[SessionAliveTimeout](Namespaces/namespacellarp_1_1iwp.md#variable-sessionalivetimeout)** <br>How long we wait for a session to die with no tx from them.  |

## Types Documentation

### enum Command

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| ePING | 0| keep alive message   |
| eXMIT | 1| begin transission   |
| eDATA | 2| fragment data   |
| eACKS | 3| acknolege fragments   |
| eNACK | 4| negative ack   |
| eMACK | 5| multiack   |
| eCLOS | 0xff| close session   |




### using LinkLayer_ptr

```cpp
using llarp::iwp::LinkLayer_ptr = typedef std::shared_ptr<LinkLayer>;
```



## Functions Documentation

### function NewInboundLink

```cpp
LinkLayer_ptr NewInboundLink(
    std::shared_ptr< KeyManager > keyManager,
    std::shared_ptr< EventLoop > loop,
    GetRCFunc getrc,
    LinkMessageHandler h,
    SignBufferFunc sign,
    BeforeConnectFunc_t before,
    SessionEstablishedHandler est,
    SessionRenegotiateHandler reneg,
    TimeoutHandler timeout,
    SessionClosedHandler closed,
    PumpDoneHandler pumpDone,
    WorkerFunc_t work
)
```


### function NewOutboundLink

```cpp
LinkLayer_ptr NewOutboundLink(
    std::shared_ptr< KeyManager > keyManager,
    std::shared_ptr< EventLoop > loop,
    GetRCFunc getrc,
    LinkMessageHandler h,
    SignBufferFunc sign,
    BeforeConnectFunc_t before,
    SessionEstablishedHandler est,
    SessionRenegotiateHandler reneg,
    TimeoutHandler timeout,
    SessionClosedHandler closed,
    PumpDoneHandler pumpDone,
    WorkerFunc_t work
)
```


### function CreatePacket

```cpp
ILinkSession::Packet_t CreatePacket(
    Command cmd,
    size_t plainsize,
    size_t min_pad =16,
    size_t pad_variance =16
)
```

creates a packet with plaintext size + wire overhead + random pad 


## Attributes Documentation

### variable FragmentSize

```cpp
static constexpr size_t FragmentSize = 1024;
```

max size of data fragments 

### variable CommandOverhead

```cpp
static constexpr size_t CommandOverhead = 2;
```

plaintext header overhead size 

### variable PacketOverhead

```cpp
static constexpr size_t PacketOverhead = HMACSIZE + TUNNONCESIZE;
```

packet crypto overhead size 

### variable DeliveryTimeout

```cpp
static constexpr std::chrono::milliseconds DeliveryTimeout = 500ms;
```

Time how long we try delivery for. 

### variable ReceivalTimeout

```cpp
static constexpr auto ReceivalTimeout = (DeliveryTimeout * 8) / 5;
```

Time how long we wait to recieve a message. 

### variable ReplayWindow

```cpp
static constexpr auto ReplayWindow = (ReceivalTimeout * 3) / 2;
```

How long to keep a replay window for. 

### variable ACKResendInterval

```cpp
static constexpr auto ACKResendInterval = DeliveryTimeout / 2;
```

How often to acks RX messages. 

### variable TXFlushInterval

```cpp
static constexpr auto TXFlushInterval = (DeliveryTimeout / 5) * 4;
```

How often to retransmit TX fragments. 

### variable PingInterval

```cpp
static constexpr std::chrono::milliseconds PingInterval = 5s;
```

How often we send a keepalive. 

### variable SessionAliveTimeout

```cpp
static constexpr auto SessionAliveTimeout = PingInterval * 5;
```

How long we wait for a session to die with no tx from them. 




-------------------------------

Updated on 2022-10-25 at 00:38:16 +0000