220.127.116.11 Sending Application Data
Higher layers pass messages to the DirectPlay 8 Protocol for transmission over an established connection. The protocol SHOULD send the packets by using the requested reliable/unreliable behavior.
The higher layer MAY request that the PACKET_COMMAND_USER_1 flag, the PACKET_COMMAND_USER_2 flag, both flags, or neither flag be set in the bCommand field. On reception, the DirectPlay 8 Protocol implementation MUST pass the presence or absence of these bits unchanged to the upper layer and MUST NOT interpret their meaning.
If the message is smaller than the supported maximum transmission unit (MTU) size, the packet MUST have the PACKET_COMMAND_NEW_MSG and PACKET_COMMAND_END_MSG flags set in the bCommand field. In this case, the payload is eligible for coalescence with other payloads if the receiver's version number and the payload sizes allow.
If the message is larger than the supported MTU size, the protocol SHOULD split the message into multiple packets. The implementation SHOULD fill each packet to the maximum size allowed with any remainder in the final packet; however, it MAY divide the payload portions in any manner, such as equal portions in all packets.
The packets MUST be transmitted in order. The first packet in the series MUST have the PACKET_COMMAND_NEW_MSG flag set, and the last packet MUST have the PACKET_COMMAND_END_MSG flag set in the bCommand field. Subsequent messages MUST NOT be transmitted until the last packet of the large message is sent. This is because the receiver reconstructs messages according to the order of the sequence IDs of their constituent packets. If two messages were interleaved, the receiver would be unable to detect the end of one message from the start of the next.
If the connection was established with fast signing, the DFRAME MUST contain a ullSignature field that is set to the 64-bit local secret that is associated with the local sender; that is, the same value as the CONNECTED_SIGNED frame's ullSenderSecret field if the local computer system performed an outbound connection, or the same value as the CONNECTED_SIGNED frame's ullReceiverSecret field if the local computer system received an inbound connection.
If the connection was established by using full signing, the DFRAME MUST contain a ullSignature field that is set to the first 64 bits of the SHA-1 signature digest, as specified in [FIPS180]. The digest MUST be calculated, in sequence, from the following data:
The entire packet to be sent, extending from the beginning of the DFRAME header and concluding with the final byte of the final mask, payload, or coalesced payload, as appropriate, except with the DFRAME ullSignature bytes set to 0.
The 64-bit current or previous local secret, in little-endian byte order. The local secret to use when validating MUST be selected according to the following logic:
If the packet is not a retry, use the current local secret.
For retried packets, if the next new sequence ID that will be sent is less than 64 and the packet being retried has a sequence ID that is greater than or equal to 192, use the previous local secret.
For all other retried packets, use the current local secret.
For full-signed connections, local secrets are also modified once for each time that the 8-bit sequence space wraps, in order to avoid signing all data with the same value. The modification is performed by using a modifier value that is derived from the lowest sequenced reliable payload, that is sent with a sequence ID of less than 192, and that is not a KeepAlive.
If the lowest sequenced packet that uses the PACKET_COMMAND_RELIABLE flag contains coalesced payloads, the first subpayload that is marked PACKET_COMMAND_RELIABLE is used to generate the modifier. If no non-KeepAlive reliable payload is sent with a sequence ID between 0 and 191 inclusive, the previous local secret modifier value is reused.
The local secret modifier value is initialized to the secret associated with the sender when the connection was established; that is, it begins with the same value as the CONNECTED_SIGNED frame's ullSenderSecret field if the local computer system performed an outbound connection, and it begins with the same value as the CONNECTED_SIGNED frame's ullReceiverSecret field if the local computer system received an inbound connection.
After sending the packet with sequence ID 255 on a full-signed connection, the sender MUST advance the secret by making the current local secret become the previous local secret and by setting the new current local secret to the first 64 bits of a SHA-1 digest (as specified in [FIPS180]) of the following data, in sequence:
The previous 64-bit local secret, in little-endian byte order.
The 64-bit local secret modifier value, in little-endian byte order.
DirectPlay 8 Protocol implementations MUST NOT allow more than 64 packets on the network simultaneously. Additional packets SHOULD be queued on the sender until an acknowledgment (ACK) for a previously sent packet is received.
Implementations SHOULD also implement TCP-friendly congestion control mechanisms [RFC2581], such as initially allowing only two packets on the network and gradually increasing the window by one as ACKs arrive without packet loss.