// JP opened flex table

Click to See Complete Forum and Search --> : Diagnosing an IPv6 UDP problem


ednozzle
December 6th, 2007, 01:41 PM
I fairly new to networking, and I'm trying to write up a UDP client & server using IPv6. Sadly, I seem to send out messages fine, but they do not get picked up by the server. I'm trying to nail down where my problem is. I used Wireshark to see that the packet is getting sent out, so I initially ruled out the client. However, I used netstat with the command "netstat -a -p udpv6", and it shows an entry on the port I use. So...it seems like it's sending and listening, yet somehow nothing happens. Does that mean that I didn't properly set up the port to listen to the multicast group? Could there be other points of failure?

Another noteworthy issue that may or may not be related: There's an existing IPv4 UDP system which I'm porting, but is still active in the code I'm debugging. As I understand it, that won't be a conflict. Anyway, if I run the client & server on the same machine, Wireshark sees the IPv4 message from the client, but not the IPv6 message. However, if I run the client on a different machine on the same subnet, it sees both IPv4 & IPv6.

I'd be happy to post code snippets if that's necessary, but if someone wanted to give me a bullet list of what to do where, that's be easier for me and probably faster for you.

Thanks in advance for your help!

Edit: Maybe it'd help if I gave a quick rundown of what calls I make. I'll strip out the unnecessary details.

Server:

1) getaddrinfo(null, myPort,...) using hints containing AI_PASSIVE, AF_INET6, SOCK_DGRAM & IPPROTO_UDP
2) socket() on result of #1
3) setsockopt(hSocket, SOL_SOCKET, SO_REUSEADDR...)
4) bind()
5) getaddrinfo("FF1E::FFFF", null...) no hints here
6) create a ipv6_mreq
7) set mreq's address to the result of #5, set interface to 0
8) setsockopt(...IPPROTO_IPV6, IPV6_JOIN_GROUP, mreq...)

After #8, I create an event, which would be fired upon receipt of a message, but it never happens.

Client:

1) getaddrinfo(null, myPort...) using hints containing AF_INET6 & SOCK_DGRAM
2) socket() on result of #1
3) setsockopt(hSocket, SOL_SOCKET, SO_BROADCAST...)
4) sendto()

I suspect my problem is in the server, around parts 5-8...or maybe 1. Any help or ideas would be greatly appreciated. Thanks!!

wotalota
December 6th, 2007, 04:33 PM
I just ran this little test server on another host to let me know if the packets were being received. Might help you debug.

#define SERV_PORT 1234
#define MAXLINE 1024

void dgram_loop(int, struct sockaddr *, socklen_t );

static int count;

int main(int argc, char **argv)
{
struct sockaddr_in6 servaddr, cliaddr;
int sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
int port;

if (argc == 1)
{
port = SERV_PORT;
}
else if (argc == 2)
{
port = atoi(argv[1]);
}
else
{
printf("Usage: udpsrv6 <udp-port-number>\n");
exit(1);
}
printf("Using port %d\n", port);

bzero(&servaddr, sizeof(servaddr));
servaddr.sin6_family = AF_INET6;
servaddr.sin6_addr = in6addr_any;
servaddr.sin6_port = htons(port);
bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
dgram_loop(sockfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr));
}

void dgram_loop(int sockfd, struct sockaddr *pcliaddr, socklen_t clilen)
{
socklen_t len;
//int len = (int)clilen;
char mesg[MAXLINE];
for ( ; ; ) {
recvfrom(sockfd, mesg, MAXLINE, 0, pcliaddr, &len);
count++;
printf("Reveived packet # %d\n", count);
}
}

//JP added flex table