I have a problem with recieving UDP multicasts on the NDCM500 HMI board. I have found some forums that report there being an issue in the windows CE 5 code to restrict the ip range used but even still i cannot recieve a multicast reliably.
I was wondering if IGMPv3 is supported by the nic and bsp?
I have some source code but it's vb.net it runs fine on xp sending and receiving but only sends multicasts on the windows CE device.
This is one of the sites where I found out about the windows ce multicast problem >> http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/46bba41d-fffe-4c59-a71e-f73788fa4c97/
Any help or information anyone could provide would be extremely useful, thanks.
Thanks for the information.
I created a debug build and can confirm that "NetXEthSetInformation" is being called with "OID_802_3_MULTICAST_LIST".
unfortunatly my compact framework application fails to run on the debug build with an error about reinstalling the compact framework.
I then created the Recieveing UDP Multicast sample from eVC and run that on the debug build and when it joins a multicast group "NetXEthSetInformation" is being called with "OID_802_3_MULTICAST_LIST".
but I cannot set break points in eVC while debugging in platform builder and the c program still doesn't appear to recieve any multicasts.
as a result of this I am left with these problems:
1. why does the .NET compact framework fail on the debug build of the operating system? and ask to reisntalled? upon reinstallation it still doesn't work.
2. why can't I debug with eVC while debugging with platform builder?
3. why can't I recieve multicasts?
any help that anyone could give me would be greatly appreaciated, until I resolve some of these issue i'm at a loss as what to try next.
I haven't looked at setting the device to promiscuous mode, I guess i need to write some software to capture the packets or find where in NDIS I would need to put some break points to examine them.
Also as a result of some experimentation I have found that the .NET application built for the compact frameowork runs on 2 XP PC's and recieves multicasts and also runs in a release build for the windows CE emulator, this indicates to me that .NET code should work, but as I mentioned above I can't run it on the debug build.
I am continuing to look into this and will post more information as I aquire it.
below is the source for the eVC sample program I am using, the sample didn't compile without slight modifications. the URL of the original sample http://msdn.microsoft.com/en-us/library/aa450126.aspx
the source i am using
// UPDMultiRecv.cpp : Defines the entry point for the application. //#include "stdafx.h"
/*
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.return 0;
}
*/#include
//#include
#include#define RECV_IP_ADDR "224.0.0.60"
#define DEST_PORT 10002int WINAPI WinMain (
HINSTANCE hInstance, // Handle to the current instance
HINSTANCE hPrevInstance,// Handle to the previous instance
LPTSTR lpCmdLine, // Pointer to the command line
int nCmdShow) // Show state of the window.
{
int index = 0, // Integer index
iRecvLen; // Length of recv_sin
char szMessageA[100]; // ASCII string
TCHAR szMessageW[100]; // Unicode string
TCHAR szError[100]; // Error message stringSOCKET Sock = INVALID_SOCKET; // Datagram window socket
struct ip_mreq mreq; // Used in adding or dropping
// multicasting addresses
SOCKADDR_IN local_sin, // Local socket's address
recv_sin; // Holds the source address on
// recvfrom function returns
WSADATA WSAData; // Contains details of the
// Winsock implementation
// Initialize Winsock.
if (WSAStartup (MAKEWORD(1,1), &WSAData) != 0)
{
wsprintf (szError, TEXT("WSAStartup failed! Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
return FALSE;
}// Create a datagram socket, Sock.
if ((Sock = socket (AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET)
{
wsprintf (szError, TEXT("Allocating socket failed! Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
return FALSE;
}// Fill out the local socket's address information.
local_sin.sin_family = AF_INET;
local_sin.sin_port = htons (DEST_PORT);
local_sin.sin_addr.s_addr = htonl (INADDR_ANY);// Associate the local address with Sock.
if (bind (Sock,
(struct sockaddr FAR *) &local_sin,
sizeof (local_sin)) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("Binding socket failed! Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (Sock);
return FALSE;
}// Join the multicast group from which to receive datagrams.
mreq.imr_multiaddr.s_addr = inet_addr (RECV_IP_ADDR);
mreq.imr_interface.s_addr = INADDR_ANY;if (setsockopt (Sock,
IPPROTO_IP,
IP_ADD_MEMBERSHIP,
(char FAR *)&mreq,
sizeof (mreq)) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("setsockopt failed! Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (Sock);
return FALSE;
}iRecvLen = sizeof (recv_sin);
// Receive data from the multicasting group server.
if (recvfrom (Sock,
szMessageA,
100,
0,
(struct sockaddr FAR *) &recv_sin,
&iRecvLen) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("recvfrom failed! Error: %d"),
WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
closesocket (Sock);
return FALSE;
}
else
{
// Convert the ASCII string to a Unicode string
szMessageA[99] = 0;
MultiByteToWideChar(CP_ACP, 0, szMessageA, -1,
szMessageW, sizeof(szMessageW)/sizeof(szMessageW[0]));
MessageBox (NULL, szMessageW, TEXT("Info"), MB_OK);
}// Disable receiving on Sock before closing it.
shutdown (Sock, 0x00);// Close Sock.
closesocket (Sock);WSACleanup ();
return TRUE;
}
Thanks for the previous help and information and thanks to anyone who can help.
Hilscher Gesellschaft für Systemautomation mbH
1. why does the .NET compact framework fail on the debug build of the operating system? and ask to reisntalled? upon reinstallation it still doesn't work.
A debug build if the CE Image is rather huge. Depending on your RAM configuration you may run out of memory? This is just an assumption.
2. why can't I debug with eVC while debugging with platform builder?
3. why can't I recieve multicasts?
Maybe there is an issue inside the netX Ethernet NDIS driver, which does not set the multicast addresses correctly. Or there is a bug inside the CE? Did you install all QFE's available for Windows CE 5?
Regards
MT
Thanks for the reply.
using ceqfecheck I have confirmed that I am update to date with the QFE's. I will move my eVC project into platform builder and try to debug it there. And I will try to order the 64MB ram board for debugging hopefully that'll help with the compact framework failing to load.
I was wondering if maybe you know if any of your customers are using multicasts with the netx and windows ce, just so I could have a little confidence it does work if used correctly.
Thanks again, I will continue battling with my problem.
Hilscher Gesellschaft für Systemautomation mbH
Before actually moving to another board you may also try to remove some items from the image. (e.g. Display support) For further testing.
To your question:
I did not hear from a customer using multicast addresses yet. Neither success, nor failure.
Regards
MT
Hilscher Gesellschaft für Systemautomation mbH
Hi David,
There seems to be a little bug inside the NDIS driver, which disallows setting /Enabling Multicast Groups. The Length of the multicast enable list is calculated wrong.
The following patch should make it work:
--- netxoids_v1012.c Mon Jan 19 14:25:24 2009
+++ netxoids_b1013.c Mon Jan 19 14:25:35 2009
@@ -395,7 +397,7 @@
break;
}
- StatusToReturn = SetMulticastAddressList(pAdapter, (unsigned char*)pInformationBuffer, ulInformationBufferLength % ETHER_LENGTH_OF_ADDRESS);
+ StatusToReturn = SetMulticastAddressList(pAdapter, (unsigned char*)pInformationBuffer, ulInformationBufferLength / ETHER_LENGTH_OF_ADDRESS);
break;
case OID_GEN_CURRENT_PACKET_FILTER:
It's just replacing the modulo with a division inside the function "NetXEthSetInformation" when handling "OID_802_3_MULTICAST_LIST" ;)
It should look like this:
case OID_802_3_MULTICAST_LIST:
//
// Verify length
//
if((ulInformationBufferLength % ETHER_LENGTH_OF_ADDRESS) != 0)
{
StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
*pulBytesRead = 0;
*pulBytesNeeded = 0;
break;
}
StatusToReturn = SetMulticastAddressList(pAdapter,
(unsigned char*)pInformationBuffer,
ulInformationBufferLength / ETHER_LENGTH_OF_ADDRESS);
Could you try, if it's working now on your side, and post your results here?
Regards
MT
I have made that change and it seems to be workin ok now. I am recieving multicasts in a .Net application on a release build.
Thanks for the help that seems to have resolved the problem. I still need to do some further investigation but I am recieving multicasts to group 224.0.0.4 on port 10002.
Seems to be a good fix, Thanks alot MT.
M T
Hilscher Gesellschaft für Systemautomation mbH
I haven't used Multicast UDP on Windows CE yet, but I have not yet heard of any problem either.
IGMP is a protocol above the ethernet layer, so the only dependency on the NIC itself is the feature to allow multicast frames to be passed to the upper layer. This feature is included in the ethernet microcode of the netX and is also implemented in the NDIS driver. So basically it should work (if IGMP does not need any other special OIDs besides OID_802_3_MULTICAST_LIST).
I assume you have the BSP, so you should be able to see, if the upper layer is calling the Function "NetXEthSetInformation" with the OID "OID_802_3_MULTICAST_LIST". If this is not the case, multicast packets will not be routed to upper layers, and are dropped.
Another possibilty is to enable Promiscious/Monitoring mode to see if the packets are arriving.
Regards
MT