ESP8266 as WiFi to PPP Bridge

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

ESP8266 as WiFi to PPP Bridge

Wormsley, Jeffrey (Jeff)

Is it possible to use an ESP8266 as a WiFi to PPP bridge? 

 

I have a device whose hardware is fixed, but is Linux based and has LAN and two serial ports, no USB host.  I need to have a very inexpensive way to get this device onto a WiFi network, so an Ethernet to WiFi bridge is out of the question (unless someone knows where I can get one for under $5). 

 

I know LWIP is available for the device, although it is my understanding it is an older version and somewhat modified.

 

My thought was to use an ESP8266 module as a PPP server, use the Linux PPP client on the device, and use the ESP8266 as a bridge. 

 

Or, is it possible to go the other way and use the ESP8266 as the client and the Linux device as the server?

 

I’m not worried about speed, won’t be streaming any videos or anything like that. 

 

Thanks,

  Jeff.


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Sylvain Rochet
Hi Jeffrey,


On Thu, Jan 26, 2017 at 06:25:48PM +0000, Wormsley, Jeffrey (Jeff) wrote:
>
> Is it possible to use an ESP8266 as a WiFi to PPP bridge?

Short answer: yes, since ESP8266 can host your application :-)


> I have a device whose hardware is fixed, but is Linux based and has
> LAN and two serial ports, no USB host.  I need to have a very
> inexpensive way to get this device onto a WiFi network, so an Ethernet
> to WiFi bridge is out of the question (unless someone knows where I
> can get one for under $5).
>
> I know LWIP is available for the device, although it is my
> understanding it is an older version and somewhat modified.
>
> My thought was to use an ESP8266 module as a PPP server, use the Linux
> PPP client on the device, and use the ESP8266 as a bridge.
>
> Or, is it possible to go the other way and use the ESP8266 as the
> client and the Linux device as the server?
Both way are possible.


But, long answer, you will have to change a little bit the PPP lwIP
stack to hook PPP IP input/output to bypass the IP stack, since you
don't need it (you want a L2-ish bridge).

Basically, you need to change ip4_input/ip6_input called from ppp.c to a
function which send a properly formatted IPv4/IPv6 packet (+ Ethernet
header ?) over your ESP8266. And you need to call ppp_input with
IPv4/IPv6 packets from your ESP8266, you'll have to prepend the PPP
header though.

You'll also have to wait for wifi module to be ready (dhcp, etc.) in
order to be able to set the remote IP address.

This is basically what cellular modems are doing when dialed using PPP.


Sylvain

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Wormsley, Jeffrey (Jeff)
Thanks for the reply.  See comments below.

>> My thought was to use an ESP8266 module as a PPP server, use the Linux
>> PPP client on the device, and use the ESP8266 as a bridge.
>>
>> Or, is it possible to go the other way and use the ESP8266 as the
>> client and the Linux device as the server?
>
> Both way are possible.

Ok.  Further research seems to indicate that the version of LwIP in these modules was customized to hook into their wireless engine (a binary blob and unchangeable) and that older version didn't have a working PPP host mode.  So it might be more practical to have the ESP8266 as a client as presumably that works.

> But, long answer, you will have to change a little bit the PPP lwIP stack to hook PPP IP input/output to bypass the IP stack, since you don't need it (you want a L2-ish bridge).
>
> Basically, you need to change ip4_input/ip6_input called from ppp.c to a function which send a properly formatted IPv4/IPv6 packet (+ Ethernet header ?) over your ESP8266. And you
> need to call ppp_input with IPv4/IPv6 packets from your ESP8266, you'll have to prepend the PPP header though.

Is there a method that might work with less invasive changes?  Maybe more of a router type interface than a bridge?  Not sure I have the chops to tear into LwIP that deeply, especially one that has already been torn into for other reasons.

> You'll also have to wait for wifi module to be ready (dhcp, etc.) in order to be able to set the remote IP address.

This might work out better having the ESP8266 as the client rather than the server, since I could delay making the connection to the PPP server until I had all of this in place.  It has the drawback of not being able to use the IP address assigned over WiFi as the IP address of the device, though.  However, in my application I may be able to use nothing but fixed IP addresses anyway.

> This is basically what cellular modems are doing when dialed using PPP.

I've used cellular modems this way, which is what made me think of this as a solution to my connectivity problem.

Thanks very much for your reply,
  Jeff.
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Ajay Bhargav (SiWi)

Jeff,

 

I have tested Ethernet ßà PPP using NAT. I am sure it can work for ESP8266 too for wifi, Though I have not tested myself. ESP SDK uses older version of lwIP. I am managing a NAT port from RT-Thread on GitHub. You can try those patches on ESP.

 

Ref: https://github.com/ajaybhargav/lwip_nat

 

Regards,

Ajay Bhargav

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: Friday, January 27, 2017 4:07 AM
To: [hidden email]
Subject: Re: [lwip-users] ESP8266 as WiFi to PPP Bridge

 

Thanks for the reply.  See comments below.

 

>> My thought was to use an ESP8266 module as a PPP server, use the Linux

>> PPP client on the device, and use the ESP8266 as a bridge.

>>

>> Or, is it possible to go the other way and use the ESP8266 as the

>> client and the Linux device as the server?

> 

> Both way are possible.

 

Ok.  Further research seems to indicate that the version of LwIP in these modules was customized to hook into their wireless engine (a binary blob and unchangeable) and that older version didn't have a working PPP host mode.  So it might be more practical to have the ESP8266 as a client as presumably that works.

 

> But, long answer, you will have to change a little bit the PPP lwIP stack to hook PPP IP input/output to bypass the IP stack, since you don't need it (you want a L2-ish bridge).

>

> Basically, you need to change ip4_input/ip6_input called from ppp.c to a function which send a properly formatted IPv4/IPv6 packet (+ Ethernet header ?) over your ESP8266. And you

> need to call ppp_input with IPv4/IPv6 packets from your ESP8266, you'll have to prepend the PPP header though.

 

Is there a method that might work with less invasive changes?  Maybe more of a router type interface than a bridge?  Not sure I have the chops to tear into LwIP that deeply, especially one that has already been torn into for other reasons.

 

> You'll also have to wait for wifi module to be ready (dhcp, etc.) in order to be able to set the remote IP address.

 

This might work out better having the ESP8266 as the client rather than the server, since I could delay making the connection to the PPP server until I had all of this in place.  It has the drawback of not being able to use the IP address assigned over WiFi as the IP address of the device, though.  However, in my application I may be able to use nothing but fixed IP addresses anyway.

 

> This is basically what cellular modems are doing when dialed using PPP.

 

I've used cellular modems this way, which is what made me think of this as a solution to my connectivity problem.

 

Thanks very much for your reply,

  Jeff.

_______________________________________________

lwip-users mailing list

[hidden email]

https://lists.nongnu.org/mailman/listinfo/lwip-users

 


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Sergio R. Caprile
In reply to this post by Wormsley, Jeffrey (Jeff)
TCP/IP stack in ESP8266 is a heavily modified development branch between
1.4.0 and 1.4.1 stable versions.
The non-OS usage of this little beast requires releasing cpu quite
frequently for wifi duties, so they require using os_ versions of the
standard C library functions. Don't know how friendly the FreeRTOS SDK
is, nor if it is stable, last time I checked it was a beta.
There is someone in the net who tracked changes and released a modified
pre 2.0.0. stack.

Having been digging into some of their example code, I do not recommend
this piece of engineering for production use in communications devices.
It may work OK for connect/do your work/disconnect stuff in devices with
some communications capabilities.

Your mileage will vary.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Ajay Bhargav (SiWi)

I agree ESP8266 LwIP stack is heavily modified and source provided with FreeRTOS sdk it never compiles. I even post on forum but no response from dev team. Most of the errors were of implicit function declaration, stack is calling functions in library with no header file defining its prototype. Adding those prototypes compiles the stack successfully.

 

Another Limitation or bug I would say in stack is, you cannot send chained pbuf to stack for sending. It crashes… I came to know recently. Hope their dev team shifts to a better newer and stable stack soon.

 

I have used FreeRTOS SDK on ESP8266 as well as on other platforms. Its stable till the time you know how to use it. Any wrong API usage can easily break your application. Most common mistakes I have seen is during IRQ context.

Can you share link of modified lwIP 2.0.0 stack?

 

  • Ajay

 

From: [hidden email]
Sent: Friday, January 27, 2017 8:12 PM
To: [hidden email]
Subject: Re: [lwip-users] ESP8266 as WiFi to PPP Bridge

 

TCP/IP stack in ESP8266 is a heavily modified development branch between

1.4.0 and 1.4.1 stable versions.

The non-OS usage of this little beast requires releasing cpu quite

frequently for wifi duties, so they require using os_ versions of the

standard C library functions. Don't know how friendly the FreeRTOS SDK

is, nor if it is stable, last time I checked it was a beta.

There is someone in the net who tracked changes and released a modified

pre 2.0.0. stack.

 

Having been digging into some of their example code, I do not recommend

this piece of engineering for production use in communications devices.

It may work OK for connect/do your work/disconnect stuff in devices with

some communications capabilities.

 

Your mileage will vary.

 

_______________________________________________

lwip-users mailing list

[hidden email]

https://lists.nongnu.org/mailman/listinfo/lwip-users

 


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Sergio R. Caprile
In reply to this post by Sergio R. Caprile
This is getting off-topic for the list, if you need further info please
feel free to write a personal message.

The company I work for resells Espressif chips/modules, they are focused
on ESP32 right now, I don't think they will work on the 8266, but you
never can tell.

I found what I think is the link you requested:
https://github.com/nekromant/esp8266-frankenstein/pull/76

Don't know if it is worth your time, I've been on this some months ago
and desisted. I would go for ESP32, looks cleaner and uses a newer lwIP
release.


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Wormsley, Jeffrey (Jeff)
> Don't know if it is worth your time, I've been on this some months ago and desisted.
> I would go for ESP32, looks cleaner and uses a newer lwIP release.

Beginning to think you are right, better to go with the newer part, even though I may not need the BLE portion of the module.

Thanks everyone,
  Jeff.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Sylvain Rochet
In reply to this post by Wormsley, Jeffrey (Jeff)
Hi Jeffrey,

On Thu, Jan 26, 2017 at 10:37:28PM +0000, Wormsley, Jeffrey (Jeff) wrote:

> >
> > But, long answer, you will have to change a little bit the PPP lwIP
> > stack to hook PPP IP input/output to bypass the IP stack, since you
> > don't need it (you want a L2-ish bridge).
> >
> > Basically, you need to change ip4_input/ip6_input called from ppp.c
> > to a function which send a properly formatted IPv4/IPv6 packet (+
> > Ethernet header ?) over your ESP8266. And you need to call ppp_input
> > with IPv4/IPv6 packets from your ESP8266, you'll have to prepend the
> > PPP header though.
>
> Is there a method that might work with less invasive changes?  Maybe
> more of a router type interface than a bridge?  Not sure I have the
> chops to tear into LwIP that deeply, especially one that has already
> been torn into for other reasons.
The main problem with IP routing is that you'll need to change the
routing table on the gateway facing your wifi module, which is probably
impossible in your case:

BOARD ------------------------------ PPP/WIFI ---------------------- GW
192.168.2.2/24             192.168.2.1/24   192.168.1.2/24     192.168.1.1/24
default via 192.168.2.1    default via 192.168.1.1             default via x.x.x.x
                                                               192.168.2.0/24 via 192.168.1.2

Or you can try Ajay NAT support ;-)

Sylvain

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

goldsimon@gmx.de
Sylvain Rochet wrote:
> Or you can try Ajay NAT support ;-)

But do keep in mind that the license of that is GPL and *not* lwip code - although their file header says so ("part of the lwip stack", "license lwip project")!

Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: ESP8266 as WiFi to PPP Bridge

Ajay Bhargav-2
I should Modify that header as I know lwip is not involved in this. I will fix it so noone is confused.

Regards,
Ajay Bhargav

On Feb 15, 2017 9:08 PM, "sg" <[hidden email]> wrote:
Sylvain Rochet wrote:
> Or you can try Ajay NAT support ;-)

But do keep in mind that the license of that is GPL and *not* lwip code - although their file header says so ("part of the lwip stack", "license lwip project")!

Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users