Connection Layer

The Connection layer provides transmission of packets between host machines and is divided into two modules, a platform packet module and the Connection manager. The platform packet module provides basic connectionless unreliable packet delivery, currently implemented using standard UDP sockets. The Connection manager provides a virtual connection between two hosts and while it does not provide delivery guarantees, it does provide packet delivery status notifications.

This notification guarantee is very important to the architecture; a packet layer that supports only guaranteed or non-guaranteed packets would not be sufficient to support the four basic data delivery modalities outlined above. How each delivery mode is handled is delegated to a higher level -- the connection manager only guarantees the correct notification of a sent packet's status. I.e., if a packet is notified as dropped it was either dropped or delivered out of order (and subsequently dropped), and if a packet is notified as delivered, it has been delivered.

The Connection manager notifies the Stream layer of the status of each packet in the order that they were sent. An overview of this relationship is shown in Figure 2. Dropped packets are never re-transmitted by the Connection manager; the Stream layer, and its associated managers, handle all data guarantee mechanisms. Since packets are never retransmitted, they are freed immediately after transmission.

The Connection manager employs a sliding window protocol in order to track the delivery of packets. When the window is full, transmission stops until an Acknowledgment is received. Acknowledgment of packets is only used to advance the window and generate notification events. This protocol imposes an average overhead of 3 bytes per packet.

Though not part of the protocol, an important feature of the architecture is bit-packing provided by a custom bit stream class. This class provides bit level read and write functions, including read/write functions for: a single bit, variable length integers, variable length normalized floats, and Huffman compressed strings. All packet data, including the header and the sliding window protocol, are accessed through this stream. These packing features are used extensively and virtually all data is transmitted using the smallest number of bits possible.

Examples of bit packing using the bit stream.

Writing into the packet:

	if (stream->writeBool(updateDamage)) {	// Uses 1 bit
		stream->writeInt(mDamageState, 2);	// Uses 2 bits
		if (mDamageState != Dead)
			stream->writeInt(mDamageLevel,6);
		if (stream->writeBool(mRepairActive))
			stream->writeInt(mRepairRate,4);
	}
The matching read method:
	if (stream->readBool()) {
		mDamageState = stream->readInt(2);
		if (mDamageState != Dead)
			mDamageLevel = stream->readInt(6);
		mRepairActive = stream->readBool();
		if (mRepairActive)
			mRepairRate = stream->readInt(4);
	}

Back to Contents