Category Archives: Software

Mobile Wi-Fi Testing with Windows 7

In some recent mobile website testing (e.g., using Fiddler to capture Android web traffic), I’ve found it helpful to create a local Wi-Fi network on my Windows 7 laptop. This allows connecting mobile phones and tablets and ensuring the network traffic flows through the laptop, allowing a proxy configuration (like Fiddler), or passive monitoring (like tcpdump or Wireshark).

Mac Users: See my similar guide for Mobile Wi-Fi testing with Mac OS X.

The test setup I’m using has the laptop connected through a wired network cable, and using the laptop’s Wi-Fi as a local access point or hotspot:

Windows Wireless Test Setup

Windows Wireless Test Setup

Here are the steps to create a shared Wi-Fi connection:

First, connect the laptop to a wired ethernet connection. If the Wi-Fi adapter is connected to a network, disconnect it. Confirm that the internet connection is working in this wired configuration.

Next, open a command prompt in administrator mode (e.g. right click on a Cmd shortcut and choose “Run as Administrator…”).

Use these commands to create a local “virtual Wi-Fi” network, replacing MyNet and MyPassword with values of your choice:

netsh wlan set hostednetwork mode=allow ssid=MyNet key=MyPassword
netsh wlan start hostednetwork

Finally, share your wired internet connection with the virtual Wi-Fi adapter we just created. Now click Control Panel ⇒ Network and Internet ⇒ Network and Sharing Center ⇒ Change Adapter Settings. Right-click your wired internet connection and select Properties. On the Sharing tab, check “Allow other network users to connect…” and choose your Virtual Wi-Fi Adaptor. (For an example see this screenshot from my PC; the wired connection is “LAN”, and the virtual Wi-Fi is “Wireless Network Connection 2”.)

Now you should be able to connect to your local network using a mobile phone or tablet, using the network name you used above (e.g., MyNet).

Once everything is running and a mobile device is connected, you can show the current network status:

C:\>netsh wlan show hostednetwork
Hosted network settings
-----------------------
Mode                   : Allowed
SSID name              : "Variable"
Max number of clients  : 100
Authentication         : WPA2-Personal
Cipher                 : CCMP
Hosted network status
---------------------
Status                 : Started
BSSID                  : ac:81:12:2e:1a:da
Radio type             : 802.11n
Channel                : 11
Number of clients      : 1
bc:47:60:fb:1a:75        Authenticated

When you are done testing, make sure to turn off the shared Wi-Fi network:

netsh wlan stop hostednetwork

For more information, see these write-ups which helped me figure out the details of this technique:

Instead of the manual steps I list above, here are a couple of software solutions that can manage these settings for you. On my HP laptop, I could not get either to work correctly, but these may be worth trying:

Simple Webservice Echo Test

While troubleshooting some PHP Curl issues, I found and used http://respondto.it/ (and later http://requestb.in/) which allows you to create a dummy webservice endpoint which reveals the full request made to it by your code.

An even simpler use case would be a webservice that simply returned data about the request directly to the calling application. I just created such a simple echo webservice on my scooterlabs.com domain.

Update 2012-03-23: Added XML response example as well (scooterlabs.com/echo.xml).

Plain text example

$ curl http://scooterlabs.com/echo
Array
(
[method] => GET
[headers] => Array
(
[User-Agent] => curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
[Host] => scooterlabs.com
[Accept] => */*
)
[request] => Array
(
[foo] => bar
)
[client_ip] => 68.125.160.82
[time_utc] => 2012-01-08T21:33:28+0000
[info] => Echo service from Scooterlabs (http://www.scooterlabs.com)
)

JSON example

$ curl --silent curl http://scooterlabs.com/echo.json?foo=bar | json_xs
{
"info" : "Echo service from Scooterlabs (http://www.scooterlabs.com)",
"request" : {
"foo" : "bar"
},
"headers" : {
"User-Agent" : "curl/7.21.3 (i386-portbld-freebsd7.3) libcurl/7.21.3 OpenSSL/1.0.0e zlib/1.2.3 libidn/1.22",
"Accept" : "*/*",
"Host" : "scooterlabs.com"
},
"client_ip" : "66.39.158.129",
"time_utc" : "2012-01-08T22:07:54+0000",
"method" : "GET"
}

XML example

$ curl --silent http://scooterlabs.com/echo.xml?foo=bar | xml_pp
<?xml version="1.0"?>
<echo>
<method>GET
<headers>
<User-Agent>curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
<Host>scooterlabs.com
<Accept>*/*
</headers>
<request>
<foo>bar
</request>
<client_ip>68.122.10.221
<time_utc>2012-03-24T17:05:49+0000
<info>Echo service from Scooterlabs (http://www.scooterlabs.com)
</echo>

Source

Source code is up on Github: https://github.com/bcantoni/echotest. If anyone has any comments or feedback, let me know here or on Github.

“Read it Later” Apps

For a side project I’m working on, I want to support several different “read it later” type applications. Looking for apps that have both mobile support and APIs, it looks like the most popular options are Instapaper, Read It Later, and Readability.

All of these accomplish a similar task: bookmark a web page for later reading, and formatting it for easier reading. Mobile support is usually included, either for reading articles bookmarked earlier, or marking new ones to read on a desktop at a later time.

Here’s a quick summary of each service:

Instapaper

  • Free service with an optional subscription for $1/month
  • Desktop web browsing
  • Mobile: iPhone/iPad mobile app ($4.99), 3rd-party compatible apps for other mobile platforms
  • API: Simple API (username/password), or Full API (xAuth flavor of OAuth)

Read it Later

  • Desktop: Firefox extension, bookmarklets for others
  • Mobile: Android (pro $0.99), iPhone (free, or pro $2.99)
  • API: Yes, username/password

Readability

  • Subscription service at $5/month (70% of which goes to authors & publishers); $5 is minimum, can do more
  • Desktop web browsing: Yes, also Firefox extension
  • Read Now in browser free, Read Later & Mobile for subscribers only
  • Mobile: Web apps (Android, Blackberry), iPhone/iPad: web now, integration with Instapaper app coming soon
  • API: OAuth

I’ve just started playing with each of these apps and their APIs and will hopefully post more feedback on each.

Fiddler Web Debugging Proxy With Any Browser

Fiddler is an extremely useful tool for debugging any web traffic on Windows environments. From their website:

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and “fiddle” with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

I originally used Fiddler back the early days with Internet Explorer, but have recently picked it up again for use with several different browsers. Although some browsers have more native capabilities now (like Firefox with FireBug), using Fiddler consistently makes it a bit easier to concentrate on the problem at hand rather than the tool itself. Fiddler can also handle and decode HTTPS traffic now.

Setting up Fiddler with different browsers is pretty straightforward:

  • Internet Explorer: No changes needed; when Fiddler is running it will automatically pick up all IE traffic
  • Google Chrome: Same as IE (automatic)
  • Apple Safari: Same as IE (automatic)
  • Opera: Same as IE (automatic), but may need to start Fiddler before Opera
  • Firefox: Change network options to use the HTTP proxy at address 127.0.0.1, port 8888; also see the Fiddler Firefox addon
  • Curl: Curl from the command line is very useful when testing webservices; to route through Fiddler, just include the proxy option like --proxy 127.0.0.1:8888
  • Other Apps: See the Configuring Clients help page for any other application which lets you configure a proxy
  • Mac/Linux: For cases where you need to debug on a different platform, you can still route traffic through Fiddler on a Windows system; after starting Fiddler, set up the application on Mac/Linux to use the proxy at windowshost:8888

For more background and “how-to” guides to get started with Fiddler, check out the Fiddler help page.