Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
Homepage
PPP-Blinky - TCP/IP Networking Over a Serial Port¶
In A Nutshell¶
PPP-Blinky transforms your typical mbed-enabled hardware into a standard Windows 7/8 (or Linux) Dial-UpNetworking (DUN) Adapter and Webserver.
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.
Tiny Embedded Webserver¶
PPP-Blinky contains enough smarts to work with web browsers such as Internet Explorer, Mozilla Firefox, Google Chrome, Curl and the Powershell Invoke-Webrequest command.
In the picture below Internet Explorer displays a small web page that is embedded in PPP-Blinky's code.
Let's Do This¶
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 right out of the box. Use the mbed online compiler to compile the software for your target board. Save the compiled binary to your hardware.
You can manually test the code by opening a terminal program such as Tera Term, and then setting the relevant COM port baud rate 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 Connection on Windows¶
Setting up Dial-Up Networking (DUN) on your Windows 7 or 8 PC is a two-step process - first you create a new modem. Then you create a new Internet connection (in practice, a new network adapter) which you associate with the new modem. The process is described here: 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 for your new modem, choose your MBED board's USB virtual COM port - you can find the exact Com port number using Device Manager and searching under Ports (COM & LPT). Finally, in modem setup, go to Modem properties and set the baud rate of the modem serial port to 115200 baud. Once a modem is defined, you can also use Device Manager to view or edit it.
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
.
PPP-Blinky sees DHCP request packets but ignores them, so you have to set a MANUAL IP Address for your dial-up adapter. I used 172.10.10.10 - PPP-blinky will then receive traffic to all IP adresses on the subnet 172.10.10.xx, so choosing 172.10.10.1 probably makes a little more sense. Note that this is the adapter IP address. The adapter itself will respond to pings, but PPP-blinky responds to all other addresses on that subnet, for example 172.10.10.2.
With a manual IP address set up and 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 nasty, really annoying bug in Windows 7/8/10 Dial-Up networking. It's almost 100% certain that you will run into it, so read this carefully:
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.
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 to type in the IP every time. The optional 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.
Pings are Fast!¶
In the image below the ICMP echo reply service was tested by sending one million pings from the PC. This took several hours.
The ping tool used on the Windows 8 PC was psping.exe from PsTools by Mark Russinovich - http://bit.ly/PingFast
The average reply time for a short ping (1 byte of data) was 10.6 milliseconds at 115200 baud on the amazing $15 Nucleo-L476RG board at 115200 baud - barely enough time for 120 bytes to be sent over the port!
Monitoring PPP-Blinky Packets¶
Since WireShark (actually Winpcap 4) does not monitor Dial-Up packets on Windows, Microsoft Network Monitor is a very handy tool to use. (Note - if you love WireShark too much, Network Monitor can save PPP captures in a .cap file format which can be read by WireShark). In the picture below, you'll 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 receives and responds to any IP address that is on the subnet of the adapter IP address, because Windows automatically creates a route to all those IPs and sends all traffic straight to PPP-Blinky. 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 ignores them, so a manually assigned IP address (IPV4) is needed for your new dial-up network.
Creating a Dial-Up Connection on Linux¶
The screen below shows the required pppd command to connect to PPP-Blinky from a Linux machine. The USB serial port of the mbed LPC1768 board registered as /dev/ttyACM0 on my Linux box. Do a websearch on pppd if you want to learn more about pppd, the Linux PPP handler. Near the bottom of the screen below, two webpages are fetched (/ and /y) by using the curl command on the command line. Gnome Webkit and Firefox work fine, too. Also try echo GET / HTTP/1.1 | nc 172.10.10.2 which uses netcat, the "Swiss army knife" of networking tools. PPP-Blinky was also tested with ApacheBench, the Apache server benchmark software. The mean time per request (after 500k fetches) for a small page was reported as 152 ms.
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.