Looking for PPP example for lwIP - Page 1
Forum section: electronics / general

author: cgroen
author_rank: Unknown
timestamp: March 15, 2017, 02:33:50 pm
content: I'm currently trying to find a suitable TCP/IP stack that has support for PPP protocol. I have looked at a few, PicoTCP, lwIP and Keil's middleware stack...So far I'm mostly attracted towards lwIP (that might change if enough problems arise) but it seems that all of the examples I have found for the lwIP is using Ethernet. In my case I need PPP (over a serial port).Do any of you know of a good starting point for this perhaps ?(any other recommendations are also welcome)

author: westfw
author_rank: Super Contributor
timestamp: March 16, 2017, 01:14:13 am
content: You'll need to put some constraints on that, since PPP is one of those protocols with enough "extensions" to multiply the basic code size by a couple orders of magnitude...At some level, you just assemble packets and pass them up just like they were ethernet packets. Except for the ones that go sideways to negotiate all those extensions! Since UARTs tend to be much simpler than Ethernet controllers, the bottom levels should be pretty much the same... ISR, State machine, PACKET!

author: krho
author_rank: Regular Contributor
timestamp: March 16, 2017, 05:53:40 am
content: nuttx has a ppp daemon, so if you want to stitch that together yourself...

author: cgroen
author_rank: Unknown
timestamp: March 16, 2017, 07:30:43 am
content: Quote from: krho on March 16, 2017, 05:53:40 amThanks(just had a look at nuttx, impressive work!)But in the case of lwIP there is already PPP included, seems to be pretty complete. The only problem is that there are no examples on how to use the zillion of files included in the "ppp" folder of lwIP (according to my search skills)It's going to run on a "not too small" embedded system, there is "plenty" of RAM (SDRAM) and flash. It would just be nice with a working example on some architecture, even if it were a windows/visual studio etc project that used the PCs serial port, but no luck so far...

author: aandrew
author_rank: Frequent Contributor
timestamp: March 16, 2017, 10:35:06 pm
content: I've run PPP on LwIP (STM32 based, using a Telit LTE module).It was pretty challenging to get set up and running due to the lack of documentation, both in-code and "official."In a nutshell though, you implement an sio_write() routine which takes data from LwIP's PPP driver and puts it to hardware. Anything coming from the serial link gets delivered to pppos_input(). That takes care of the link between the hardware and the PPP implementation. That's the easy part. :-)From there you're in a state machine of your own design. I had the following states:* INIT: call pppInit(), jumps to DISCONNECTED state* DISCONNECTING: call pppLinkTerminated() and pppClose() to reset things, jumps to DISCONNECTED* DISCONNECTED: does nothing until the higher-level code wants to start a connection (jumps to START)* START: calls pppSetAuth() and pppOverSerialOpen(), jumps to CONNECTING* CONNECTING: runs lwip_loop() until you either get a connection (from the link status callback which sets the state to CONNECTED) or drops back to DISCONNECTING to close up and try again* CONNECTED: runs lwip_loop() until your higher level code decides it wants to tear the link down.What's lwip_loop() I hear you ask? it's the dumb routine that shuttles data received from the serial link to pppos_input(). The routine also handled the periodic call to sys_check_timeout() which is an LwIP function that handles all the IP (including PPP) timeouts. You might design your architecture differently.This code was able to establish and maintain PPP links for *days* over the cell network, and correctly re-established the connection if the link dropped (either through a remote disconnection or my disconnecting the antenna to test). My code did a fair bit more too (GPS, autobaud, dialing, selecting a carrier, maintaining link info, SMS, battery level, etc.) but none of those are important to PPP and LwIP.Good luck!

author: cgroen
author_rank: Unknown
timestamp: March 17, 2017, 05:07:33 am
content: Thanks a lot for input!The infrastructure around the modem I'm fine with, have been working on 2G/3G modems for the last 20 years or so. It''s more the actual implementation/integration in lwIP that I'm lost at. There are a ton of examples using Ethernet on all sorts of controllers, but none I have found on PPP....

author: westfw
author_rank: Super Contributor
timestamp: March 17, 2017, 08:27:25 am
content: QuoteAre you confused about the integration of packet-level IO (getting TCP/IP/PPP packets into the network process), or about the "other" negotiations that happen via IPCP and similar (IP addresses/etc)? Or both?

author: cgroen
author_rank: Unknown
timestamp: March 17, 2017, 08:37:49 am
content: Quote from: westfw on March 17, 2017, 08:27:25 amHmm, its more the overwhelming options in the lwipopts.h file (would be nice with a copy of a working "ppp" example of that). I did find some references to the "data insertion" from the serial port etc.(f.ex here:http://lists.nongnu.org/archive/html/lwip-users/2013-06/msg00013.html)It seems from other users experience that once that is working there is light at the end of the tunnel.

author: westfw
author_rank: Super Contributor
timestamp: March 18, 2017, 12:47:25 am
content: Hmm. I haven't used lwip at all, but I'm passing-familiar with serial PPP in general.I'm looking at the latest (?) lwip source athttp://git.savannah.nongnu.org/cgit/lwip.git/tree/src/include/netif/ppp/ppp_opts.h?h=STABLE-2_0_0Is that the list of parameters that you're having trouble with?I'd think that just setting PPP_SUPPORT to 1 would give you a base configuration; it looks like a lot of the other options have reasonable defaults...What exactly are you trying to DO with PPP? Cheap local connection? Dialout? Dialin? Radio? Security important, or irrelevant? Can you get by with SLIP instead? (it's a lot simpler, but is IP only (which is not nearly so much of an issue as it was back when we were "inventing" PPP.))

author: cgroen
author_rank: Unknown
timestamp: March 18, 2017, 07:39:17 am
content: There is a lwipopts.h file that has a lot of options in it. Some are values for buffer sizes, some are enabling/disabling stuff. It would have been nice with one from a working example with PPP.I'm trying to use it to act as a client over 3G (dialout), security not top priotity. I need full TCP/IP (both sockets and UDP). Slowly getting a project set up on a PC, hope that it will eventually work out

author: cgroen
author_rank: Unknown
timestamp: March 27, 2017, 08:20:02 am
content: Well,I've had some progressI'm now able to ping a host using a connection thru a 3G modem! Currently I have this running as a PC program with the 3G modem connected thru USB port. Once I feel more confident about the code and the zillion configuration parameters, I will move the stuff to the target processor...I hope (no promises!) that I can prepare a project for others to benefit from (in Visual Studio...) at some time.

author: sarp
author_rank: Newbie
timestamp: May 11, 2018, 01:18:14 pm
content: There is no more pppInit() or pppOverSerialOpen() functions in the current LwIP stack. Therefore, I do not know how to modify the states to my current project. Do you have any other examples?