Hot!TCP/IP Address issue

Author
Kaws
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2017/07/16 13:12:08
  • Location: 0
  • Status: offline
2017/12/05 08:53:05 (permalink)
0

TCP/IP Address issue

Hello Guys,
 
I've got problem with my harmony based application. Everything worked fine while debugging, but now it's time to connect it to real network. I got dedicated IP, which is 192.168.164.4. It can be obtained by DHCP.
After tuning on device stay unavailable. After some experiments I figured out, that it can't work with IP addresses greater than 192.168.0.254. No matter is it set manually as static address, or it's given by DHCP. Device just does not respond.
Could anyone tell me, what can cause problem like that?
 
My setup:
PIC32MX795F512L
MPLABX v4.01
Harmony 1.11, later updated to 2.04 (nothing changed)
XC32 1.44
 
Harmony configuration screenshots attached
 
 
post edited by Kaws - 2017/12/11 16:21:15

Attached Image(s)

#1

19 Replies Related Threads

    concertinaman
    Bug Sorter
    • Total Posts : 230
    • Reward points : 0
    • Joined: 2007/06/14 05:56:58
    • Location: UK
    • Status: offline
    Re: TCP/IP Address issue 2017/12/05 09:03:56 (permalink)
    5 (1)
    Your subnet mask is 255.255.255.0
    That puts 192.168.164.4 on a different subnet to 192.168.1.xxx
    #2
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/05 09:19:56 (permalink)
    0
    This data are not really important, my program replaces it on startup with custom ones from NVM or "factory default", defined before this function call. And if DHCP enabled- it's just DHCP, so everything should work.
    void setNetwork(){
        TCPIP_NET_HANDLE netH = TCPIP_STACK_IndexToNet(0);
        
        if(networkInitDone == 1 || nvmData.DHCP){
            networkInitDone = 1;
            return;
        }
        
        if(!TCPIP_STACK_NetIsReady(netH)){
            return;
        }
        
        TCPIP_STACK_NetAddressSet(netH, &nvmData.IPs[0], &nvmData.IPs[2], true);
        TCPIP_STACK_NetAddressGatewaySet(netH, &nvmData.IPs[1]);
        TCPIP_STACK_NetAddressDnsPrimarySet(netH, &nvmData.IPs[3]);
        TCPIP_STACK_NetAddressDnsSecondSet(netH, &nvmData.IPs[4]);
        
        networkInitDone = 1;
    }

     
     
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 15134
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: TCP/IP Address issue 2017/12/05 10:20:07 (permalink)
    0
    Then what is you REAL Subnet Mask?  The one the Driver is actually using?
    #4
    rainad
    Moderator
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/05 10:23:32 (permalink)
    5 (3)
    This is not the right way to change the network settings for an interface.
    Recover your parameters from storage (IP addresses, GW, etc.), update the TCPIP_NETWORK_CONFIG data structure and then call TCPIP_STACK_Initialize() to start with the right parameters.
    Alternatively, turn down the interface - TCPIP_STACK_NetDown() - update the parameters and then call TCPIP_STACK_NetUp().
     
    #5
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/07 08:39:17 (permalink)
    0
    By the our network policy- devices should use DHCP configuration, so I was provided only with IP address, just to access device and know where it is. So I should not really care about parameters, isn't it? But looks like real subnet mask should be 255.255.252.0
    About configuration changes- thank you, I will correct my code, but even now it works good with "propper" addresses, both on startup and on-the-fly by user configuration (from web form).
    Can't really say which addresses are obtained by the board, tried to debug it this way:
    Shows 0.0.0.0 both on IP address and Mask. But it's not actually true, because device getting address, it's just not responding.
    post edited by Kaws - 2017/12/07 08:41:00

    Attached Image(s)

    #6
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 03:38:46 (permalink)
    0
    Got some more info on problem. Looks like PHY part and MAC driver runs fine, cause after turning on ICMPv4 Server I'm getting response to PING. So Adresses are fine and DHCP works OK. It's all HTTP server fault.
    Any suggestions?

    Attached Image(s)

    #7
    rainad
    Moderator
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 10:28:58 (permalink)
    0
    So, if the board if alive and well on the network and the addresses are fine, what is the problem with HTTP?
    Have you tried a known Web page first to see if that works OK?
    Or simply connect with a client socket (not a browser) to the server and let us know what the response is.
     
    #8
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 10:41:02 (permalink)
    0
    Yes, sure. I tested app itself and it works great. But only if board has address lower then 192.168.0.254
    No matter if it set manually or obtained from DHCP.
     
    Socket connection also failed, time out

    Attached Image(s)

    #9
    NKurzman
    A Guy on the Net
    • Total Posts : 15134
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: TCP/IP Address issue 2017/12/11 10:57:43 (permalink)
    0
    Do you understand what the subnet mask does?
    #10
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 11:14:03 (permalink)
    0
    I have a common understanding of what it does. But again- should I really care about it if I have the DHCP server, which provides my board with all the right parameters?
    And I can get ping responds, that means that network part works right, am I right?
    So the problem is about http server.
     
    #11
    rainad
    Moderator
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 16:03:46 (permalink)
    0
    If the board works fine, it has proper IP address and you can ping it, etc., let me ask:
    - what HTTP module do you use for your app?
     
    Can you show us a copy of your system_config.h?
     
     
    #12
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 16:19:28 (permalink)
    0
    I'm using regular http server configured by harmony with web app compressed by MPFS2 and stored on NVM. There are also some callbacks in custom_http_app.
    Please find system_config.h attached.
    The most wired thing- is that event if I connect board directly to PC it works same way. 
    To finally clarify IP configuration situation, I'll give an example:
     
    PC config:
    IP: 192.168.0.5
    Mask: 255.255.255.0
    GW: 192.168.0.10
    Board config (static IP, no DHCP)
    IP: 192.168.0.15
    Mask: 255.255.255.0
    GW: 192.168.0.10
    WORKS
     
    PC config:
    IP: 192.168.0.5
    Mask: 255.255.255.0
    GW: 192.168.0.10
    Board config (static IP, no DHCP)
    IP: 192.168.2.15
    Mask: 255.255.255.0
    GW: 192.168.0.10
    Does not work :(
     
    Same with DHCP, works only if given address is "less" than 192.168.0.254, even 192.168.0.255 makes controller unreachable.
    post edited by Kaws - 2017/12/11 16:30:39
    #13
    NKurzman
    A Guy on the Net
    • Total Posts : 15134
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: TCP/IP Address issue 2017/12/11 16:30:18 (permalink)
    0
    If your IP address is 192.168.0.254 and your SubNet is 255.255.255.0 then it will only respond to IP address that are 192.168.0.XXX  if you want to talk to 192.168.1.XXX then your Subnet mask Must be something like 255.255.0.0  (or 255.255.254.0)  What Subnet Mask is the DHCP Server giving you?
    #14
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 16:34:31 (permalink)
    0
    Ok, I'll try to play a bit with mask tomorrow. Not sure about given subnet, I can't see it with debug tools, I only see 0.0.0.0 as I mentioned before. I'll ask our system administrator about it and will reply back. Maybe you right and that's the problem, but all PC's in network powered by DHCP, so I'm pretty sure that it's ok, and event more strange- that I can ping it but can not access http server...
     
    #15
    rainad
    Moderator
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 16:51:08 (permalink)
    0
    Kaws
    Board config (static IP, no DHCP)
    IP: 192.168.2.15
    Mask: 255.255.255.0
    GW: 192.168.0.10
    Does not work :(

     
    The gateway address is in a different network than the board address. Of course it won't work.
    Put a valid gateway address in there at least if you want to test the static mode.
    Maybe you don't want to use a gateway, sure, but the stack may still need a valid address.
    But you said that the DHCP is working. Please give the settings that you get from the DHCP, those should be correct.
     
     
    #16
    mrpackethead
    packet mangler
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/11 19:48:13 (permalink)
    0
    rainad, whats the behavior of the harmony stack if you do set up this config [ note everyone: dont' do what is below its not a good idea.  ]    will it just drop the outbound packet before it gets sent?  there is really a routing table is there?
     
     
    rainad
    Kaws
    Board config (static IP, no DHCP)
    IP: 192.168.2.15
    Mask: 255.255.255.0
    GW: 192.168.0.10
    Does not work :(

     
    The gateway address is in a different network than the board address. Of course it won't work.
    Put a valid gateway address in there at least if you want to test the static mode.
    Maybe you don't want to use a gateway, sure, but the stack may still need a valid address.
    But you said that the DHCP is working. Please give the settings that you get from the DHCP, those should be correct.
     
     




    #17
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/12 04:48:51 (permalink)
    0
    Ok, I made it to work with 192.168.164.4 on my local setup by setting PC address to 192.168.164.15
    It's ok, you guys were absolutely right.
    And I also got IP's from the board, here they are:
    IP: 192.168.164.4
    Mask: 255.255.255.0
    GW: 192.168.100.1

    So it seems like our system administrator's fault...
    I'll ask and reply back.
    #18
    Kaws
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2017/07/16 13:12:08
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/12 08:24:20 (permalink)
    0
    Problem solved...
    Network firewall blocked port 80
    I'm so sorry about disturbing you guys, and thank you very much!
    #19
    mrpackethead
    packet mangler
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: TCP/IP Address issue 2017/12/12 12:39:25 (permalink)
    0
    Kaws,  a few things that you might do that could really help you, when developing IP solutions;
     
    Its really helpful to have a secondary NIC in the machine that you are working on.  Attch this to a 'mirror' port on an ethernet switch,  and mirror the in/out data of the device ( also connected to the same switch ).. this lets you see all the packets coming in/out,   use wireshark..  This can save you a LOT of guess work.  In your case you coudl have seen the DHCP packets, seen that they were not appropriate and sorted somethign out.
     
    #20
    Jump to:
    © 2017 APG vNext Commercial Version 4.5