Skip To Main Content

Hacking Your Event Space

Posted by Scott Fitchet

Jan 31 2011

One of the best things about working at Bocoup has been the fabulous lineups of speakers we’ve had over the past year and the top-notch development squads who show up month-after-month to learn/lobby/scheme over querying, scripting, and visualizing the future.

Our event crowds have (more often than we’ve even expected) been so large that we’ve had to worry about having enough space on our current wireless router for everyone’s laptops, cell phones, and tablets.

A packed house at one of our jQuery meetups last March. Click the image to check out ejohn’s slides or more digipics from @cowboy

As someone who is at the same time a data-mining junkie, data visualization afficionado, and responsible for helping maintain our local wireless network, I wanted to track and visualize routing performance statistics enhance our ability to appropriate network resources for our employees, partners/clients, coworkers, trainees, Gratis et Libre participants, and event attendees.

Hacksaw!

The Hack

Our current Cisco wireless router happens to have a network management screen whereby we can see a list of all of the devices who have been given IP address leases from our DHCP server, along with each device’s MAC addresses and time remaining on their current session.

I’ve been working with PHP and wget lately on a few projects and decided to script some custom reports to give us more timely access to our active and available wireless resources.

Here’s a quick bash script that I’ve scheduled with crontab to run every minute that grabs an HTML page from our router. Every router is going to have slightly different managment screens so consider that part of this article your homework. If you happen to be using a Linksys E-Series router you’ll find your DHCP routing table by clicking on a button or link like this in your administration panel.

pull-dhcp.sh

#!/bin/bash

# This script runs every minute using crontab. It logs into your router
# and grabs a DHCP that will be scraped later with PHP.

HOST='192.168.1.1'
FEEDDIR='/home/sfitchet/git-repos/roto'
COOKIES=$FEEDDIR'/cookies.txt'
USER='admin'
PASS='alpine' # j/k ;)
FILENAME='/DHCP_Static.asp' # This is URI we want from our router's admin page

# Get the DHCP HTML page and save it to a temporary location
wget -E -O $FEEDDIR$FILENAME'.html.temp' --cookies=on --keep-session-cookies --save-cookies=$COOKIES $HOST$FILENAME --http-user $USER --http-password $PASS

# When the download is complete, copy the file to the production path and then
# delete the temp file.
cp $FEEDDIR$FILENAME'.html.temp' $FEEDDIR$FILENAME'.html'
rm $FEEDDIR$FILENAME'.html.temp'



Once the raw data from our router has been stored locally we can just use something like PHP to parse it into an array and then count the number of records ….

<?php

  // Grab the raw data feed from the filesystem
  $filename = "DHCP_Static.asp.html";
  $file = file_get_contents($filename);

  // Find the range of characters we'll scrape from the raw data feed
  // Sure I could regex this part but I didn't :p
  $startpos = strpos($file, "var table = new Array(") + 22;
  $endpos = strpos($file, ");", $startpos);
  $length = $endpos - $startpos;

  // Scrape the file into a PHP var
  $scrapeage = substr($file, $startpos, $length);

  // Pull the semi-formatted data into a PHP array
  $datalist = explode(",", $scrapeage);

  // Calculate the total number of active DHCP leases
  $numhosts = count($datalist) / 5;

?>

From that PHP script we now have our magic number of remaining DHCP addresses which can now be easily show on an HTML page to be reloaded every minute or so via AJAX (or even a meta-refresh if you’re in a hurry).

What Did I Learn From This?

The available data from this particular router isn’t very extensive but I think I’ve managed to learn a few things from this exercise:

  • If you’re going to be paranoid about providing enough addresses at an event, double your expected attendance number and multiply that by at least 3 devices per person.
  • We’ve been setting our IP leases to the default 24-hour span. This is perfectly acceptable for our daily bocoupers, coworkers, and workshops — but for larger events where we might be at risk of running out of address space, a seperate address range (and/or router) with much shorter lease times would help avoid network lockouts. If you’re event is overbooked, your attendees are more likely to help you conserve network resources if you can visualize the situation (or a fun way to advertise that you’ve prepared for a landslide)
  • The default software on most home and small business routers is very limited in terms of usage reports and API programming functionality. I’m very much looking forward to trying one of the freely downloadable WiFi firmware options like OpenWrt/LuCI which have Javascript APIs and lots of other goodies for the most popular small Linksys routers.
  • My favorite hostnames on the DHCP service today are: DONT-TAZE-ME, ALECTO, and ULTRA-LINCOLN.

Future Things I’d Like To Try

  • A hardware inventory of everyone who joins our network based on MAC address and stored in MySQL. There are freely available databases that identify most device manufacturers based on its’ MAC address.
  • Creating more reliable aggregate statistics of how many people show up at our events. Most of the time RSVPs aren’t very accurrate.

By The Way!

In case you haven’t heard, Bocoup is moving to an even better space next month just one block away above Lucky’s Lounge on Congress Street (yes we’re upgrading our wireless router too!). I’ll look forward to seeing everyone there and hope you’ll can help me dream up the next round of “Event Hacking”.

Posted by
Scott Fitchet
on January 31st, 2011

Comments

We moved off of Disqus for data privacy and consent concerns, and are currently searching for a new commenting tool.

Contact Us

We'd love to hear from you. Get in touch!