Documentation ¶
Overview ¶
Package packeter breaks a message into Reed-Solomon shards with enough parity shards to accommodate for expected losses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BufferSize = 50
BufferSize is the default channel buffer size for a Packeter
var Packetlength = 10000
Packetlength is the max packet length in bytes. Defaults to 10k. This cannot be higher than 65535 because of the UDP standard.
var TTL = time.Second * 10
TTL sets the time that a partial message will wait until is deleted
Functions ¶
This section is empty.
Types ¶
type Package ¶
Package represents a message that was transmitted.
type Packet ¶
type Packet struct { PackageID uint32 PacketID uint16 ParityShards uint16 Packets uint16 Data []byte }
Packet represents a shard of a message. If enough shards from a message are collected, the message can be reconstructed.
func (*Packet) DataShards ¶
DataShards returns the number of DataShards in a message, this is also the number of shards needed to reconstruct the message
type Packeter ¶
type Packeter struct { sync.Mutex Handler func(*Package) // contains filtered or unexported fields }
Packeter manages the process of collecting packets and resolving them to messages as well as converting a message into a set of packets
func (*Packeter) Chan ¶
Chan returns the channel that can receive Packages after the packeter has reassembled them
func (*Packeter) Make ¶
Make takes a message as a byte slice, along with the expected loss rate and target reliability and produces the packets for that message. The packets are returned as a slice of byte-slices.
func (*Packeter) Receive ¶
Receive collects packets. When exactly enough packets have been recovered to reconstruct the message, the message is sent to the Handler if one is defined or over the channel otherwise. Receive can continue to collect packets after the message has been constructed for reliability statistics.