Mbed client and cellular internet connection


(Carmelo Migliore) #1

Hi, I'm trying mbed-client-examples with my ST-Nucleo and a cellular modem, but I have some problems. I see some packets being sent and received but the registration process does not complete successfully.
I've seen that mbed-client starts a listening socket, but since the cellular connection is behind a NAT this socket won't be reachable... can this be the problem of the failed registration? And if my guessing is correct, isn't there a way to use mbed-client with NATed connections?
Thank you

(Minho Kim) #2


I already e-mail them 'How to use client on nucleo board?'.
but they are un-aware of using expansion shields or modules.

Is there anyone who use client on nucleo board?

(Carmelo Migliore) #3

Well the cellular modem I'm using works good and also mbed-client seems to run fine on my Nucleo... When I try to register the device, network packets seem to be sent and received correctly, but after a few seconds nothing more happens... I suspect this is because of the NAT but I'm not sure...
Is there someone who can help?

(Yogesh Pande) #4

Are you using the mbed-client-example as it is without any modifications or have you done some porting changes to make it run over cellular modem interface ? mbed-client is currently supported over LwIP IPv4 Ethernet and 6LoWPAN network only because of underlying mbed OS Socket support. So, I am not sure if it would work out-of-box for cellular modem interface.


(Carmelo Migliore) #5

Thank you for the reply. I'm using the PPP layer included in sal-stack-lwip so I'm using LwIP IPv4 as TCP/IP stack. In fact "normal" connections with mbed OS Sockets work flawlessly. I tried DNS resolving, HTTP, UDP etc., all work well.
I have problems only with mbed-client, of course I modified mbed-client-example, I removed all the reference to ethernet to make it run over cellular modem interface. I can see many network packets are sent and received correctly, but after a while I get a "network error". My guess is that mbed-client can't run over a NATed connection (like cellular connections are)... can this be the reason?

(Yogesh Pande) #6

That's good news that you are able to get the socket working over cellular modem. The issue then might be to do with connection between client and server.
If you are using Device Connector (api.connector.mbed.com:5684) then few things that you can check
1) Have you taken the device credentials from https://connector.mbed.com/#credentials and not modified any of the values there like endpoint name or domain.
2) Is it possible to check data packets received and sent by device (wireshark) to check if the DTLS handshake is proceeding or failing ? The error sounds like it is failing in DTLS handshake phase and NAT connection issue can be one of the reasons but it would be nice to know if any of the data packet transactions have occured between client and server.


(Carmelo Migliore) #7

1) Yes I'm using device connector, I took all the credentials and I didn't modify any of those.
2) I'm not aware of a method to capture packets with LwIP... I could forward all the network packets to PC serial, but then how can I check those with wireshark? I think that packets should be in a particular format (.cap) to be read by wireshark, right? If you know how to capture packets I'd be happy to try
Thank you for the support

(Yogesh Pande) #8

Check this link https://wiki.wireshark.org/CaptureSetup/PPP . Hopefully you can capture the packets in Wireshark through this.


(Carmelo Migliore) #9

Thank you Yogesh, I'll give it a try and will let you know

(Carmelo Migliore) #10

@yogpan01 I was able to make a capture, here you can find the pcap file: https://drive.google.com/file/d/0ByBW913zLgUIU2Z5c3Zxc3VkSW8/view?usp=sharing
The packet flow looks a bit strange to me, however the DTLS handshake can be clearly seen. I'm not a DTLS expert so I can't understand what's going on, hope you can help :slightly_smiling:
My device's IP address is (as you can see it's a private address because the connection is NATed)
Probably at some point the device tried to do a value update even if the registration wasn't succesful, so maybe the packet flow is a little dirty. However it should be still understandable.
The mbed-client-example returned a "Network error", probably because of the RST packet that can be seen at the end of the capture
Thank you for the support

(Yogesh Pande) #11

We checked the wireshark logs and it seems that after Server Hello Done , the client is not able to proceed. I reproduced the DTLS handshake with Linux client and found that after this step, client then sends the whole Certificate to the server which is over 540 bytes. Now, do you know if there is any buffer limit on the size of data that you can send through cellular interface, something which is limiting it to less than, say 512. Because I can see some traces of IP fragmentation in the pcap logs but they are not originating from client IP but may be some gateway in between. That can be starting point to check the size limit for the data that can be sent or received through cellular modem , or is there some limit that you might have put on your porting layer ?


(Carmelo Migliore) #12

Hi Yogesh, yes this could be the problem. The cellular modem I'm using (Adafruit FONA, based on Simcom800) is quite cheap so maybe when I try to send too much data it fails. I'll check and will let you know

(Rainer Geissendoerfer) #13

Did you manage to use the mbed client for your Adafruit FONA? I am trying to do the same thing (I am also owning the FONA Breakout), but (as I am a newbie to the platform - coming from Particle and Arduino) I wonder how to do it. Would you mind posting the code?


Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.