• AVR Freaks

Hot!TCP/IP client not receiving packets above 124 bytes

Author
regh
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2020/11/26 01:37:13
  • Location: 0
  • Status: offline
2021/03/02 02:41:22 (permalink)
0

TCP/IP client not receiving packets above 124 bytes

Hi. I'm currently implementing a TCP/IP client on a PIC32 Curiosity v2 development board (PIC32MZ2048EFM144). I'm using a LAN8720 daughter board and have modified the Harmony v3 TCP client example here https://github.com/Microchip-MPLAB-Harmony/net/wiki/Create-your-first-tcpip-application, using the values for stack/heap size given in the tutorial. I'm using Socket Master to set up a TCP client on my PC and am able to send messages of 70 bytes (with the extra protocol headers this comes to 124 bytes) or less between my pc and development board (PC connected to router via wifi, PIC connected to router via ethernet).
 
My problem is that any messages over 70 bytes long don't get received by the PIC. I can see the packets being sent over the network when I check with Wireshark, and the server retries to send them several times. After a couple of seconds the server then closes the connection (I'm assuming because it didn't receive an ACK to it's message). The PIC recognises that the connection has been closed (so hasn't crashed) and then goes through the connection procedure again (which is successful).
 
Does anyone have any ideas with what could be happening here, or any suggestions of what I can look into to debug this?
Thanks for any help in advance.
#1

16 Replies Related Threads

    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/02 13:33:40 (permalink)
    0
    Make sure you have a serial console enabled on your board.
    Enable the TCP commands in MHC and then, from the console prompt try these commands and let's see the output:
    >netinfo
    >heapinfo
    >tcpinfo
    >macinfo
     
    #2
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/03 06:15:41 (permalink)
    0
    Hi Rainad
    Here's the output from those commands just after connecting to my server program, doesn't recognise tcpinfo though
     
    netinfo
    ---------- Interface <eth0/PIC32INT> ----------
    Host Name: MCHPBOARD_E - NBNS disabled
    IPv4 Address: 192.168.1.10
    Mask: 255.255.255.0
    Gateway: 192.168.1.1
    DNS: 192.168.1.1
    MAC Address: 68:27:19:d3:ab:b1
    default IP address is ON
    dhcp is enabled
    Link
    >heapinfo
    Heap type: internal. Initial created heap size: 39168 Bytes
    Allocable block heap size: 26576 Bytes
    All available heap size: 26576 Bytes, high watermark: 12592
    Last heap error: 0x0
    No Trace info exists.
    >tcpinfo
    *** Command Processor: unknown command. ***
    >macinfo
    Interface: PIC32INT Driver Statistics
    Receive Statistics
    nRxOkPackets: 95
    nRxPendBuffers: 0
    nRxSchedBuffers: 4
    nRxErrorPackets: 0
    nRxFragmentErrors: 0
    nRxBuffNotAvailable: 0
    Transmit Statistics
    nTxOkPackets: 9
    nTxPendBuffers: 0
    #3
    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/03 08:38:03 (permalink)
    0
    The TCP command needs to be enabled, as it is disabled by default.
    In configuration.h you need:
    #define TCPIP_TCP_COMMANDS   true
    and then rebuild.
     
    Before seeing what's going on with TCP, looks like you have some other issues.
    As 'netinfo' shows the DHCP is enabled but the board uses a static address.
    - Do you have a DHCP server in your network?
    - You can try a static IP address, but one that makes sense for your network.
    You first need to be able to ping the board. Are you able to do that?
    Once you got there we can check further on the TCP issue.
     
    #4
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/03 09:10:59 (permalink)
    0
    Hi Rainad
     
    Thanks for your response. I'm currently working at home so haven't set up  any dhcp server myself, I'm not sure if my router handles giving out ip addresses (I don't have to set up ip addresses on my laptop). The static address I picked was just randomly selected as I was testing that I was able to change it properly.
     
    I've tried pinging the board but it is unsuccessful, although it still connects to the server running on my laptop. I've tried pinging the router, which is successful, so my laptop seems to be able to do it ok.
    #5
    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/03 10:31:28 (permalink)
    4 (1)
    One possibility is that the ICMP server is not enabled in your demo.
    Please try to enable it and see if you can ping the board.
    Is the static IP address that you use in the same network with your PC and router?
     
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 19192
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/03 10:48:54 (permalink)
    0
    If you have an ordinary home router that works with other devices in your house, then it would have DHCP enabled.
    A static IP would need to be compatible with your network. You can look at the IP about your laptop gets from your home network.
    Typically the first three numbers must match.
    And if you choose one that’s in use by another device it won’t work.
    So choose a high number for the fourth item if you’re using static. Otherwise you probably would be better off with DHCP
    #7
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/04 02:08:54 (permalink)
    0
    ICMPv4 server is enabled in harmony and the first 3 sections of the static IP match my network. "Allow replies to broadcast requests" is disabled and ICMPv4 client is disabled.
     
    I've changed the final digit to 254 for the static IP and am now able to successfully ping the board (I've checked in wireshark and it says this is coming from a microchip device). However, it is still looks like the static ip is being used and it still won't receive large packets.
    Output from sys commands are:
    netinfo
    ---------- Interface <eth0/PIC32INT> ----------
    Host Name: MCHPBOARD_E - NBNS disabled
    IPv4 Address: 192.168.1.254
    Mask: 255.255.255.0
    Gateway: 192.168.1.1
    DNS: 192.168.1.1
    MAC Address: 68:27:19:d3:ab:b1
    default IP address is ON
    dhcp is enabled
    Lin
    >heapinfo
    Heap type: internal. Initial created heap size: 39152 Bytes
    Allocable block heap size: 26560 Bytes
    All available heap size: 26560 Bytes, high watermark: 12592
    Last heap error: 0x0
    No Trace info exists.
    >tcpinfo
    TCP sockets: 10
    sktIx: 0, addType: 1, remotePort: 100, localPort: 55374, flags: 0x01
    rxSize: 512, txSize: 513, state: 1, rxPend: 0, txPend: 0
    >macinfo
    Interface: PIC32INT Driver Statistics
    Receive Statistics
    nRxOkPackets: 102
    nRxPendBuffers: 0
    nRxSchedBuffers: 4
    nRxErrorPackets: 0
    nRxFragmentErrors: 0
    nRxBuffNotAvailable: 0
    Transmit Statistics
    nTxOkPackets: 13
    nTxPendBuffers: 0
    #8
    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/04 06:56:31 (permalink)
    0
    regh
    I've changed the final digit to 254 for the static IP and am now able to successfully ping the board ...
    However, it is still looks like the static ip is being used and it still won't receive large packets.



    Not sure what you mean by this. If you change the static IP address to something like "192.168.1.117" (an unused IP address in your network) you cannot ping the board anymore?
     
    On the TCP side, I see that you have a client socket, that's trying to connect to a remote host on port 100. And there's no reply from that machine (do you have a server listening on that PC?).
    Is this what you're trying to do?
    Initially you mentioned that the client socket was on the PC and the PIC32 was a server socket.
    Please explain.
     
     
    #9
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/04 07:08:13 (permalink)
    0
    Hi Rainad
     
    My apologies for not being clear. I have changed the static IP address of the PIC to 192.168.1.254 and now I can ping it from my laptop using "ping 192.168.1.254" on the command prompt. This was changed in harmony (the previous IP ending in 10 didn't allow me to ping it, whether this is coincidence or not I don't know). 
     
    I have a server set up on my laptop using Socket master just to do simple things like check the connection with the pic and to test sending messages between laptop and pic. The pic is the TCP client, the laptop is the server. I may have turned the server off when I did the last lot of test commands, but I have been able to connect the pic to my laptop server and send small messages from the server to the pic. However, if I try to send a message that is longer than 70 B (which I think corresponds to a TCP packet length of 124 B), the pic doesn't receive the transmission. In my code I'm using TCPIP_TCP_GetIsReady() in my ethernet state machine to check if there is anything to read, and it is always returning 0 when these larger messages are sent.
    #10
    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/05 11:32:02 (permalink)
    0
    So if you set your board IP address to something else (for example 192.168.1.117, 192.168.1.139, etc., i.e. any unused IP address in your network) then you cannot ping the board. The only time you can ping the board is when you set the address to 192.168.1.254. Is my understanding correct?
     
    Regarding the TCP connection: so your TCP client socket connects fine to the PC server, they can send each other messages as long as the server sends small messages. Is that what you see?
    - what happens after the server sends a longer message, are the sockets still connected, you can send smaller packets OK?
    - what happens if the client socket on the PIC32 side sends larger packets, those ones are received OK by the server?
     
     
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 19192
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/05 14:40:25 (permalink)
    0
    If you are having issue with the IP, what subnet mask did you set on you Board?  What is the one on the Network provided by your Router?  
    #12
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/11 02:11:47 (permalink)
    0
    Hi folks
     
    Apologies for taking so long to reply. Thanks for taking the time to respond.
     
    Rainad:
    I've tried with some different IP addresses on the same network and so far only 192.168.1.251 - 255 (that is the last number of the IP address being between 251 and 255) can be pinged, any last number less than 251 cannot be pinged (although I haven't tested it exhaustively). Strangely, I accidentally set the board IP to 129.168.1.252 at one point and I still got a response when I pinged 192.168.1.252  (first 3 digits are different).
     
    When both the the PIC and my server are up and running, they connect fine and can send small packets (<125 bytes from what I can see on wireshark) between each other with no problem (that I'm aware of).
    If the server sends a packet larger than this, the pic doesn't register it. I can see on wireshark that the server then tries to resend the packets but doesn't receive any response from the PIC so closes the connection. The PIC is set up to reconnect if the connection drops which it does fine. If I try to send a smaller packet straight after the larger packet is sent, but before the connection is closed, nothing different happens: the PIC doesn't receive either message and the server closes the connection after a timeout. This behaviour occurs with IP addresses that I can ping (e.g. 192.168.1.255) and those that I cannot ping (e.g. 192.168.1.10).
    I haven't tried sending longer messages from the PIC to the server yet, will try that today.
     
    NKurzman:
    My IPv4 subnet mask is 255.255.255.0 which matches the subnet shown on my network for the wifi adapter when I run ipconfig from the command line.
    #13
    rainad
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/11 13:59:54 (permalink)
    5 (1)
    I think you have an issue on that Curiosity board or something is not configured properly.
    Let aside the TCP, but the fact that you can ping only some addresses is really strange.
    What is interesting is that the MAC doesn't report any errors (macinfo report seems clean, or maybe it's incomplete?).
    I'd forget about TCP tests for now, just try ping or UDP until you solve the issue.
    Change your socket from TCP to UDP (or use a different example) and see if bigger UDP packets go through.
    There is a 'packet logger' in the stack, that may help you with this, rather than setting breakpoints and debugging the code. Enable the packet logger and then log ICMP traffic, for example, then UDP, so that we can see if the MAC really reports those packets to the stack and, if so,  what module in the stack discards them and for what reason.
     
    I think that's easier than setting breakpoints in the processing layers of the stack to understand where exactly the packets are dropped.
     
    #14
    rbuck
    Super Member
    • Total Posts : 358
    • Reward points : 0
    • Joined: 2005/04/28 12:48:11
    • Location: Phoenix, AZ
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/11 19:22:39 (permalink)
    0
    This behavior occurs with IP addresses that I can ping (e.g. 192.168.1.255)


    192.16.1..255 is not a valid device IP address. That is the broadcast address of your network. The ping reply could be coming from any device on your network, but is probably coming from you router.

    When both the the PIC and my server are up and running, they connect fine and can send small packets (<125 bytes from what I can see on wireshark between each other

    How do you know they are sending packets between each other? Do you send a message from the PC and get the correct reply from the PIC? Or vice versa?

    68:27:19:d3:ab:b1 is not a Microchip MAC address. In fact, 68:27:19 is not assigned to any vendor. Did you make that address up? You should be using the MAC address that is programmed into the PIC32MZ2048EFM144. However, that probably has nothing to do with the problem you are having.
     
    You are assigning a static IP address but you also have DHCP enabled. That could be causing your problem. You also have "default IP address" set to ON. This should probably be OFF. Remove all of the static IP configuration and leave DHCP enabled. This will allow your network router to setup all of the necessary IP configuration for the board.
     
    You could also enable ICMPV4 client and add code in your application to ping the server and watch Wireshark to see if the server replies to the ping.
     
    Edit: Actually 68:27:19 does belong to Microchip. The tool I was used yesterday to check the ID showed no results found. I checked it with another tool a few minutes ago and it identified Microchip as the owner. So your MAC address is good after all.
    post edited by rbuck - 2021/03/12 15:23:34
    #15
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/12 01:35:32 (permalink)
    0
    I've tried sending larger packets from the pic to the server and that appears to work fine when debugging.
     
     
    Rainad: I'll try setting up with UDP and see if that helps diagnose anything.
     
    rbuck: Didn't realise 255 was a general broadcast, thanks for the info. When sending smaller messages I can view what is received either on the ui of the server application or by printing what the PIC receives on a serial terminal, and all of the characters are correct. I haven't got as far as having automated responses coming from them. I can also see that they are both sending ACKs for the smaller packets when using Wireshark.
    The MAC address is the default that comes up in Harmony (something I should probably look at for the final product, but the ethernet messaging is more important right now). Actually looking back at my notes, I wasn't comparing the MAC, I was just going off that in the packet breakdown in Wireshark, it says the packets from the PIC have the the source: Microchi_d3:ab:b1. Whilst maybe not the best practice to make those assumptions, I thought it was pretty unlikely that anything else on my home network would have anything like that as a source, and the rest of the packet matched what I would expect from the PIC.
    I can't have DHCP enabled all the time as my client wants to have the option to either have it or not. The default for the device will be to use DHCP but  some customers will want to set static IP addresses so they know exactly which device has which address. I do need to set it up properly though so will try just using DHCP for now. I'll have a look at the ICMPV4 client as well.
     
    Thanks for the support folks.
    #16
    regh
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2020/11/26 01:37:13
    • Location: 0
    • Status: offline
    Re: TCP/IP client not receiving packets above 124 bytes 2021/03/22 08:51:43 (permalink)
    0
    I've switched over to PIC32MZ DA (for a separate issue related to graphics for the application) and the upper limit seems to have been solved (despite not changing any of the ethernet settings for the project).
    #17
    Jump to:
    © 2021 APG vNext Commercial Version 4.5