This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use NDK to get the remote MAC?

Other Parts Discussed in Thread: SYSBIOS

Hi all ,

Did NDK get remote MAC while remote host issue a udp request ? I try to dump the arp static table while the udp packet proccessing .

I find that there is no arp entry in the table . see code

linux seems to have the function that add a arp entry when it receives a request . Can NDK do that ? Because I need to query the remote mac on arp table or there is any other way to get remote MAC?

Brenden

  • Brenden,

    You want to examine the dynamic ARP table, not the static table. There is not a direct function to obtain a MAC address for an IP address, but you can see an example of how to do it in the console example application. See the DumpRouteTable() function in the tools/console/conroute.c source file. You could refactor this function to do what you need.

    Mark

  • Mark , 

            I try use DumpRouteTable() to dig out how to get remote mac ! But fail ! I can not get mac neither remote nor local mac!

            Because of  RtGetLLI return  0 and  LLIGetMacAddr failed ! See below code 2047.empty.c

    if( !(hLLI = RtGetLLI( hRt )) || !LLIGetMacAddr( hLLI, MacAddr, 6 ) )
       llExit(); // can't get hLLI object , so  always there
    else
    {
    llExit();
    System_printf( " %02X:%02X:%02X:%02X:%02X:%02X",
    MacAddr[0], MacAddr[1], MacAddr[2],
    MacAddr[3], MacAddr[4], MacAddr[5] );
    }

    The DumpRouteTable function seems to just can get routing entry not the arp entry !

    Is there any other way to get arp entry?

    Brenden

  • Brenden,

    When I tried using this code, I made the mistake of not defining a critical pre-processor symbol when compiling which led to bad results. Make sure you have -D_INCLUDE_NIMU_CODE defined for the compiler. When I do this, I get (as an example):

    Address Subnet Mask Flags Gateway
    --------------- --------------- ------ -----------------
    0.0.0.0 0.0.0.0 UG xxx.252.160.1
    xxx.252.160.0 255.255.254.0 U C if-1
    xxx.252.161.26 255.255.255.255 U H L local (if-1)
    xxx.252.161.51 255.255.255.255 U H D4:BE:D9:03:11:B3

    Mark

  • Thanks Mark, 

           I'll follow your advice.

    Brenden

  • Hi Mark, 

              I am sure the orignal  NDK already include nimu relate function . I can see nimu relate function symbol in map file (ex:0001410d NIMUPacketServiceCheck) , I can get local mac by call NIMUIoctl() also.But follow your advice I still can't get remote mac by using  LLIGetMacAddr ! It return 0 which means fail!

    Could you see my code is anything wrong ?0447.empty.c2843.empty.cfg

    I am using

    mcusdk version :1_00_00_68 

    CCS version 5.2.0.00069

    ndk version : 2_21_01_38

    sysbios version :6_33_04_39 

    xdctools version :3_23_04_60

    target board : DK_LM3S9d96


    Thank you !

    Brenden

     

  • Hi Brendan,

    Did you rebuild your app code with the compiler define that Mark mentioned, or did you rebuild the NDK? I believe you need to add this define and rebuild your code.

    Todd

  • Hi Todd , 

             I already add _INCLUDE_NIMU_CODE define , but use LLIGetMacAddr() still fail ! see pic

    Here is my project zip , Can somebody help me to point out what is going on ?http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/355/8032.NDK3.7z

    Brenden

  • Hi Brenden,

    I've attached a file that I validated with the tcpEcho example in MCUSDK. Can you add this file to your tcpEcho project and rebuild? Note: I add #define _INCLUDE_NIMU_CODE at the top of the arp.c file, so you don't need the compiler option. 

    3323.arp.c

    I call DumpRouteTable() near the top of the tcpWorker. So when you run the linux/windows tcpSendReceive tool, the DumpRouteTable is called.

    Void tcpWorker(UArg arg0, UArg arg1)
    {
    ...

        fdOpenSession(TaskSelf());
        
        DumpRouteTable();

    Here is the output I obtained

    [Cortex_M3_0] Service Status: DHCPC    : Enabled  :          : 000
    [Cortex_M3_0] Service Status: DHCPC    : Enabled  : Running  : 000
    [Cortex_M3_0] Network Added: If-1:146.252.161.13
    [Cortex_M3_0] Service Status: DHCPC    : Enabled  : Running  : 017
    [Cortex_M3_0]  
    [Cortex_M3_0] Address          Subnet Mask      Flags   Gateway
    [Cortex_M3_0] ---------------  ---------------  ------  -----------------
    [Cortex_M3_0] 0.0.0.0          0.0.0.0          UG      146.252.160.1     
    [Cortex_M3_0] 146.252.160.0    255.255.254.0    U   C   if-1
    [Cortex_M3_0] 146.252.161.13   255.255.255.255  U H  L  local (if-1)
    [Cortex_M3_0] 146.252.161.150  255.255.255.255  U H     00:1E:4F:BB:A9:66
    [Cortex_M3_0]  

    Todd

  • Thanks Todd !

    It work!