• AVR Freaks

Hot!DHCPv6 configurations in MHC

Page: 123 > Showing page 1 of 3
Author
anuragjk
Starting Member
  • Total Posts : 41
  • Reward points : 0
  • Joined: 2018/12/11 23:59:45
  • Location: 0
  • Status: offline
2019/05/03 00:24:03 (permalink)
0

DHCPv6 configurations in MHC

Hey forum,
I was trying to get DHCPv6 working in my micro (PIC32MZ2048EFH064), I read the "TCPIP Stack Libraries Help" pdf and it says the following in the DHCPv6 section,
"All of the required files listed in the following table are automatically added into the MPLAB X IDE project by the MHC when the library is selected for use."

But i couldn't find any settings related to DHCPv6 in my MHC.
I tried to manually enable TCPIP_STACK_USE_DHCPV6_CLIENT but then the stack fails to initialize.



Versions:
Harmony v2.04
MPLAB X IDE v4.01
#1

50 Replies Related Threads

    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/03 09:48:22 (permalink)
    3 (1)
    DHCPv6 is not yet supported by the MHC. Unfortunately that's an error in the documentation.
    Thanks for pointing it out, it will be corrected for the coming revisions.
    Until DHCPv6 is added to the MHC you need to add it manually:
    - enable the TCPIP_STACK_USE_DHCPV6_CLIENT in your system_config.h (you should also have the TCPIP_STACK_USE_IPV6 defined)
    - provide a TCPIP_DHCPV6_MODULE_CONFIG data structure in the system_init.c and add it to the existent TCPIP_STACK_MODULE_CONFIG_TBL
    - you can use default values for all data in TCPIP_DHCPV6_MODULE_CONFIG. Take a look in the framework/config/dhcpv6_config.h for all the values and their defaults.
     
    #2
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/03 21:58:05 (permalink)
    0
    Hey Rainad,
    Thank-you very much for the reply, I'll try this out.
    #3
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/06 04:30:11 (permalink)
    0
    Rainad,
    I've did the following changes in my code.
    added following in system_config.h :

    #define TCPIP_STACK_USE_IPV6
    #define TCPIP_STACK_USE_DHCPV6_CLIENT


    added following in system_init.c :


    const TCPIP_DHCPV6_MODULE_CONFIG dhcpv6Data =
    {
    .configFlags = 0x01,
    .dhcpCliPort = 546,
    .dhcpSrvPort = 547,
    .duidType = 3,
    .nIanaDcpts = 4,
    .nIataDcpts = 2,
    .nFreeDcpts = 2,
    .defaultIanaT1 = 0,
    .defaultIanaT2 = 0,
    .defaultIataT1 = 0,
    .defaultIataT2 = 0,
    .ianaSolicitT1 = 0,
    .ianaSolicitT2 = 0,
    .solicitPrefLTime = 0,
    .solicitValidLTime = 0,
    .nMsgBuffers = 8,
    .msgBufferSize = 512,
    };

     

    const TCPIP_STACK_MODULE_CONFIG TCPIP_STACK_MODULE_CONFIG_TBL [] =
    {
    {TCPIP_MODULE_IPV4, 0},
    {TCPIP_MODULE_ARP, &tcpipARPInitData}, // TCPIP_MODULE_ARP
    {TCPIP_MODULE_IPV6, &tcpipIPv6InitData}, // TCPIP_MODULE_IPV6
    {TCPIP_MODULE_ICMPV6, 0}, // TCPIP_MODULE_ICMPV6
    {TCPIP_MODULE_NDP, 0}, // TCPIP_MODULE_NDP
    {TCPIP_MODULE_UDP, &tcpipUDPInitData}, // TCPIP_MODULE_UDP
    {TCPIP_MODULE_TCP, &tcpipTCPInitData}, // TCPIP_MODULE_TCP
    {TCPIP_MODULE_DHCP_CLIENT, &tcpipDHCPInitData}, // TCPIP_MODULE_DHCP_CLIENT
    {TCPIP_MODULE_ANNOUNCE, &tcpipAnnounceInitData}, // TCPIP_MODULE_ANNOUNCE
    {TCPIP_MODULE_DNS_CLIENT, &tcpipDNSClientInitData}, // TCPIP_MODULE_DNS_CLIENT
    {TCPIP_MODULE_NBNS, &tcpipNBNSInitData}, // TCPIP_MODULE_NBNS
    {TCPIP_MODULE_SNTP, &tcpipSNTPInitData}, // TCPIP_MODULE_SNTP
    {TCPIP_MODULE_HTTP_SERVER, &tcpipHTTPInitData}, // TCPIP_MODULE_HTTP_SERVER
    { TCPIP_MODULE_MANAGER, &tcpipHeapConfig }, // TCPIP_MODULE_MANAGER
    // MAC modules
    {TCPIP_MODULE_MAC_PIC32INT, &tcpipMACPIC32INTInitData}, // TCPIP_MODULE_MAC_PIC32INT
    {TCPIP_MODULE_DHCPV6_CLIENT, &dhcpv6Data} // DHCPv6 client added by Anurag
    };

    I also added dhcpv6.c to the project as it was not already done.
    Still I'm not getting the dynamic ipv6 address for my micro.
    I was using an iBall Baton router which is already providing dynamic ipv6 to my PC,
    Also I'm using tcpip discoverer to check for IP


    Anurag
    #4
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/07 06:36:14 (permalink)
    0
    Try to enable the DHCPv6 debug and you'll get messages to the console:
    in the dhcpv6_private.h
    #define TCPIP_DHCPV6_DEBUG_LEVEL (0x1f)
    Also monitor the traffic with wireshark, do you see any DHCP transactions, maybe that will give a clue as to what's happening.
     
    #5
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/09 00:25:32 (permalink)
    0
    Hello Rainad,
    I enabled Debug as you instructed, but it was giving out garbage data on my console.
    I'm attaching all the screenshots and the wireshark data along with this post
    Also i give you a brief discription of how I wired everything if its of any importance,
    My Win7 PC is connected to the router via wlan and the starter kit is connected to router via ethernet cable (no internet).
    I couldn't get debug to work with teraterm in my Win7 PC so I used minicom in my laptop to get that data (at 115200 buad)

    Mac address of starter kit is d8:80:39:75:a9:f3

    Attached Image(s)

    #6
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/10 14:13:08 (permalink)
    0
    I see only one DHCPv6 transaction and the server reply in the log that you sent. But that's not the host d8:80:39:...that you mention.
    So probably the DHCPv6 module is not running?
    Set a breakpoint in the DHCPv6 Task routine and see if it executes and if advances the states - if it tries to do something useful.
     
    That was the purpose of enabling those debug messages...
    But you need to fix the console issue. This garbage on the console happens only when enabling the DHCPv6 debug, otherwise everything is OK?
    If so, maybe the terminal is confused by some weird character that's sent by the board.
    Try saving the data into a file and we can look in that serial log, maybe it makes more sense.
    Teraterm should work, never had issues with it, maybe you can retry it.
     
     
     
     
    #7
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/13 03:41:26 (permalink)
    0
    Hey Rainad,
    I was able to get the console message once I changed all occurrences of SYS_CONSOLE_MESSAGE() to SYS_CONSOLE_PRINT() in dhcpv6.c
    I got the following data in the first few minute:
     
     

    TCP/IP Stack: Initialization Started
    SYS_Initialize: The MPFS2 File System is mounted
    TCP/IP Stack: Initialization Ended - success
    Interface PIC32INT on host MCHPBOARD_E - NBNS enabled
    PIC32INT IP Address: 0.0.0.0

    >DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    PIC32INT IP Address: 192.168.100.115
    PIC32INT IP Address: 192.168.1.150
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d888, type: 1, IA ix: 3, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000daa0, type: 1, IA ix: 4, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d240, type: 1, IA ix: 0, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d458, type: 1, IA ix: 1, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000d670, type: 1, IA ix: 2, state: 0, passed
    DHCPV6 task: Transmit, Msg: 0xa000dcb8, type: 1, IA ix: 5, state: 0, passed
     

    #8
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/13 07:06:26 (permalink)
    0
    That's a good start to understand what the problem is.
    These messages show that the board transmits the DHCPv6 messages.
    However, it seem that there's no reply coming from the server.
    Please look again with wireshark: do you see these messages coming out of your board?
    If so, is there any reply to them?
    Let's see what we can find.
     
     
    #9
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/14 05:35:43 (permalink)
    0
    Hey Rainad,
    I did the wireshark capture again but didnt find any dhcpv6 packets from the micro,
    but then I thought like the communication is happenning between micro and the router and so far the wireshark is showing the communications which involves PC only.
    so I connected the micro directly to PC and captured the wireshark data which shows dhcpv6 packets originating from the micro (attcahment**). 
    But this way I wont be able to capture the response from the router if there is any. 
    Maybe I'm doing the capturing part wrong, please tell me the right way to use wireshark in this scenario.

    Nb: I've used eth.addr == d8:80:39:75:a9:f3 to filter only packets from micro.
    **Forum is giving me permission denied while replying, so doing a quick reply and file is shared via Gdrive.
    https://drive.google.com/file/d/10QNeF4Xi_hjs-LZS4S4oesh0pf0sOHbY/view?usp=sharing
    post edited by anuragjk - 2019/05/14 05:37:55
    #10
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/14 06:26:36 (permalink)
    0
    You need to capture the traffic between the PIC32 board and the router.
    Use a switch with a mirroring port. Or a packet sniffer inserted on that network segment.
     
    #11
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/15 04:24:54 (permalink)
    0
    Hey Rainad,
    I captured communication between the PIC32 board and router by connecting an extra Ethernet port and bridging the two interfaces (one is connected to router and other to PIC32 board) the captured packets are attached.
    Nb: MAC of router is 00:1e:a6:d8:2a:03
    #12
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/15 11:40:29 (permalink)
    0
    Now I see some responses from the server.
    But I don't understand why the PIC32 sends so many DHCPv6 packets in a burst, and doesn't seem to receive any of the server's replies.
    Can you ping a link local IPv6 address and see if that works?
    Even without starting the DHCPv6.
     
     
    #13
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/15 22:45:17 (permalink)
    0
    I checked the ping to link local address [fe80::da80:39ff:fe75:a9f3] both with and without TCPIP_STACK_USE_DHCPV6_CLIENT and got response in both cases. 
    ICMPv6 server is enabled in harmony by default.
    #14
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/16 03:25:55 (permalink)
    0
    There are some other things I observed:
    The function SYS_CONSOL_MESSAGE() is working normally when used in app.c but gives out garbage data when used in the debug function _DHCPV6DbgMsgOut_PrintPassed()
    Also when I tried debugging, control is never reaching the main while loop in _DHCPV6Client_ReceiveTask(), as the TCPIP_UDP_GetIsReady() is returning NULL. So the client receive task returns without doing anything.
    #15
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/16 06:57:06 (permalink)
    0
    Your test shows us that the IPv6 is working at least.
    Why the IPv6 traffic is not forwarded to the UDP and then to DHCP is not clear. Something is missing in your set up or not properly configured.
    Would it be possible to set a breakpoint in the UDP module: TCPIP_UDP_Process() function, on the line where the TCPIP_UDP_ProcessIPv6() is called?
    First to see if the execution gets there and then going into the TCPIP_UDP_ProcessIPv6(), see why the packet is discarded.
    Sorry about this low level debugging, but I cannot think of other way to understand what's going on.
     
    The DHCPv6 messages not showing up properly to the console is because of the sprintf() used in those functions.
    You can try to see if the behavior is better if you replace the sprintf with a SYS_CONSOLE_PRINT(...).
    But the UDP problem is more important to solve.
     
    P.S. Switching from the usage of SYS_CONSOLE_MESSAGE to SYS_CONSOLE_PRINT will work better.
    Simply replace SYS_CONSOLE_MESSAGE(dhcpBuff); with SYS_CONSOLE_PRINT("%s", dhcpBuff);
     
     
    post edited by rainad - 2019/05/16 07:18:28
    #16
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/16 08:32:52 (permalink)
    0
    "Would it be possible to set a breakpoint in the UDP module: TCPIP_UDP_Process() function, on the line where the TCPIP_UDP_ProcessIPv6() is called?"
    I did as you told, and found that the execution is reaching TCPIP_UDP_Process() but never reaching TCPIP_UDP_ProcessIPv6(). 
    "Sorry about this low level debugging, but I cannot think of other way to understand what's going on."
    Don't be sorry, I'm grateful for your help.  :)
    "P.S. Switching from the usage of SYS_CONSOLE_MESSAGE to SYS_CONSOLE_PRINT will work better.
    Simply replace SYS_CONSOLE_MESSAGE(dhcpBuff); with SYS_CONSOLE_PRINT("%s", dhcpBuff);"
    I already did that.
    #17
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/16 09:55:29 (permalink)
    0
    Then set a breakpoint in ipv6.c::TCPIP_IPV6_Process() function, on the big switch:
    case IPV6_PROT_UDP:
    and try to see why that frame is never forwarded to UDP. The _TCPIPStackModuleRxInsert(TCPIP_MODULE_UDP, pRxPkt, true) should be called.
     
     
    #18
    anuragjk
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2018/12/11 23:59:45
    • Location: 0
    • Status: offline
    Re: DHCPv6 configurations in MHC 2019/05/17 02:30:43 (permalink)
    0
    Hey Rainad,
    TCPIP_IPV6_Process() is not always executed, and when its executed it didn't reach the switch case. It returned at the else shown below,

    if (localAddressPointer == NULL)
    {
         // If we didn't find a matching configured address try to find one in the tentative address list
        if ((localAddressPointer = TCPIP_IPV6_AddressFind (pNetIf, constLocalIPv6Addr, IPV6_ADDR_TYPE_UNICAST_TENTATIVE)) != NULL)
        {
            addrType = IPV6_ADDR_TYPE_UNICAST_TENTATIVE;
        }
        else
        {
            TCPIP_PKT_PacketAcknowledge(pRxPkt, TCPIP_MAC_PKT_ACK_PROTO_DEST_ERR); 
            return;
        }
    }

    #19
    rainad
    Moderator
    • Total Posts : 1176
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: online
    Re: DHCPv6 configurations in MHC 2019/05/17 10:05:24 (permalink)
    0
    Can you please add the TCPIP_DHCPV6_FLAG_DAD_DISABLE (i.e. 0x02) to the configFlags?
    Maybe there's some wrong setting/timeout in there that removes the DHCP address from the lists.
     
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5