Get Online in McDonald's with ESP8266

McDonald's used to be the largest chain of free restrooms in the world. Nowadays, they are the largest chain of free WiFi across the United States. Every McDonald's I've been to offers AT&T WiFi services. I can walk in, connect to "attwifi" on my phone, accept the license agreement, and I'm online.

attwifi captive portal in McDonald's

The license agreement page is called a captive portal, a web page displayed to newly connected users before they are granted broader access to network resource. While it's trivial to click through the captive portal on a smartphone, if you are wearing an ESP8266 as a connected jewelry, it would not connect successfully. When I encountered a captive portal in my apartment WiFi, I made an Arduino sketch to send the packets I found through Fiddler, but McDonald's WiFi is different:

  • Each McDonald's store hosts their captive portal on a different domain.
  • The form submission step needs several parameters from the HTML, but does not use cookies.

attwifi captive portal form HTML

"Wireshark" on ESP8266: PacketDump

I dived into the open source lwip library in ESP8266 Arduino Core, and figured out how to observe raw Ethernet packets.

PacketDump.ino demo

lwip's struct netif

lwip declares a network interface structure in lwip/netif.h:

struct netif {
  struct netif *next;

  ip_addr_t ip_addr;
  ip_addr_t netmask;
  ip_addr_t gw;

  netif_input_fn input;
  netif_output_fn output;
  netif_linkoutput_fn linkoutput;

  u16_t mtu;
  u8_t hwaddr_len;
  u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
  u8_t flags;
  char name[2];
  u8_t num;

  // (some fields are omitted)
};

用yate2实现软VoIP语音通话(SIP协议)

2009年1月7日,工业与信息化部发放了三张3G牌照,标志着中国进入了通信技术的新时代。3G的重要特性之一是高速数据链路,移动上网速度大大提高。同时,中国移动也大幅下调了2G网络GPRS上网的资费。可是,语音通话费用仍然按兵不动。作为永远处于弱势的用户,我们却可以通过VoIP网络电话自己实现免费语音通话。

网络电话是下一代网络(NGN)的重要应用之一。“下一代网络”是指10年以后的网络,全部基于软交换(Softswitch)技术。但是,拨打VoIP免费网络电话,并不需要再等待10年。基于现有的TCP/IP网络,我们已经可以使用开源的VoIP软件,实现PC-to-PC的免费语音通话。(注:这里的“免费”,是指不需要支付传统语音通话费用,ADSL/FTTB/3G等上网接入仍然是需要费用的)

下面,我将介绍如何用yate2软件搭建VoIP服务器,并用SIP协议完成语音通话。在我的实例中,使用了局域网内的3台PC,Windows操作系统,接在同一个集线器上,并不是广域网或3G接入。

yate2建立VoIP服务器

Yate = Yet Another Telephony Engine,是一款开源的VoIP网络电话软件。它可以作为服务器、也可以作为客户端使用。yate2可以在Linux下运行、也可以在Windows下运行。yate2下载地址

用Lua语言编写Wireshark dissector插件

Wireshark是一款著名的网络协议分析工具,基于GPLv2协议开源,支持Linux、Windows、MacOS等多个操作系统。

Wireshark is the world's foremost network protocol analyzer, and is the de facto (and often de jure) standard across many industries and educational institutions.

Wireshark development thrives thanks to the contributions of networking experts across the globe. It is the continuation of a project that started in 1998.

Wireshark已经支持数千种协议,对新协议的支持还在不断增加。今天,你发明了一个新的网络协议,也想让Wireshark识别,你该怎么办呢?你有两个选择:

  1. 发布你的网络协议,等到有1,000,000人每天使用你的协议时,Wireshark就会支持你的协议
  2. 编写一个Wireshark插件,自己动手、丰衣足食

如果你选择了前者,请按下CTRL+D,然后在你改变主意的时候再回来。