Small Internet Protocol Stack using a standard serial port.

Dependencies:   mbed

You are viewing an older revision! See the latest version

Homepage

PPP-Blinky - TCP/IP Networking Over a Serial Port

/media/uploads/nixnax/network-popup2.jpg

No Ethernet Port Required

PPP-Blinky uses a standard serial port. It should run on every available mbed hardware platform.
No ethernet port is required.

In A Nutshell

PPP-Blinky transforms your typical mbed-enabled hardware into a standard Windows 7/8 Networking Adapter and Webserver.

Tiny Embedded Webserver

PPP-Blinky contains enough smarts to work with web browsers such as Internet Explorer, Mozilla Firefox, Google Chrome and Curl.

In this picture Internet Explorer displays a small web page that is embedded in PPP-Blinky's code.

/media/uploads/nixnax/ppp-blinky-in-ie.jpg

Trying It Yourself

You will need an mbed-enabled hardware board. Establish a serial port connection between your mbed board and your host PC. The easiest way is probably to use mbed hardware with a USB serial debug port. I've tried the ST-Micro Nucleo-L476RG, Nucleo-L152RE,mbed-LPC11U24 and mbed-LPC1768 boards and they all work fine. Use the online mbed web-based compiler to download and compile the code. Save the compiled binary to your hardware.

You can manually test the code by opening a terminal program such as Tera Term, and setting the relevant COM port to 115200 baud. LED1 should toggle for every two 0x7E (~) (i.e. tilde) characters you type, as those are the HDLC frame start/end markers. Don't forget to close the port when your'e done testing, or else Windows Dial-up Networking will report that the com port is in use by another program when you try to connect.

Creating a Dial-up Networking Adapter on Windows

/media/uploads/nixnax/modem.jpg

To set up your Windows 7 or 8 PC, you have to create a new modem. The process should go roughly like this https://technet.microsoft.com/en-us/library/cc726048(v=ws.10).aspx, and you have to choose Communications cable between two computers under Standard Modem Types.

When asked which serial port to use, select your MBED board's USB virtual COM port. Finally, go to Modem properties and set the baud rate of the modem serial port to 115200 baud.

In Windows XP/7/8 networking, create a new Dial-up networking adapter by choosing Setting up a new network connection and then choosing Connect to the Internet. You will be told You are already connected to the internet, but click Set up a new connection anyway and choose the new modem that you have created. Even though it's a direct connect link, you have to enter a phone number to dial, so just enter 1.

With the the code running on your MBED board, you should see LED1 blinking as soon as you click Connect on your PC, signaling that PPP-Blinky is receiving networking packets from the PC. Your network connection will be shown as Connected.

Dealing with the Windows 7/8/10? Error 777 Bug

There is a really annoying bug in Windows 7/8/10 Dial-Up networking. It's almost 100% certain that you will run into it.

If you see Error 777 instead of Verifying User Name and Password and LED1 never turns on, you have to manually edit a file named rasphone.pbk, find a string Type=1 and change it to Type=3.

/media/uploads/nixnax/rasphone.jpg

Note that this string will be modified back to Type=1 every time Windows saves phone book information (e.g. the phone number) so you have to remain vigilant for Error 777 and go back in to repeat the fix! You will probably have to do this many times.

It's a well known bug and you can read all about it, including finding the location of rasphone.pbk, here: http://stackoverflow.com/questions/7953376/ppp-connection-through-serial-cable-works-on-windowsxp-but-doesnt-work-on-windo

After Connect

Once everything is working you establish a dial-up connection to your mbed board over the USB virtual com port.

The IP address you manually assigned to the new dial-up network adapter functions as a gateway to any valid IP address on that subnet. In the screen capture below, I'm sending pings from the Windows 8 command line to my ST-Micro Nucleo-L476RG board over the USB virtual serial Port. I'm using a second serial port and Tera Term to capture the debug output from a second serial port on the hardware. I've also added the hostname mbed-PPP-Blinky to my Windows hosts file so I don't have type in the IP every time. The debug output from the board prints out the IP source and destination address and the first few bytes of the data payload. Note that the source is the adapter IP address, and the destination is some other address on that subnet - all packets to that subnet are sent to our mbed hardware.

/media/uploads/nixnax/ppp-blinky-online.jpg

Pings are Fast!

In the screen shot below the ICMP ping reply routine was compiled with debug printing commented out. The ping reply for a short ping (1 bytes of data) was around 11 milliseconds on the Nucleo-L476RG board at 115200 baud. Note that one million pings were sent! My ping client was psping from PsTools by Mark Russinovich, which can ping really fast.

/media/uploads/nixnax/mega-ping.jpg

Monitoring PPP-Blinky Packets

Since WireShark (actually Winpcap) does not monitor Dial-Up packets on Windows, Microsoft Network Monitor is a very handy tool to use. In the picture below, you see a web client from IP 172.10.10.10 (the Dial-Up Adapter IP) establish a connection to PPP-Blinky at 172.10.10.1 using the S (SYN) flag, and in frame 17992 it pushes an HTTP GET request to PPP-Blinky. The request is coming from the curl 172.10.10.1 webclient command I issued in Powershell. In frame 17993 PPP-Blinky responds with an HTTP response header and a small web page. The connection ends in frame 17995. Frame 17996 is the start of new connection, which is fully established in the last frame. Note that the IP address that you manually assigned to the Dial-Up Networking Adapter becomes the remote IP. PPP-blinky will receive and will respond to any IP address that is on the subnet of the adapter IP address, because Windows will automatically route any IPs on the adapter IP to PPP-Blinky. That means PPP-Blinky effectively monitors the entire subnet established by the IP of the dial-up adapter. Note that PPP-blinky does see DHCP request packets, but it ignores them, so a manually assigned IP address is needed for the DUN adapter.

/media/uploads/nixnax/ms-network-monitor.jpg

Caveats

This part is to ensure you understand that PPP-Blinky is not Apache.

PPP Blinky is an extremely sparse implementation of TCP, UDP, ICMP, IPCP and LCP over PPP. To keep things this simple, it assumes one TCP connection at any time. This is fine for many embedded applications. However, if your dreams include having a multitude of TCP connections simultaneously, PPP-Blinky is probably not for you.


All wikipages