Small Internet Protocol Stack using a standard serial port.

Dependencies:   mbed

You are viewing an older revision! See the latest version

Homepage

TCP/IP Networking Over the MBED Virtual Com Port is Possible

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

PPP-Blinky shows how your mbed-enabled hardware interface as a standard Dial-up Networking Adapter in Windows 7 and Windows 8 using only a serial port.

PPP-Blinky waits for a Dial Up Connect string from the Windows PC over the serial port.

The response string is interpreted by the Windows unimodem driver as a CONNECT response.

Windows then assumes the connection is up and starts sending IP packets using the PPP protocol.

The code interprets the PPP packets and toggles LED1 every time a new packet is received.

Tiny Embedded Webserver Working

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-webserver.jpg

Trying It Yourself

Establish a serial port connection between your MBED board and your host PC. The easiest way is probably to use a board with a USB serial debug port. I used the ST-Micro Nucleo-L476RG. Compile and load PPP-Blinky onto 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. Nothing will happen until you type CLIENTCLIENT (there is no echo) when you will see "CLIENTSERVER" sent from the board. LED1 should also toggle for every two 0x7E () characters you send. 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.

Creating a Dial-up Networking Adapter on Windows

/media/uploads/nixnax/modem.jpg

To test this with 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 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 turn on as soon as you click Connect on your PC, signaling that the code detected the "CLIENTCLIENT" string from the PC.

After the PC receives the correct response CLIENTSERVER, it will try to establish an "internet" (PPP) connection with your MBED board, and you will see Verifying User Name and Password in the status box. You have just proven that a USB-PPP networking connection is possible!

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 likely 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 printfs commented out. The ping reply for a short ping (8 bytes of data) was around 12 milliseconds on the Nucleo-L476RG board at 115200 baud.

/media/uploads/nixnax/fast-ping-test.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 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 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