# Energy-Efficient Hosting Rich Content from Mobile Platforms with Relative Proximity Sensing
## 4 On-Demand Wi-Fi Connection to Nearby Mobile Devices
### Establishing Connectivity  
After the Wi-Fi radios are turned on, the next step is for mobile devices to connect to the appropriate BSSID (Basic Service Set Identifier), get an IP address and learn the IP address of the other mobile device. In our current implementation, mobile devices of _T-Wing_ are equipped with N150 micro wireless adapter [34] as a Wi-Fi network module which works in IEEE 802.11n. The Wi-Fi network modules of _T-Wing_ are configured for ad-hoc mode to communicate with nearby other _T-Wing_ devices. All mobile devices participating in _T-Wing_ are configured to use the same channel number. After the mobile devices get connected to the appropriate BSSID, they are assigned a non-conflicting IP address by the proxy server, which thus takes on the role of a kind of DHCP (Dynamic Host Configuration Protocol) server. We note that the mobile devices cannot use a real DHCP server, since this is a peer-to-peer network. Also, it would be highly inefficient to use autoconfig to assign themselves a non-conflicting link-local IP address since autoconfig takes 10 s of seconds to send an ARP request and avoid conflicts. Finally, we note that simply selecting IP addresses at random is insufficient with IPv4. IPv6 would be the perfect solution for this problem: it has a very large number 23 of available link-local addresses. Specifically, due to the Birthday Paradox, there is a high likelihood of an IP address conflict even with relatively few neighbors in proximity. When the proxy server notifies the mobile device to wake up, the mobile device is assigned a link-local IP address. This address is only valid for the current network association between a mobile device requesting the content and a mobile device hosting the content, i.e., until the Wi-Fi connection is turned off. Similarly, the mobile device requesting the content is also assigned an IP address by the proxy server, and the proxy server informs the requestor of the IP address of the mobile device hosting the content. At this point, the mobile device can access the hosted content over IP from the nearby mobile devices.  
Assuming that a mobile device participating in _T-Wing_ makes a Wi-Fi connection just for a one-time accessing of small size of web content in a peer-to-peer manner, it may hinder user experience.  
Figure 2: _T-Wing_ protocol for discovery and on-demand Wi-Fi activation.  
This is because the network association consists of several operational steps. These include: (1) a connection to the appropriate BSSID; (2) an IP address assignment; and (3) a reception of the IP address of the other mobile device. However, once the network association is successfully completed, _T-Wing_ does not require additional network configuration for a continuous web transaction with the mobile device hosting rich content; hence, _T-Wing_ can provide an energy efficient communication channel with a relatively small percentage of network association overhead, in case that the mobile device accesses directly the mobile device hosting rich content over the Wi-Fi.  
Finally, in case the Wi-Fi radio of a mobile device is already connected to an AP while being asked to connect by a neighboring mobile device, we can use Virtual Wi-Fi [35] to simultaneously connect to the Wi-Fi network as well as the _T-Wing_ peer-to-peer network. This solution has the extra advantage that it seamlessly scales to the setting when a client wants to access content from multiple mobile devices.