Tweeting a torrent

A friend asked what the best way to tweet a Torrent would be. I thought the obvious thing would be to tweet the magnet link, but those tend to be too long to fit in 140 characters and Twitter’s URL shortener doesn’t work on magnet: links.

Why are magnet links so long any way? Here’s a working magnet link to a copy of wikipedia, an 11GB file named enwiki-20140707-pages-articles.xml.bz2:


That’s awfully wordy, let’s break it down and futz it to be readable.


The important thing is the hash in the xt parameter. That uniquely identifies the content and it can be addressed as such via DHT discovery. Those tr parameters just list trackers, which you don’t strictly need thanks to trackerless torrents. Indeed, the following 61 character URL works fine in Transmission.


It’s not very convenient though. It lacks a filename, file size, etc. Startup time is (theoretically) slower as we have to discover data. I also don’t know how much of a performance impact removing the tracker list has, if any.

Of course one could add some of the missing bits back. “dn” is the displayed filename, “xl” is the file size.

The xt parameter is a bit subtle; there are at least 9 different hash algorithms that can be specified. BTIH seems to work well for torrents.


Home surveillance cameras

I want a security camera for my house, for when I’m away. Nothing too creepy or serious, just some peace of mind so I can see if a package got delivered or if the propane delivery guy came.

tl;dr; I’m going to try ZoneMinder with an Axis M1034-W camera.

The mainstream product everyone recommends is Dropcam. But it and its competitors all work by uploading a video feed 24/7 to a server they host which then does the processing to do useful things like only show video clips of motion, etc. They tend to charge $10/month for the hosting. And it’s a lot of bandwidth. So I’d rather roll my own, using my own Linux server. (Yes when Jack Bauer breaks in, Chloë will be able to knock my surveillance offline with a Linux zero-day. That’s not my threat model.)

The hacker solution for this stuff is surprisingly unclear. On the Linux video collection side, motion(1) is a popular low level tool for doing motion detection from video feeds. ZoneMinder seems to be the high end tool of choice for managing multiple cameras. It works with a lot of stuff including video capture devices hard-wired to the machine and network cameras.

I’m baffled by the choice of camera hardware. I decided to try Axis because they have a developer program, ZoneMinder works well with them, and they have a reputation for being good but expensive. I only need one camera so expensive is OK. The M10 line seems to be the low end stuff, $200 instead of $400+. The M1034-W is the WiFi option. They also make wired POE stuff which seems like it’d be good for outdoor use.

That’s all research. I ordered the camera, will tinker with it next week.


LoL lag on Wifi

When I play LoL with a wired connection to my router in Grass Valley it looks like this. But when I play via WiFi it looks like this. Periodic ping spikes, from the usual 85ms to 170ms or so. Note the packet loss number is the same, about 10 packets/s. This ping pattern is not particularly noticeable while playing, but sometimes on WiFi I’ve had serious lag, disconnects, etc. Not so much when wired.

The WiFi link is as good as it could be. I’m 10 feet from the router, clear line of site, 30dB SNA. 802.11n, 5GHz, relatively quiet network. Either there’s something broken with the hardware or else WiFi really is just this unreliable. Need to experiment more. I sure wish I knew what algorithm LoL used to report ping. Last time I did the packet dissection work it looked like it was the RTT time on special ping/pong packets. Maybe they get lost and are retransmitted?

OpenWRT second impressions

I’ve been running OpenWRT for a few days now. I like it. I also don’t like it. I’m going to keep running it, and will probably install it on any new routers in the future.

The part I like is it feels like a “real Unix”. I trust that it’s going to do its job right, or if it doesn’t I have access to look inside and figure out what went wrong. Tomato has always been opaque, and if it rebooted itself or didn’t do something I wanted I felt powerless to understand or fix it. With OpenWRT it’s all just a Linux distro.

The part I’m on the fence about is that it’s “real Unix”. In particular, that it’s super complicated. The ipchains have some 100+ rules in them, which really are defining about seven “zones“, which really are 4 physical interfaces and maybe 6 aliased interfaces. It’s great that the system is so flexible, but then it also makes even simple things hard.

vnstatThe part I don’t like is that it’s a “real Unix”, complete with that awful lack of usability. You can configure everything but you also have to configure everything. That’s a grand old Unix tradition, see also: Linux-on-the-desktop. As an example, I’d like a simple counter of bandwidth used per month. There’s none installed by default. But here’s a list of 17 tools that might do it. Only a few of those have Web UIs, and only ~half of them are installable via the package manager. And none do precisely what I want, the best I could find is something that churns out hideous 1990s-style gd images. Of course I could build my own, it’s Unix! But I don’t want to build my own.

I think there’s a need for a new router firmware, a nicely packaged distribution based on top of OpenWRT. Take the stock OpenWRT and add the packages that ordinary home router users need. Maybe write / package a few other things, like the monthly bandwidth monitor I would like. Then stick them all together with a nice GUI that ordinary technical savvy people can use, not just Linux/networking experts. Tomato is the model for this, the core Tomato firmware was a beautiful, well documented product. Tomato-on-OpenWRT would be terrific. It all seems doable, OpenWRT is a strong foundation. The only thing I’m not sure about is how hard it’d be to build the web UI. Luci is pretty flexible as a foundation, I think what I’m describing could just be a skin and set of Luci apps. But not sure.

Automatic: driving history

For two years I’ve had an Automatic tracker in my car, a gizmo that downloads data off the diagnostic port and uploads it to an iPhone app via Bluetooth. It tracks things like speed, mileage, etc but it turns out the most interesting thing it’s actually tracking is where I drive. But it’s not that interesting, and I’ve always been a bit nervous about the privacy implications of it, and rather than pair it to my new phone’s Bluetooth I’m going to stop using it.

Some summary stats from it:

  • 613 trips since September 2013
  • 11,290 miles in 252 hours. Average speed: 45mph.
  • 25 MPG average, $1600 in fuel

By far most of the hours in the car have been the 150 miles on I-80 between SF and Grass Valley.

The main use case the developers have in mind seems to be a nanny to encourage you to drive better. You get a “Score” that’s dinged down for driving over 60 mph, or braking too hard, or whatever. I found that condescending and useless. The IFTTT integration was sort of nice for creating data in Dropbox, but it wouldn’t export the GPS track. The product got a lot more useful when they added the Dashboard, with some nice Mapbox views of the data. Still I don’t have much use for collecting the data.

Here’s a heatmap they produced of all my driving. You can see all the I-80 trips, plus a long trip down to LA and back. Occasional detours through Stockton or Yuba City.

Automatic heat map

OpenWRT: persistent DNS entries

One wrinkle with OpenWRT: if the router reboots, it loses the DNS entries it was giving based on DHCP leases. Even the ones you’ve configured as static DHCP leases, they don’t show up until the client host renews its DHCP lease. Forum discussion suggests this is because dnsmasq is reading from the dhcp.leases file which is stored on tmpfs, not permanent storage.

The simple workaround is just to manually add the host in /etc/hosts and restart dnsmasq. It will serve those entries to DNS clients. That means the client’s IP address is now stored in two different places, which is not ideal, but I can live with it. There’s some discussion of other solutions for this like moving the DHCP lease file to permanent storage or changing the configuration tool to manage parallel entries in both DHCP and dnsmasq. As of 15.05, none of that seems to be happening.

I’m liking OpenWRT now. It’s comforting working with a router that’s a full and proper Linux distribution. It’s also sort of overkill, but on the balance I like it.