Windows Vista TCP/IP stack cannot send UDP packets?
Windows Vista came out with the new TCP/IP stack that was very promising TCP/IP v6 build in. That was great news for anybody that has worked in the socket world. I have been going in and out with my love and projects in IP and UDP. I do prefer UDP as I’ve always the excuse that I do not warranty the delivery ;-) That’s a great joke in the 3G conference in Barcelona for next year, must write down.
.NET 3.5 provides us a new class UdpClient to handle the communications using UDP to send and received packets from a socket, I personally still love using the Socket library from .NET as is very similar to the C/C++ socket library, except the method Peek() to check if there is a new byte arriving. With the .NET libraries if there aren’t any bytes to be received the function Receive() will block forever, make sure you add a timeout to be able to let go of the thread.
For UPD the properties for the socket are the ones passed on the constructor.
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
server.Connect(RemoteIPEndPointSent);
server.SendTo(bytesToSend, RemoteIPEndPointSent);
byte[] Buf = new byte[48];
try
{
server.ReceiveTimeout = 5000;
int isom = server.Receive(Buf);
}
catch
{
//Nothing is replying!
}
server.Close();
In the sample above the timeout for the socket is 5 seconds, that will give the remote computer, plenty time to reply, after that an exception will be raised that you can catch and handle.
Problem
Something that was driving me crazy was when I started sending UDP packets from Vista and nothing arrived to the remote computer, after using a network sniffer I realize that all packets were converted to ARP packets instead of UDP packets and also sent from a IP v6 address instead of the IP v4 address in my computer. Going to the Network Control panel and disabling IP v6 didn’t make a difference.
Resolution
Having a set up with a sniffer in the middle is a time consuming task, so I though to debug a little the problem. I logoff the computer and re-login, he ARP packets were still being sent instead of UDP. A complete computer reboot seems to do the trick for Vista to use the new TCP/IP stack.
I thought that Vista was designed with a new TCP/IP stack, knowing the kernel is still the old 32 bits Windows kernel, the stack will refresh itself to get the newest configuration without needing a reboot. When changing the configuration the OS does not ask for a reboot, as expected, however if you do not reboot, you won’t be able to disable the IP v6 protocol and all packets will be received by routers with that protocol. Now, do you know how many routers have enabled or understand IP v6?
Cheers
Al
Posted from
http://weblogs.asp.net/albertpascual