Sending IPv6 packets

Discussion to talk about software related topics only.
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Sending IPv6 packets

Post by SeeCwriter »

I'm using v2.8.7. In the code below, my app calls UdpBroadcast() twice a second. Using wireshark I see the IPv4 packets, but no IPv6 packets. Did I do this correctly?

Code: Select all

IPADDR4 BroadcastIP  = IPADDR4::GlobalBroadCast();
IPADDR6 BroadcastIP6 = IPADDR6::AsciiToIp6( "ff02::1" );

void UdpBroadcast()
{
  // If not connected to a network, bail...
  if ( !EtherLink() ) return;

  int len = UdpFormatStatusString( BroadcastPkt.data );
  
  UdpSend( BroadcastPkt.data, len, BroadcastIP, BroadcastPkt.port );
  
  UdpSend( BroadcastPkt.data, len, BroadcastIP6, BroadcastPkt.port ); 
}

void UdpSend( char *buf, int len, IPADDR6 &ip, WORD port )
{
  UDPPacket pkt(true);
  pkt.SetDestinationPort(port);
  pkt.SetSourcePort(port);
  pkt.AddData((BYTE *)buf, (WORD) len);  
  pkt.Send(ip);
}

void UdpSend( char *buf, int len, IPADDR4 &ip, WORD port ) 
{
  UDPPacket pkt;       
  pkt.SetDestinationPort(port);
  pkt.SetSourcePort(port);
  pkt.AddData((BYTE *)buf, (WORD) len);  
  pkt.Send4(ip);
}
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Sending IPv6 packets

Post by pbreed »

Yes you did this correctly....

Is IPV6 turned on for your PC?
I've found that modern PC NIC cards are very aggressive in throwing away packets before wireshark ever sees them.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Sending IPv6 packets

Post by pbreed »

I'd also try ...
nburn\pctools\find\python\find6.py..>

A Python program that should find all netburners running IPV6 code on your network...
(Requires that IPV6 be turned on for your PC)
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Sending IPv6 packets

Post by SeeCwriter »

I checked my PC, and it says that IPv6 is enabled. It only has a link-local address, which shouldn't be problem. As an aside, the netmask on the end of an IPv6 address that I normally see as a forward slash and a number (/64), is shown as a percent sign and a number in my PC. i.e. %64. Is that new or that Windows specific?

I ran the python script and it found the NB module. Then could it be that the module is in fact transmitting the ipv6 packets, and that this is either a wireshark issue or a PC issue? Wireshark does see lots of IPv6 packets flying around, it's just that none are from the NB module (MOD5441X). I added a filter to wireshark to look for ipv6 addresses with a ff02 prefix, and I get nothing.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Sending IPv6 packets

Post by pbreed »

Does wireshark see the python find6 packets?

It sends out a multicast and should be receiving a unicast response...


The IPV6 version of Arp is called neighbor discovery...

On the NetBurner try...
#include <ipv6/ipv6_diag.h>
ShowAllV6Info();

You should see your PC as a neighbor...

Paul
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Sending IPv6 packets

Post by SeeCwriter »

Here's the output of ShowAllV6Info:

Code: Select all

Show All IPv6 Info:
Info for interface number 1
Container     Prefixes has:
IP is :fe80::203:f4ff:fe09:7eeb:eTenative         Valid:1 OnLink:1 Time-1
End of     Prefixes
Container Destinations is Empty
Container    Neighbors is Empty
Container      Routers is Empty
Container      DnsList is Empty
Container  DHCPServers is Empty
DHCP Client: 0x0IPV6_Frame_RX:        0
IPV6_Frame_RX_ICMP:   0
IPV6_Frame_RX_UDP:    0
IPV6_Frame_RX_TCP:    0
IPV6_Frame_RX_Frag:   0
IPV6_Frame_RX_Discard:0
IPV6_Frame_TX_Frag:   0
IPV6_Frame_TX:        8
IPV6_Ticks:           8
-------------------------

Inteface 1 MAC:00:03:f4:09:7e:eb
IPv4 Addresses:
IP:      10.250.5.102
Mask:    255.255.255.0
DNS:     10.250.4.229
Gateway: 10.250.5.1
fe80::203:f4ff:fe09:7eeb/64 :Link Local
O2 A.FH
Startup complete, [0 sec]
I ran the python script and captured the traffic with wireshark. And yes, the PC sends a UDP packet to "ff02:4e42", port 20034, and the module responds to the PC with a packet of what wireshark calls a "Neighbor Solicitation", and the PC then issues it's own "Neighbor Solicitation".
I attached a screen shot of wireshark.
NeighborSolicitation.docx
(203.67 KiB) Downloaded 179 times
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Sending IPv6 packets

Post by pbreed »

It looks like none of the IPV6 time based stuff is running...
Strange, no neighbors at all..
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Sending IPv6 packets

Post by SeeCwriter »

The problem with the printout is that it was happening right after Ethernet initialization. So recalling a comment in one of the IPv6 files that this can take a long time, I put ShowAllIPv6Info on a timer and called it every 10-seconds. After the 3rd call (30-seconds) after boot-up I get this:

Code: Select all

Show All IPv6 Info:
Info for interface number 1
Container     Prefixes has:
IP is :fe80::203:f4ff:fe09:7eeb:eValid_Preferred  Valid:1 OnLink:1 Time-1
End of     Prefixes
Container Destinations has:
Destination [1500]:fe80::b4f3:189:71e9:3b56 First Hop:fe80::b4f3:189:71e9:3b56
Destination [1500]::: First Hop:Null
End of Destinations
Container    Neighbors has:
N:fe80::b4f3:189:71e9:3b56 mac:d4:be:d9:19:d2:21:eReachable  Action[0] in 100  R
outer:     0x0  P[0]:     0x0
End of    Neighbors
Container      Routers is Empty
Container      DnsList is Empty
Container  DHCPServers is Empty
DHCP Client: 0x0IPV6_Frame_RX:        3
IPV6_Frame_RX_ICMP:   2
IPV6_Frame_RX_UDP:    1
IPV6_Frame_RX_TCP:    0
IPV6_Frame_RX_Frag:   0
IPV6_Frame_RX_Discard:0
IPV6_Frame_TX_Frag:   0
IPV6_Frame_TX:        144
IPV6_Ticks:           403
-------------------------

Inteface 1 MAC:00:03:f4:09:7e:eb
IPv4 Addresses:
IP:      10.250.5.102
Mask:    255.255.255.0
DNS:     10.250.4.229
Gateway: 10.250.5.1
fe80::203:f4ff:fe09:7eeb/64 :Link Local
But I still don't see any of the IPv6 packets from the module it's supposed to be sending to ff02::01 on wireshark.
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Sending IPv6 packets

Post by SeeCwriter »

I'm beginning to think that the issue is with wireshark. Wireshark is now not capturing IPv4 broadcast UDP packets from the NB module, but I have another utility that we wrote to display UDP traffic to our equipment and it shows the traffic. So I know the IPv4 packets are working.

I was trying different things regarding the way IPv6 UDP packets are sent, and wireshark flagged all the packets as malformed. This is what I tried. It's not obvious to me what's wrong.

Code: Select all

IPADDR6 BroadcastIP;  
BroadcastIP.SetFromIP4( IPADDR4::GlobalBroadCast() );

void UdpBroadcast()
{
  // If not connected to a network, bail...
  if ( !EtherLink() ) return;

  int len = UdpFormatStatusString( BroadcastPkt.data );

  UdpSend( BroadcastPkt.data, len, BroadcastIP,  BroadcastPkt.port );
   
}

void UdpSend( char *buf, int len, IPADDR6 &ip, WORD port )
{
  UDPPacket pkt(true);
  pkt.SetDestinationPort(port);
  pkt.SetSourcePort(port);
  pkt.AddData((BYTE *)buf, (WORD) len);
  if ( ip.IsEmbeddedIPV4() )
     pkt.Send4( ip.Extract4() ); 
  else 
     pkt.Send( ip );  
  
}
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Sending IPv6 packets

Post by SeeCwriter »

Using example program IPv6-DHCPv6, I added a function to send a UDP packet when "Any Key" is hit. I tried using addresses "ff02::1" and "ff02::4e40". In both cases, wireshark does not capture any traffic to those addresses. It also doesn't capture the Module's IP address sending anything to those addresses. When I run the python discovery script, wireshark does capture that transaction. I'm at a loss as to why.

Code: Select all

void UdpSend( char *buf, int len, IPADDR6 &ip, WORD port )
{
  UDPPacket pkt(true);
  pkt.SetDestinationPort(port);
  pkt.SetSourcePort(port);
  pkt.AddData((BYTE *)buf, (WORD) len);  
  pkt.Send(ip);
}


void UserMain( void * pd )
{
    initWithWeb();
    char buf[] = { "Hello World" };

    IPADDR6 ip6adr = IPADDR6::AsciiToIp6( "ff02::4e40" );
    
    siprintf(DHCPNameBuffer,
            "%s_%s_%02X%02X%02X",
            "NB",
            PlatformName,
            gConfigRec.mac_address[3],
            gConfigRec.mac_address[4],
            gConfigRec.mac_address[5]
            );
    iprintf("OfferName: %s\n", DHCPNameBuffer);
    pDHCPOfferName = DHCPNameBuffer;

    // set our callbacks
    NB::V6::DHCPv6::pAddOROCB = AddORO;
    NB::V6::DHCPv6::pRequestOptionCB = AddSendOption;
    NB::V6::DHCPv6::pReplyCB = GetReply;

    EnableSmartTraps();

    iprintf("Application: %s\r\nNNDK Revision: %s\r\n",AppName,GetReleaseTag());
    while(1) {
        showIpAddresses();
        iprintf("\r\nType any key to display address information\r\n");
        iprintf("Note that routable addresses may take a few second to receive\r\n");
        getchar();
        iprintf("\r\n\r\n");
        puts("Sending...");
        UdpSend(buf, (int) strlen(buf), ip6adr, 2100);
        puts("Done.");
    }
}
I'm using v2.8.7 of the tools with a MOD5441X.
Post Reply