Zero Padding Culprit

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I have a Windows Forms Application that communicates with an embedded client
using custom messages over a UdpClient connection.

Everything was fine until the Windows machine was upgraded with service
packs.
After installing WinXP SP2 and .Net Fx 1.1 SP1, something started zero
padding my messages (verified by Ethereal). The embedded client doesn't
expect these extra bytes.

Does anyone know what software component is zero padding my messages to a
multiple of 32 bits? Is it WinXP SP2, Fx 1.1 SP1, or something else?

Thanks for your help, Jeff
 
Jeff said:
I have a Windows Forms Application that communicates with an embedded client
using custom messages over a UdpClient connection.

Everything was fine until the Windows machine was upgraded with service
packs.
After installing WinXP SP2 and .Net Fx 1.1 SP1, something started zero
padding my messages (verified by Ethereal). The embedded client doesn't
expect these extra bytes.

Does anyone know what software component is zero padding my messages to a
multiple of 32 bits? Is it WinXP SP2, Fx 1.1 SP1, or something else?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Hi Jon,

Thanks for helping me.

I'm sure I didn't explain my problem very well.
If I had, you probably wouldn't want to see any of my code because I think
it is irrelevant.

I have a Windows Forms application (C#) that uses UdpClient to send bytes to
the network.

Machine A: WinXP SP1, .Net Framework 1.1
Machine B WinXP SP2, .Net Framework 1.1 SP 1

Suppose I send a 5 byte message from my application on Machine A.
Using a packet sniffer, I can see my 5 byte payload on the network.
Life is good.
However, the same .exe running on Machine B acts differently.
Using a packet sniffer, I can see my 5 bytes plus 3 bytes of zero padding.

Why the zero padding, or 32-bit alignment?

Thanks, Jeff
 
Jeff said:
Thanks for helping me.

I'm sure I didn't explain my problem very well.
If I had, you probably wouldn't want to see any of my code because I think
it is irrelevant.

No, I think I understood your description, but I still want to see the
code.
I have a Windows Forms application (C#) that uses UdpClient to send bytes to
the network.

Machine A: WinXP SP1, .Net Framework 1.1
Machine B WinXP SP2, .Net Framework 1.1 SP 1

Suppose I send a 5 byte message from my application on Machine A.
Using a packet sniffer, I can see my 5 byte payload on the network.
Life is good.
However, the same .exe running on Machine B acts differently.
Using a packet sniffer, I can see my 5 bytes plus 3 bytes of zero padding.

Why the zero padding, or 32-bit alignment?

I don't know, but it's possible that you have a bug in your code which
only exhibits itself under SP1.
 
Jon,

Here is a simplified and clarified snippet:

public void SendTestMessage()
{
const byte BYTE_ONE = 0x01;
const byte BYTE_TWO = 0x02;
const byte BYTE_THREE = 0x03;

ArrayList msgBuffer = new ArrayList();

msgBuffer.Add(BYTE_ONE);
msgBuffer.Add(BYTE_ TWO);
msgBuffer.Add(BYTE_THREE);

byte[] msg = (byte[])msgBuffer.ToArray(typeof(byte));

this.udpClient.Send(msg, msg.Length, this.remoteEndpoint);
}

Thanks again for your help,
Jeff
 
Back
Top