Major rewrite of the packet sending code:

* Automatic packet splitting. You can send packets with any number of blocks and the networking layer will split them up automatically
* Less memory is allocated for outgoing packet buffers
* Memory is only allocated for zerocoding (outgoing and incoming) when it is needed
* A lockless queue is used to hold outgoing ACKs
* ACKs are stuffed into packets until they hit the MTU
* All outgoing packets are serialized exactly once, instead of serializing every resend
* Improved the clarity of the networking layer (I will upload a flow chart of packet sending soon)

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2800 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2009-05-22 19:54:00 +00:00
parent dcb7da5a24
commit f1e8fd4fe8
8 changed files with 580 additions and 233 deletions

View File

@@ -10,14 +10,8 @@ namespace OpenMetaverse
{
/// <summary>Size of the byte array used to store raw packet data</summary>
public const int BUFFER_SIZE = 4096;
/// <summary>Size of the temporary buffer for zerodecoding and
/// zeroencoding this packet</summary>
public const int ZERO_BUFFER_SIZE = 4096;
/// <summary>Raw packet data buffer</summary>
public readonly byte[] Data;
/// <summary>Temporary buffer used for zerodecoding and zeroencoding
/// this packet</summary>
public readonly byte[] ZeroData;
/// <summary>Length of the data to transmit</summary>
public int DataLength;
/// <summary>EndPoint of the remote host</summary>
@@ -29,9 +23,8 @@ namespace OpenMetaverse
public UDPPacketBuffer()
{
Data = new byte[UDPPacketBuffer.BUFFER_SIZE];
ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE];
// Will be modified later by BeginReceiveFrom()
RemoteEndPoint = (EndPoint)new IPEndPoint(Settings.BIND_ADDR, 0);
RemoteEndPoint = new IPEndPoint(Settings.BIND_ADDR, 0);
}
/// <summary>
@@ -41,8 +34,18 @@ namespace OpenMetaverse
public UDPPacketBuffer(IPEndPoint endPoint)
{
Data = new byte[UDPPacketBuffer.BUFFER_SIZE];
ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE];
RemoteEndPoint = (EndPoint)endPoint;
RemoteEndPoint = endPoint;
}
/// <summary>
/// Create an allocated UDP packet buffer for sending a packet
/// </summary>
/// <param name="endPoint">EndPoint of the remote host</param>
/// <param name="bufferSize">Size of the buffer to allocate for packet data</param>
public UDPPacketBuffer(IPEndPoint endPoint, int bufferSize)
{
Data = new byte[bufferSize];
RemoteEndPoint = endPoint;
}
}