Table of Contents

Class ThrottledTunnel

Namespace
VpnHood.Core.Tunneling
Assembly
VpnHood.Core.Tunneling.dll

Represents a tunnel with a send limit: the session's packets wait in its queue, one for all its channels, and leave it at the limit.

public class ThrottledTunnel : Tunnel, IPacketTransport, IDisposable
Inheritance
ThrottledTunnel
Implements
Inherited Members

Remarks

The queue is the session's bottleneck, sharing the limit with its forwarding streams: it takes its turns at the limit as one more stream, so beside busy streams all its packets together get a stream's share. It holds about a quarter second of the limit, at least a new connection's first burst, in lanes by flow that take turns, so a flow that floods fills only its own lane.

Constructors

ThrottledTunnel(TunnelOptions, TrafficMeter)

Initializes a new instance of the ThrottledTunnel class.

public ThrottledTunnel(TunnelOptions options, TrafficMeter trafficMeter)

Parameters

options TunnelOptions

The options.

trafficMeter TrafficMeter

The session's meter: the send limit the tunnel's packets are paced to, shared with the session's forwarding streams. The session disposes it.

Exceptions

ArgumentException

The options' most packet channels is less than 1, or trafficMeter has no send limit.

Properties

QueueLength

Gets the number of packets waiting in the send queue.

public override int QueueLength { get; }

Property Value

int

Remarks

It is the packets waiting for their turn; the base queues none, as it passes each on.

Methods

DisposeManaged()

Releases managed resources; the base detaches the PacketReceived handlers. A derived class must catch its own errors.

protected override void DisposeManaged()

Remarks

It disposes its UDP channel, then its other channels.

SendPacketsAsync(IReadOnlyList<IpPacket>)

Sends a batch of packets: one packet in single mode. It runs on the sending loop, one batch at a time; in passthrough mode, on the sender's thread.

protected override ValueTask SendPacketsAsync(IReadOnlyList<IpPacket> ipPackets)

Parameters

ipPackets IReadOnlyList<IpPacket>

The batch. The list is reused after the call.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

It must end once the transport is disposed. A throw counts the whole batch dropped and disposes it, except in passthrough mode without AutoDisposePackets, where the derived class disposes what it does not hand on; so it must not throw after handing a packet on. A packet it gives up without failing the batch, it reports with DropPacket(IpPacket), or the packet counts as sent. In passthrough mode it must complete at once and never send on its own transport.