Trap provides for multiplexed data transfer, in order to allow one physical connection to carry multiple logical flows. These logical flows can be completely independent of each-other, and, as such, may have different requirements. For example, one flow can be the transfer of a 1gb movie, while a separate flow contains short control messages, or user-to-user text messages.
Channels provide a way to separate out these flows.
With channels, the application can specify a channel for “bulk” data, and a channel for prioritised data. When data is sent on the prioritised channel, it will pre-empt the bulk transfer. This allows multiple separate flows to coexist without having to establish separate physical connections.
Channels are instantly available. You can send on any supported channel. Channel configuration can be asymmetric – the server can have different bandwidths and priorities for a channel than the client. This allows proper prioritisation on asymmetric links, as many internet connections are.
All channels are instantly available, and can be used at will. The default configuration uses 16kb chunks and 128kb in flight bytes. Within the same priority level, channels are cycled on a round robin basis. All channels share the same priority, with the exception of the trap control channel, with ID 0. This channel should not be used.
Using a channel is as simple as specifying it when sending data. Thus, to send on channel 1:
client.send(msg, 1, false) // Java client.send(msg, 1); // JavaScript
All channels can be used instantly.
Channels can be customised as well. It is possible to change the priority of a channel. The priority goes from positive to negative (highest to lowest priority), where the highest priority can pre-empt other traffic. Thus, a channel with priority 100 will have a possibility to send traffic before a channel with priority 1. If a link does not have enough bandwidth, it is possible for lower prioritised channels to be starved out.
Within the same priority level, messages will be interleaved. If there are five channels at level 0, they will each get to send out one chunk. They will not be starved out individually in case of a lack of bandwidth.
Channels are accessed using the getChannel method.
channel = client.getChannel(1);
Once a channel is accessed, several properties can be set. These include: