Some Bits: Nelson's log

50 posts in 2020

Ubiquiti failover problems

On the back of my problems with a flaky WAN link I’ve had a different problem with my Ubiquiti router: it would fail over from the WAN link (when it was down) to my LTE backup, but then not return once the WAN link came back up. Not every time, only three or four times in several months. But that’s obviously no good.

More details are documented in this public post and this private support ticket.

Long stort sort, I got escalated to tier 3 support. I’ve made two changes at their suggestion. One was to switch the watchdog ping address from ping.ubnt.com to 1.1.1.1, mostly to skip DNS resolution in the “is the network up?” test. The other was to turn on smart queuing, which apparently might magically fix the routing problems I was seeing.

I changed the ping address Nov 21, and the smart queueing was enabled Dec 9. Meanwhile I haven’t seen my WAN link flake out once since Dec 1. No explanation for that new stability, the router was last rebooted Nov 29 or so and there was flakiness after that. But with the WAN link behaving solidly there’s no chance of the routing failover messing up.

So.. still confused as to what caused the problems I saw. I suspect they’ll come back.

Update: the came back. WAN started flaking out today, Dec 20, at 11:59am local. No hint the failover isn’t working though.

Windows 10 sound output devices

Windows’ model of sound output has always confused me but I think I finally figured it out. Particularly how it interacts with apps like Zoom and games like World of Warcraft. Here’s some notes.

Jump down to the section on “Application output device” for the juicy bits on “why isn’t sound playing where I want?”

Output devices

Your Windows system has a set of output devices; placees it can put sound out on. Typically these correspond to hardware devices you own like headphones or speakers, but can also be virtual sound devices for capturing audio, modifying it on passthrough, etc.

The easiest way to see your sound devices is to open the Sound settings. Right click on the volume / speaker icon in your taskbar, or open Settings, click System, then click Sound. You’ll see something like this:

The drop down (“Speakers”, here) lets you choose what your system default output device is. Most apps will play sound to that device. This notion of “default” is the cause of much confusion, read on for more.

Clicking through to “Manage sound devices” gives you a couple of extra options:

There’s a “test” option for each device. Also the ability to disable sound devices. This is useful for annoying devices you never want to use. Like the Acer X34, which is the option to send sound out my video cable to my crappy monitor speakers. Never ever want to do that, so it’s disabled.

Windows has like ten options for setting the sound volume. The most complete one I know is “App volume and device preferences”, you can get there by pressing the Win key and typing “mixer”.

The “Master volume” is the output level for the current selected default output. Each output device has its own remembered master volume that you can change by switching output devices first. Also there’s a per-app mixer available for some but not all apps. I don’t know what populates that list but it’s obviously not very complete.

Application output device

Every app gets to choose which device it sends sound output on. Most apps just send to the system default and you have no control over that. A few specialty apps like Zoom or games with voice chat let you control the output device, typically in the System settings.

Zoom outputs
World of Warcraft sound

Choosing a new sound output can be handy particularly for voice communication systems. Maybe you want most system sound out the speakers but your friend’s voice on zoom in an earpiece. But for most apps “System default” is what you want. But here’s the gotcha:

The system default device can change while the app is running. Most apps will detect that change and switch sound to the new output device. You turn on your Bluetooth headphones and now sound is going out those headphones. Neat! But World of Warcraft is an exception. If “System Default” is selected it will not switch to a new output device even if the system default has changed; it will keep playing to whatever was the default when the game was launched. I suspect other apps do this too. It’s a bug IMHO.

Changing default output device

When you plug in a new device it usually becomes the default output magically for you. Often that’s what you want. But it can become confusing, particularly when you then unplug a device and the default output switches back to something. If you’re not hearing sound, first thing you should check is what Windows thinks your default output device is at the moment. 9 out of 10 it’s that HDMI monitor you plugged in.

I’ll say it again: if an app is playing to the system default and you change the system default, most of the time the app will switch to that new output device. But some apps don’t detect the change. It’s very confusing.

A special note about wired headphones. The headphones I have are implemented as a separate output device. Both my speakers and headphones are plugged into separate motherboard jacks and the Realtek S1220A sound chip implements genuine separate devices for each. Other motherboards do something special with headphones where when you plug them in they electrically intercept the speaker output and divert sound to the headphones. But Windows is 100% unaware of this diversion. My old Realtek ALC887 motherboard did this. If yours does, you will not see a separate headphone device and there’s no way in software to switch between them.

Sound input devices

For the most part, all the notes I wrote about output devices apply to input devices as well. There’s multiple input devices, there’s a default input device, switching between them is a little confusing.

Except: Windows 7 had an idea that there were two default input devices; “default device” and “default communication device”. You can still change the latter if you go to the old Control Panel. In theory that communication device was for voice chat and the other default device was.. your high end microphone for studio recording? No idea. This default communication device concept also applies to output devices. I don’t think many apps ever used the idea much and it seems deprecated in Windows 10.

Also except: some microphone devices have a “Boost” option to make them sound louder. And/or a separate input gain control. I’ve never understood why, it has something to do with line levels or something. Anyway if no matter how loud you talk you’re too quiet, the boost can help you. Only my Realtek headphones have this (not the Microsoft LifeCam), I get there via Settings / System / Sound, then clicking “Device properties” on the microphone, then Additional device properties. That puts me in an old Win7-style app, where the Levels tab has a boost option. I suspect every sound driver is different.

Also also except: you have your choice of sound format that a Realtek microphone puts out. Bitrate, bits per sample, etc. Mine got set to 32 bit output somehow and no other apps worked; the mike was responsive but all you could hear was static. Setting it to 44.1kHz, 16 bit fixed it. I’m not sure what’s required to have 32 bit audio working in Windows, but I sure don’t need it for my voice chat.

Steam Link tricks: keyboards, tablets

In this post: how to play PC games on your TV or tablet computer.

Steam Link is Valve’s half-abandoned technology for streaming PC games. The original product idea was you’d install PC games on your fancy gaming PC, then stream them to a cheap streaming video device on your TV so you could play on your couch. They got it working reasonably well at 1080p on a wired home LAN, but it never succeeded in the market and you can’t buy the hardware anymore.

For me the real problem was the Steam Controller which was not only a bad game controller, but also a really bad fit for PCs keyboard-and-mouse user interfaces. They did their best but it sucked.

But what if you don’t use the Steam Controller and use a regular keyboard and trackpad instead? Turns out that’s pretty easy, particularly with the excellent Logitech K830 wireless keyboard/trackpad. I’ve now been playing games like Dicey Dungeons and Crusader Kings 3 three different ways.

A long HDMI cable is by far the easiest way. Just set your TV up as a second display for your PC, no Steam Link required. Use the K830 as a second keyboard/mouse for the PC. Obviously only works if you’re in range to run the cable. HDMI 2.0 (required for 4k) only works to 35 feet or so; beyond that you need some sort of expensive fiber or ethernet conversion cable. Or wireless.

Steam Link hardware. You can’t buy this new anymore, but if you have one lying around or buy a cheap used one it still works perfectly well for 1080p display. You can plug the K830 wireless adapter into the Steam Link’s USB ports and control it from there. Works a lot better on wired LAN but wifi is possible. Resolution matching is a little fiddly but I’ve had good luck if I run my PC at 1920x1080 first, Steam Link will sync to that pretty well.

Steam Link on a tablet. Just tried this on my Samsung Galaxy Tab 5e and it’s pretty brilliant; there’s Steam Link clients for both iOS and Android. No easy wired LAN option but the WiFi seems pretty good other than some minor graphics and sound glitchiness. The mixed bag is the control; with no other hardware, Steam emulates a simple gamepad with touch controls. But it also emulates a mouse with touch controls which is all you need for playing a fully mouse-UI game like Dicey Dungeons. For more complex UIs like Crusader Kings 3 I’m back to keyboard-and-mouse. Pairing the K830 via bluetooth to the tablet works great, it becomes fully usable in the Steam Link Android client.

I’m amazed how well all this works. But in retrospect it’s pretty simple. The only drawback is that while the K830 is a nice portable keyboard/trackpad, it’s really not a gaming mouse. Not even a full size keyboard. Not great for faster games that require precise mouse input. One alternative is a Corsair lapboard with matching wireless keyboard and mouse of your choice. That gives you a full size desk-like setup, but be aware it’s pretty big.

QGIS fun with LIDAR data

After fooling around with DEM data yesterday my buddy Mike did some nice work for me and gave me LIDAR data. Nnot raw LIDAR data but rather processed data; gridded DEMs of various sorts. The raw data comes from an August 2018 LIDAR survey of my area. I’m no expert at LIDAR at all but I learned enough to be dangerous, so here it is.

The raw data comes in LAZ files, which are basically point readings; a laser reflected off of something at that specific XYZ. Mike’s Makefile munges that through las2las, las2ogr, and ogr2ogr to get it into a specific reprojected GeoPackage file. Then gdal_grid does the real magic of looking at all those random points in XY space and mapping them to a uniform XY grid suitable for a raster DEM. From there you can use normal DEM tools.

The neat thing is LIDAR gives you multiple Z values for a specific X, Y coordinates. Ie: that there were reflections for a particular spot at, say, both 2103.37 meters and 2122.93 meters. What could that mean? In a word, trees. Sometimes the laser penetrates the leaves and reflects off the ground, sometimes it bounces off the leaves. That sounds noisy, but it’s super useful.

The trick is if you take the minimum elevation at every X, Y then you get a DEM of something like ground level. Not exactly; buildings will show higher, so will the middle of a tree trunk. But it’s pretty close. Similarly if you take the maximum then you get the height of the tree at that spot. And if you take the difference max-min you get the tree height. More or less.

So that’s what’s shown on my map above; tree heights from 0m to 25m rendered white to green. Isn’t that neat? The choice of 25m is important; too low and all the trees look the same, too high and you can’t see all of the forest for trying to emphasize the one tree.

A quick Google Search suggests it’s possible to write a tree classifier that looks solely at LIDAR data and knowledge about the biome and estimates a tree inventory by species. Helps if you can compare summer and winter images.

I tried also using a discrete color scale to color the tree height in categories. Flat ground (white), low brush (brown), small trees (light green), and big trees (dark green). It sort of works, I think the data picture below is fairly accurate, but it’s also pretty hard to read. Also it doesn’t tell me anything about what I really need to know, which is where there’s brush underneath trees.

I also experimented with using the LIDAR data to make contours. Honestly the result isn’t better than what I got with the 1/3 a.s. DEM file. It’s much noisier and the extra accuracy doesn’t much help. LIDAR contours in red, DEM contours in grey. I suspect if you really want to get a proper elevation map from LIDAR data alone you need to work harder at smoothing the data and discarding errors.

QGIS fun with elevation data

My neighborhood association is assessing what we need to do for fire safety on a plot of land we own. I’ve been having fun in QGIS mapping various aspects of the land. Particularly like this abstract example:

That’s showing the lot boundary (purple), the river (blue), a trail (mauve), and a powerline (black). And then 1m contours in light grey. Not a great map for navigation, but it does a nice job showing the terrain contours. Also it’s just kind of abstractly pretty.

Couldn’t be easier to do this stuff. Grab NED 1/3 arc second data off the National Map. Crop that DEM to a small region in QGIS, then have QGIS calculate contours, and Bob’s your uncle. QGIS is such a powerful tool. And cheers to GDAL doing all the work underneath.

Mapping Enga Province

I just finished a fun project; making a couple of maps of Papua New Guinea’s for a friend’s academic book chapter. I’ve never really collaborated with someone this way for a print publication and it was a good experience. Also this may sound goofy but the audacity of mapping PNG was part of the appeal; it’s a famously unmapped place.

The main map is a regional overview of Enga Province, in the PNG highlands. Also a detail map of the Porgera Valley area; the mine and various villages. Enga is not huge; 4500 square miles, a bit smaller than Connecticut, and with 432,000 people. It’s also very remote and mountainous and very thick with vegetation. It’s in that part of PNG that’s classic “uncontacted tribes” territory, although that was all 50+ years ago and a lot of folks there now have cell phones and Facebook. (David Attenborough’s A Blank on the Map is fun for the flavor, although it’s a different part of PNG.)

Online maps are pretty limited, but there are some beautiful paper maps going back to ground surveys in the 40s to 60s. To give you an idea of how limited digital maps are, here’s Google, Bing, and OSM. (They do get a bit better if you zoom in to the population centers like Wabag and Porgera.)

So my job was to produce an overview map of Enga to help readers orient to places named in the text. Also a detailed schematic view of Porgera. High res copies are available here.

Data: OSM and SRTM

The first challenge was getting data. The key things I wanted to draw were roads, rivers, and settlement locations. Secondarily I wanted to convey the terrain somehow, and for the Porgera area also map specific features related to the mine.

I went through a lot of data sources; Natural Earth, PNG government data, academic datasets, random shapefiles that fell off the back of a truck. Most of it proved not very good: incomplete, or old, or limited. Some exceptions though; the PNG government has a great dataset for the names of rivers, for instance.

I ended up mostly using OpenStreetMap data for rivers and roads. Several people have done a lot of excellent work mapping very detailed specifics of Enga Province; the street map of Paiam is a thing of beauty. The rivers were a bit spotty, I think there may have been some data loss at some point in OSM’s history. But the data was a comprehensive, uniform collection and I could fill in a few missing rivers with data from the Humanitarian Data Exchange. (I’m very curious where their data came from!)

I got the OSM data itself from the French OSM extracts. Excellent simple data source, grouped by country. I imported the PBF directly into QGIS, no conversion. Working with its unusual schema is a bit awkward but once you get used to it it’s not so bad.

For settlements I couldn’t find a dataset anywhere that worked great. I ended up getting a list of placenames and rough locations from the author I was working for, then painstakingly placing the dots precisely in the center of each of what looked like the “right cluster of houses” on aerial imagery. I also went back to some of those old 60s maps for ideas of where things might be, lots of fun. A similar process was used for the mine maps, although it helps that other people had done similar maps so I was never trying to do unique original data work.

That leaves terrain. This part’s easy! SRTM v3 for the basic elevation data, colored by 500m contours. Then overlaid on top of that a greyscale hillshade (courtesy of Mike) blended with hard light. I like the result, although it’s a bit noisy for print. Looks great in color on a screen though. (Extra detail: a 2600m contour line from OpenDEM to highlight the limit of cultivation of staple food crops.)

Design

The visual design is the part I’m not entirely happy about; my skills are more with data wrangling than aesthetics. I mostly went with very basic choices where I could; plain Arial font, plain standard map symbology, etc. I’d say the result is “adequate” but not beautiful.

For inspiration I drew on this Wikipedia map of Hawai’i. This 2008 SVG map is a thing of beauty, frequently cited as good design for Wikipedia. For map symbols I borrowed ideas from Wikipedia’s map template SVG although I ended up diverging quite a bit. Drawing roads with casings sure turned out complicated.

One thing I learned more about; text halos or buffers. It’s common to make labels stand out against busy backgrounds by rendering the text in black with a small white outline. Or so I thought. Actually it works better if the outline is light grey with 50% or more opacity; the white/black is too contrasty. QGIS lets you create buffers for labels directly. If you need to do them yourself in HTML/CSS, something like -webkit-text-stroke: 1.5mm rgba(255,255,255,0.5) works.

Software: QGIS

I did the whole map from start to finish in QGIS, mostly version 3.14. QGIS has come a long way and I’m very impressed with it, particularly for an open source tool. The UI is mostly accessible and if you can’t figure out how to do something (like, say, smooth a polygon) you can find an answer online. It has some baffling UI choices, like moving a vertex of a polygon isn’t animated. Also some bugs and weird limitations. I never could figure out how to edit the colors in my legend, custom symbols just wouldn’t take. But QGIS has a lot of complexity and power in a fairly usable package.

My favorite thing with QGIS is how great it is for experimental mapping. Early on I just loaded every single data layer I could find. Six different sources for rivers, four for roads. A bunch of scanned paper TIFFs I’d georectified. 30+ layers for me to tinker with, overlay, all to figure out which data sources I’d really use in the end. Lots of fun.

The part that sucks in QGIS is the Print Composer. The main map editor is lovely and taking screenshots from its display works great. But the moment you want to export a precisely defined PDF or a large raster image, you need to use the Print Composer. The composer is also where you add things like titles, scale bars, legends, etc.

Most of the composer works OK but it’s clumsy. The real problem is it’s got a whole different renderer! And this renderer does very different things for labels. I must have misunderstood something fundamental about print scaling, because a label would be a tiny little thing on my edit map and then this huge blob of word on the print map. And because labels try very hard not to be on top of each other, there’s was an enormous amount of hand tweaking and verification and testing to get everything correct. (Also a couple of map layers of fake curved lines just so I could put text on them). Seriously I was pulling my hair out with labels. I gather this is always the case in mapmaking but the inconsistent rendering algorithms really makes it hard.

OSM and Wikipedia?

So now I’m done; map submitted to the author. For now. I’d guess I spend 50-80 hours on this project, although someone focussed and better at QGIS could have done it in under 20. I spent a lot of time learning things I didn’t need to, PNG is fascinating!

We’ve talked about having a goal of making maps for all the PNG provinces for Wikipedia. I’d like to do that and I’m pretty well set up for it. The main thing stopping me is Wikipedia culture. The last thing I want is to do a bunch of hard work and have some gatekeeper come in and invalidate all my work without even an explanation.

I went looking for Wikipedia mapping standards and didn’t get real far. This conventions page has useful guidance but I can’t tell if it’s authoritative; a lot of it hasn’t been updated meaningfully since 2012 or so. When you dig into the tutorials, etc for mapmakers a lot of it ends in 2008 with excellent guides written in French for Inkscape. Back then QGIS wasn’t really realistic, now it is. That or even a custom automated software render pipeline, no hand editing at all.

What I really need is a Wikipedia map mentor, someone to work with me to get that first submission right so my work is accepted. Either that or maybe I’ll just put the map I have now on the page and see what response it gets.

One weird trick to improve network latency

A smokeping from my house to 8.8.8.8

Can you spot the moment PG&E cut the power to our area? The network (and my house) are on backup power, so I’m still online. Looks like a whole lot of other customers aren’t though. Pings dropped roughly from 52ms to 42ms. It’s the fastest I’ve ever seen, even faster than at 3am.

It’s possible that what’s really going on is a different route is being used now that power is down. Here’s the route I have right now:

                                       Packets               Pings
 Host                                Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. setup.ubnt.com                    0.0%    21    0.7   0.7   0.4   1.1   0.2
 2. 10.33.1.1                         0.0%    20    0.9   1.0   0.7   1.4   0.2
 3. BR-Switch_tik-a.ppk.sbbnet.net    0.0%    20   25.5  32.3  19.4 105.4  17.6
 4. 172.16.1.149                      0.0%    20   23.8  31.2  21.3  81.4  13.0
 5. 172.16.1.138                      0.0%    20   32.0  35.6  17.5  80.4  12.1
 6. ether4_tik-c1.crx.sbbnet.net      0.0%    20   30.9  29.4  18.4  41.2   6.2
 7. Gi022_rtr-e.crx.sbbnet.net        0.0%    20   24.1  28.5  17.6  36.1   5.4
 8. pr02-ae12.sea09.net.google.com    0.0%    20   37.4  45.2  32.6  51.7   5.2
 9. 74.125.243.193                    0.0%    20   51.5  45.5  34.8  58.1   6.4
10. 209.85.254.237                    0.0%    20   48.7  45.9  33.4  56.0   6.1
11. dns.google                        0.0%    20   69.1  50.3  39.0  75.4  10.4

Edit: one weird trick to increase latency! Note graph is 30 hour time scale.

The long steady part at left is Smarter Broadband, you can barely see the little dip in latency from 50ms to 40ms I reported above. The outage is when both they and AT&T cellular were down. Then I switched to AT&T cellular with 150-400ms ping times to Google DNS overnight. Just about 7am that let up to 500ms ping times. It’s still working, but they must be severely congested or something.

Here’s an mtr:

                                       Packets               Pings
 Host                                Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. 192.168.3.1                       0.0%   134    0.7   0.7   0.3   1.1   0.2
 2. 100.127.125.128                   0.0%   134    1.6   1.3   0.8   1.7   0.2
 3. 100.127.173.124                   0.0%   134    2.1   1.8   1.2   5.0   0.4
 4. 107.94.133.11                     1.5%   134  551.2 397.4  89.4 955.8 125.3
 5. 166.185.45.162                    4.5%   134  535.3 393.0  80.5 643.1 112.0
 6. 192.168.192.74                    2.2%   134  517.8 430.0 108.2 1094. 124.8
 7. 192.168.196.8                     3.0%   134  538.8 430.3 108.9 1058. 125.7
 8. 162.244.250.1                     5.2%   134  557.3 432.1 106.9 1017. 120.6
 9. 162.244.250.54                    3.7%   134  506.6 434.2 117.5 966.9 120.9
10. (waiting for reply)
11. 148.66.238.120                    1.5%   134  488.9 450.1 123.0 934.0 130.0
12. 148.66.238.125                    6.0%   134  534.0 448.3 128.7 932.0 126.8
13. 148.66.238.99                     3.8%   134  539.3 456.0 121.8 881.6 130.0
14. 148.66.237.195                    3.0%   134  592.4 452.5 121.6 845.8 129.0
15. 4.59.30.121                      92.5%   134  580.4 511.9 313.3 759.1 122.6
16. 4.69.141.154                     89.5%   134  550.0 451.5 329.1 569.9  85.7
17. 72.14.203.208                     3.8%   134  624.7 468.0 164.4 850.5 117.8
18. 216.239.56.153                    5.3%   134  577.3 493.0 204.1 3320. 287.9
19. 216.239.42.153                    3.0%   134  578.2 459.6 137.2 831.6 118.2
20. 8.8.8.8                           1.5%   133  594.3 458.0 155.7 781.3 118.8

One more latency graph, shorter timescale. Most of this time is on AT&T’s cellular network until the very end (one short period, then the end). There’s jitter and then there’s jitter, you know?

QGIS: drawing roads with lines in casings

Many maps follow a sort of standard for symbology where roads are drawn as brown-orange-red lines with black casings around them. Like this, from a Wikipedia style guide.

QGIS has almost no support for drawing lines with casings, as common as it is. It’s something of a right of passage for map makers to figure out how to do it. I think I figured it out finally but I’m not an expert; please correct me in comments if I need it. This StackOverflow question is also helpful.

The basic idea is to draw two lines; a thick black line, then the thinner orange line on top of it. That’s simple enough. But it’s subtle and if you do it wrong all sorts of ugly things can happen.

Part of what makes doing this hard is that in most GIS data sets, roads aren’t just one single line. Particularly in OSM data roads are many line objects that are separate, little segments of road, and they just happen to overlap / join up right. Those joints can look terrible if you draw things wrong, see below. Also the intersections between roads need special attention.

I should note up-front that it’s important to test your results in whatever output format you’re really going to use. The on-screen preview in QGIS looks nice. But if you use the layout manager to compose a print run, know that the layout manager renders differently than the preview. Worse you’re probably really rendering to PDF or SVG, so you really have to look at those output files. And if you care about print, well, print it; the printer will change the way it looks once again. Most of the screenshots here are going to be in the main QGIS edit / preview mode.

The simplest thing is to just style the lines for your roads with two overlapping lines , like this in the Symbol Selector. Note the order matters!

In this case I have the black line as 1mm and the orange line as 0.6mm. Something like this is available as a default symbol in QGIS, the “Topo Main Road”.

This mostly works, and you should try it first and see if it’s acceptable because it’s so simple. However if you look closely, you’ll see small errors in the black casing. Particularly for roads made of many line segments. You can fix some of these by fiddling with the cap style; “flat” on the black line and “square” on the orange line works best for me. Here’s what square/square looks like blown up to 4mm to exaggerate the problems:

Another drawback with this simple approach is you don’t have any control over road intersections. They can end up looking terrible.

The more complicated drawing option is to have two layers for roads; one for the casings and one for the orange lines. You don’t actually need two full GIS layers though, you can also just duplicate the line data in the symbology classifier. In this case I’m using an OSM PBF extract with a Rule-Based Layer. (You might also be able to do this with a Categorized layer, but that type is less amenable to having multiple symbols for one type of data.)

If you just try this straight it might or might not work. The problem is that the order of these lines is not consistent in QGIS; they don’t necessarily draw in the order you have the rules in. To fix that you have to enable symbol levels (more info). This lets you specify the z-order of the symbols to control what order they are drawn in. Higher numbered levels are drawn on top of lower levels.

Note I’ve added in some extra complexity here; multiple sizes of roads. The general rule is you want to draw small roads first and then bigger roads on top of them. So the primary road is given the highest level, 15, so it draws on top of secondary and tertiar.

In this case I drew the casings right before the roads; doing things in that order makes it so the primary road has an uninterrupted casing. Here’s a sample of some roads of different sizes blown up to exaggerate the lines. (And the glitches in the casings, sigh. It looks better at normal resolution.)

Another option is to draw all the casings last, after all the roads. (Ie: have secondary’s orange line higher priority than the primary casing.) Doing that results in something that looks like this:

I’m not actually certain which is correct. I like the former better, so I’m doing that. Google Maps and the beautiful hand-rendered maps by Imus Geographics do the latter, so maybe I’m wrong. Honestly at normal map sizes you’d need a magnifying glass to see the difference.

One last note: symbol levels seem to only be relevant within their map layer. A symbol with a high level but in a lower map layer will not overdraw a symbol in a higher map layer.

So there you have it, roads with casings. And imperfections. I don’t know if it’s possible to actually do better in QGIS; I should really ask an expert. I sure wish QGIS just had support for “line with casing” as a symbol style. The “topo road” thing doesn’t cut it.

Smokeping notes

I’m trying to improve my Internet uptime monitoring. Right now I have a junky script that sends an ICMP ping every 1 or 5 seconds to a few carefully chosen IP addresses; my router, my upstream link, Google DNS, etc. It logs a text summary when a string of pings fail in a row. It works OK but is janky.

So I asked on the Internet for a better ping monitoring system and was reminded about smokeping. I have it sorta set up on my Ubuntu box now and it’s OK. Before I deep dive on that I also want to give a shout out to vaping, a rewrite of smokeping in Python. It’s not as featureful but then it’s not as old and idiosyncratic, either.

So the setup. I have smokeping sending 3 pings every 5 seconds to a total of 8 hosts. It makes graphs of latency for the ping replies along with highlighting packet loss. Eazy peazy.

Why 3 pings every 5 seconds? Well smokeping is really designed to send a whole lot of pings at once and show the distribution of latencies. The default is 20 pings! Also the default is only to measure every 5 minutes, which is fine for long term monitoring but I’m trying to catch short failures. It turns out 3 pings is the minimum smokeping is willing to send. 5 seconds was a compromise for me not wanting to spam too much. Works out to 3 * 8 / 5 = ~ 5 ping packets a second.

I’m using the default FPing probe. It’s fairly smart about handling timeouts, spacing an interval between pings, rotating through different hosts, etc. There’s also an FPing_Continuous probe option in smokeping whose main difference is it uses the “--loop” option in FPing. Near as I can tell that just moves the control loop from smokeping to fping, not sure that really buys you anything. Maybe it spreads the pings out more evenly?

As near as I can tell there’s no way to get smokeping to ping once a second. I found some years-old discussion about architectural assumptions in smokeping about the minimum interval between pings, and how much time the pings should take, etc that make it sound like that “20 pings every 5 minutes” really is the intended use case. Also I now have a giant RRD file I’m sure, and the code seems to be regenerating all the graphs every 5 seconds whether I need them or not. It’s all a bit silly and overkill but I think harmless for now.

I might also yet replace smokeping with vaping. It’s not nearly as fancy, but then it seems designed precisely for my 1 ping-per-second desired scenario.

Sample to ping.ubnt.com

Android phone migration experience

My 18 month old Pixel 3 had a hardware failure; the battery swelled, apparently a common problem. To Google’s credit they got a replacement to me in 36 hours at no cost to me. So now I have the experience of transferring my life from one Android phone to the other.

This was a transfer from a Pixel 3 running Android 11 to a Pixel 3 running Android 10. No idea if the downlevel OS caused a problem; I didn’t see any option to upgrade first.

Top line: it’s not a great experience compared to an iPhone. Apple has very simple one button backup and restore. Android does not. Instead it has like six different things you might want to back up, some of which are automatic and some are not.

I mostly had the data and settings stuff configured for backup to Google, so I figured I was OK. I also made a backup over USB of all the files on the phone, although I haven’t restored those.

Setting up the new phone at first was easy. You turn it on and it prompts you to plug a cable in to the old phone to transfer everything. Great! Go go go! It only took a few minutes, too. But the fact it only transferred 7GB of stuff was a clue something was wrong; I’ve got 30+GB on the phone.

A big part of what didn’t transfer were my apps. Instead the phone decided to redownload all the apps from the Internet. That’s not a terrible choice but it’s slow and possibly expensive and seems a little unnecessary. It took over an hour to redownload 150 apps, many of which I honestly don’t want.

Then the phone is mostly like before. Except.. all sorts of settings and configurations aren’t carried over. Many are, but not everything, and it’s quite confusing. Some things not restored:

  • Notification customizations. All these apps are back spamming me with noisy notifications.
  • Most logins. Almost every app demands I log in again. Fair enough. Happily, 1Password transferred over with little problem.
  • Authy auth state. I ended up having to delete Authy from the new phone, change the backup password on the old phone, then reinstall it on the new phone to get my login tokens back.
  • App permissions. Have to completely re-set-up which apps get access to location services, etc.
  • Random app preferences. Like my weather app forgot that I want weather for where I am right now, now Tokyo. Tapet seems to have remembered I want a new background every hour and that I’d paid for the app, but forgot my color preferences. GSAM Battery Monitor totally lost its state. Golf on Mars kept everything.

I think what I find most baffling is the app inconsistency, the way some settings carried over and others didn’t. Logins too. I have 4 gay hookup apps on my phone (go ahead and judge; I would). 2 of them made me log in again, 2 didn’t! So weird.

None of this is a catastrophe, but it’s definitely a nuisance.

Update: see the discussion here. Particularly the link to data backup docs for developers. I guess since Android 6 auto-backup for apps is on by default but limited to 25MB / app. There’s also a more manual backed up Key/Value store for properties, etc.

QGIS: drawing elevation increments

I wanted to make a map where every 100m of altitude has a different color. Ie: not a continuous ramp, but discrete colors. This turned out to be tricky enough I’m writing note.

1. Import DEM data like SRTM

2. Set the render style to “singleband pseudocolor”. Do not use “singleband grey”; it does not have the options we need.

3. set min / max to reasonable values. Ie 0 to 4000 meters. Set color interpolation to Discrete, pick a color ramp you like. (see step 7 for more)

4. Set mode to “Equal Interval”. Change the number of classes as you see fit; I chose 8. Click the “Classify” button.

5. Apply the style. It should look close to the result you want.

6. Tweak the Brightness / Saturation / Contrast to modify the overall effect as you need.

7. Experiment with different color maps. There’s a lot more built in than you’d think; if you “Create new color ramp” of type “Catalog: cpt-city” you find a lot of interesting options including many that are specifically for topography.

Here’s a simple brown every 500 meters scale I’m using.

The result looks like this (along with blue river lines from another data layer)

BTW the color map for my favorite Wikipedia map ever is one of the ones built in to QGIS. Or at least something similar. Look for “wiki-france” under “topography and bathymetry”.

Cursed hillshade

This is what you get in QGIS if you use its hillshader and then zoom in finer than the resolution of the DEM data. May need to view image full size to get the effect.

Ubiquiti Security Gateway failures

Trying to diagnose a problem with my Grass Valley network where the Internet goes down 20-120 seconds every few hours. I think this is an old problem that dates back to my old router (Ubiquiti EdgeMAX) but it may be related to the new USG or the LTE failover device I recently installed, even though it’s now disabled.

The symptom is the whole Internet goes down. My router logs this message:

WAN iface [eth0] transition to state [active] 11:33 am 2020-10-05
WAN iface [eth0] transition to state [inactive] 11:32 am 2020-10-0

I’m able to reproduce that the Internet is really down with a simple looping ping script. But that just tells me the Internet is down, not why. My question is why is the router logging that message?

Related: this webpage has excellent docs on how Ubiquiti’s failure detection and failover works.

Theories

My first theory was that my WISP is just flaky and that’s to be expected. I swear I’ve had problems like this for years. But I had a long chat with them yesterday and they assured me that’s not expected behavior. Also that my device had a clear strong signal for at least a week. But their monitoring is only good to 5 minutes, so wouldn’t catch a 30 second outage.

My second theory is that my WAN device, a Cambium ePMP 1000, is genuinely just failing. That the device loses power or for some other reason reboots. Unfortunately it’s up in a tree and I don’t have the access to read any stats or SNMP data from it, so I don’t know. But that’d surely explain why the router decided eth0 was inactive, if it lost ethernet link.

The third theory is that it’s Ubiquiti’s watchdog itself that’s failing. If you configure a WAN2 failover (say, my LTE device) they run a watchdog process that tries to ping ping.ubnt.com every 10 seconds. If that fails 3 times in a row it decides the WAN1 interface is down, sets it inactive, and fails over to WAN2.

Evidence

But would they still be running this failover algorithm even if WAN2 is disabled and not running? I fear maybe so. Logging in as root on the USG and running show load-balance watchdog I see some evidence that the failover stuff is still happening.

Group wan_failover
eth0
status: Running
pings: 2457
fails: 0
run fails: 0/3
route drops: 7
ping gateway: ping.ubnt.com - REACHABLE
last route drop : Tue Oct 6 02:53:08 2020
last route recover: Tue Oct 6 02:53:59 2020

That timestamp corresponds to my latest failure and suggests the watchdog apparatus is still running. show load-balance status also has some interesting info in it.

There’s more information in /var/log/messages on the router:

Oct 6 02:52:38 ubnt zebra[753]: interface eth0 index 2 changed .
Oct 6 02:52:38 ubnt kernel: eth0: Link down
Oct 6 02:52:39 ubnt zebra[753]: interface eth0 index 2 changed .
Oct 6 02:52:39 ubnt kernel: eth0: 100 Mbps Full duplex, port 0
Oct 6 02:53:08 ubnt wlb: wlb-wan_failover-eth0 wlb-wan_failover-eth0 reachability failed, failover
Oct 6 02:53:08 ubnt wlb: group wan_failover, interface eth0 going Inactive
Oct 6 02:53:08 ubnt wan-event: [WAN Transition] eth0 to state inactive
Oct 6 02:53:59 ubnt wlb: group wan_failover, interface eth0 going Active
Oct 6 02:53:59 ubnt wan-event: [WAN Transition] eth0 to state active

In this log, the ethernet interface goes down first, before the watchdog is involved. That’s consistent with theory #2: the connection to the WISP antenna is flaking out. Looking back in the logs that’s the same pattern for many failures. The ethernet link goes down for about 2 seconds, then comes back. Then about 30 seconds later the failover system kicks in and marks the WAN inactive. Then some period of time later (51 seconds in this instance) the failover marks the link active again.

My local ping to the WISP antenna shows a shorter outage. Clocks are both NTP synchronized, but 7 hours off because of timezones.

Ping 35446 failed Tue Oct 6 09:52:42 2020.
Ping 35447 failed Tue Oct 6 09:52:47 2020
Ping 35448 failed Tue Oct 6 09:52:52 2020
Ping 35449 failed Tue Oct 6 09:52:57 2020
Outage for 21 seconds started Tue Oct 6 09:52:36 2020

I also have a different monitor pinging ping.ubnt.com from my own Linux box

Ping 197355 failed Tue Oct 6 09:52:42 2020
Ping 197356 failed Tue Oct 6 09:53:12 2020
Ping 197357 failed Tue Oct 6 09:53:22 2020
Ping 197358 failed Tue Oct 6 09:53:27 2020
Ping 197359 failed Tue Oct 6 09:53:32 2020
Ping 197360 failed Tue Oct 6 09:53:37 2020
Ping 197361 failed Tue Oct 6 09:53:42 2020
Ping 197362 failed Tue Oct 6 09:53:52 2020
Ping 197363 failed Tue Oct 6 09:53:57 2020
Ping 197364 failed Tue Oct 6 09:54:02 2020
Outage for 90 seconds started Tue Oct 6 09:52:32 2020

Putting that all together, the timeline:

  • 02:52:38 to 02:52:39 router notices WISP ethernet is down
  • 02:52:42 to 02:52:57 (approx) can’t ping the antenna IP address
  • 02:53:08 to 02:53:59 router marks WAN interface inactive
  • 02:52:42 to 02:54:02 (approx) can’t ping an Internet host

Note that even though the ethernet is down for 1 second, the whole Internet is down for 90 seconds. But the WISP antenna is only down for about 20 seconds.

My guess is the ethernet connection to the WISP antenna, including its power, failed. Or else the WISP antenna rebooted itself. The ethernet link comes back very fast on reboot on that device, like 1 second. But it takes 20 seconds to get up and running enough it’ll respond to pings. And in this case, 90 seconds to fully recover and be online again reliably. Not all the outages are this long; most are more like 60 seconds.

Next steps

So that’s all consistent with theory #2: the connection to the WISP antenna is flaking out. I mean it’s right there in the “link down” message. I’m still confused as to how a momentary break in ethernet signal makes for a 60 second outage.

I’ve asked my ISP whether it can give me more information about what’s happening to WISP antenna device. At least, its uptime.

I’ve got a pretty marginal wiring solution for the antenna; the ethernet cable is 350+ feet long and the PoE injector is at far end from the antenna. I’ve also got a simple passive cable joiner about 50 feet from the antenna. I should split it there and put the PoE injector and maybe an ethernet switch nearer the antenna and see if that makes it more reliable.

Update

Well damn, a theory shut down. My ISP got back to me:

I logged into the antenna, and it is showing an up time of 6 days and 7 hours at the time of this email. I also looked at the signal history for the last 3 days and found no breaks or loss of the signal between the antenna and the radio tower. That antenna has a reboot time of about 1 to 2 minutes.

So much for my theory that the antenna was losing power and rebooting.

However I’m still convinced that the ethernet link between the router and the antenna is failing. I mean, the router says so in its logs! That could still be a result of the long ethernet run through a coupler, so there may be still be an advantage to putting a switch in the middle of that long run; it may never have been PoE, but data / link failure. I also wonder if it’s possible the WAN1 port on the USG itself is broken. Seems unlikely but...

I had no outages at all for nearly 36 hours, then today I’ve had 10 outages in 5 hours (mostly overnight). Really confusing.

Update 2

It’s been bugging me that the local antenna seems to go down for 21 seconds, but then the whole WAN goes down for a minute+. I think we’ve got an unfortunate coincidence of timings. The watchdog default is (I think) 3 pings in 10 seconds failing for a failure, and 3 pings in 10 seconds working for a success. With my antenna link outages 3 pings just barely fail in a row. The 4th would work but the router has already decided the link is not working. Then it waits for 3 more pings before re-activating the link. I can sort of verify this behavior; I had the antenna fail a ping once for 6 seconds (don’t know why), and the router didn’t detect that as a real outage.

So for now I’m testing changing the config to need 6 bad pings in a row to detect WAN failover. Once the LTE device is back working it’ll be a longer wait for it to come online, but it might hide these ethernet link outages or at least make them less severe.

$configure
ubnt@ubnt# set load-balance group wan_failover interface eth0 route-test count failure 6
[edit]
ubnt@ubnt# set load-balance group wan_failover interface eth0 route-test count success 3
[edit]
ubnt@ubnt# show load-balance group wan_failover
flush-on-active enable
interface eth0 {
route-test {
count {
failure 6
success 3
}
initial-delay 20
interval 10
}
}
interface tun900 {
failover-only
route-test {
initial-delay 60
interval 600
}
}
sticky {
dest-addr enable
dest-port enable
source-addr enable
}
transition-script /config/scripts/wan-event-report.sh
[edit]
ubnt@ubnt# commit
[edit]
ubnt@ubnt# save
Saving configuration to '/config/config.boot'…
Done
[edit]

These changes aren’t persistent; next time the controller reprovisions the router they’ll be wiped out. The linked docs talk about how to make them persist through that too but I’m told these only work through a USG, not a Dream Machine. Fortunately I have the USG.

Update 3

Those changes may have made things worse; outages seem to be even longer. Honestly I can’t really understand what’s happening. Since making those changes:

Outage for 60 seconds started Mon Oct 12 14:19:03 2020
Outage for 90 seconds started Tue Oct 13 16:13:22 2020
Outage for 75 seconds started Tue Oct 13 16:18:27 2020
Outage for 51 seconds started Tue Oct 13 16:29:32 2020
Outage for 75 seconds started Wed Oct 14 08:37:20 2020
Outage for 16 seconds started Wed Oct 14 08:38:35 2020
Outage for 14 seconds started Wed Oct 14 19:08:41 2020
Outage for 55 seconds started Wed Oct 14 21:09:21 2020
Outage for 121 seconds started Thu Oct 15 01:40:31 2020
Outage for 90 seconds started Thu Oct 15 18:25:41 2020
Outage for 90 seconds started Fri Oct 16 19:50:06 2020

I’ve tried setting the “success” timer from 3 consecutive pings (ie: 30 seconds) to just one. Not ideal if there’s a working failover, but in the absence of one I think this is better than waiting?

Wyze camera v2 hacking

Wyze makes these amazing little cameras for $25; 1080p, infrared capable, two way audio. $25! The drawback is their firmware is very limited and you’re stuck trusting their web services. I am not willing to upload video from my house to a cloud server.

Solution: Xiaomi-Dafang-Hacks. It’s a hacker firmware you can install on top of the Wyze v2 cameras and various other similar ones that’s much more flexible. It’s designed for local use, you can get the thing to put out an RTSP stream, MQTT events when there’s motion detected, etc.

I followed this guide for setting it up. Basically it comes down to “flash the firmware to this funky .bin file you put on a MicroSD card. Then copy a new OS to the SD card for it to boot”. I think it would have worked the first time but I had a typo in my WiFi config file. I got it right the second time. Or as I told a friend:

Well I carefully ground the powders, then charred them in the brazier with aqua regia. I collected the vapours in the alembic and distilled them three times, using a clean retort washed with the tears of a child each time. I poured the final elixir into the Wyze camera and rebooted it and... no joy.

Ah hah! I found a spec of dirt in my elixir, perhaps rheum from where the tears were not adequately filtered. I re-ran the distillation process and watched the one flashing light for signs of success. Previously, the light shone a steady yellow. This time it winked out. Success!

Now the camera is listening on https://dafang/ and lets me do various things, all without involving cloud servers I know nothing about. Now then.. what was my plan for using this thing anyway?

Updates

After dorking around with this for awhile I’m much less impressed. The firmware seems pretty flaky to me even once installed reliably. Either that or the camera is.

The RTSP stream for H.264 is a mess. The encoding isn’t quite right so VLC often displays corrupted video, it’s like it’s missing key frames or something. Sound is 50/50 whether it gets transmitted or not. The record feature in the system doesn’t seem to even try to record stuff and writes a naked .h264 file, not a container format. (Also it works by using RTSP to localhost, lol.)

The thing there is a lot of support for is doing something in response to motion detected, using the motion(1) program from Linux. It’ll send messages to an MQTT server, or record a static JPG to the SD card, or send an email, or send a Telegram message (!). I don’t know if that stuff is any more reliable than anything else but I can see how it’d be useful.

I have this same experience every time I hack with camera software; there’s a big gap between “eh, kinda works” and a nice usable system with clean rounded corners. I really want to just buy a working home security system that’s Internet and camera centric. But it has to not send stuff to a cloud server out of my control.

Update 2

After most of a year away I revisited this blog post, grateful to have the notes! Got the hacker firmware up and running and updated. It’s nicer! Also the update process is a bit buggy. It leaves your old config files in place but some of those files needed updating. In particular there’s a DCIM_PATH set in the configs for various recording services that should be set to /system/sdcard/DCIM or a subdirectory thereof; nothing was recording locally until I enabled it. Simplest thing is to go to /system/sdcard/config and diff the .conf files with their .dist versions and fix things by hand. (“Simplest”).

I haven’t figured out if the firmware is more reliable than it was last time I tried it. A bunch of stuff seems flaky. You pretty much have to reboot when changing the configuration for anything; even stopping and restarting services manually doesn’t always pick up new configurations for some weird reason. Recording audio with the video does not seem to work. If you delete a file in the web UI you have to reload the page to see the other files remaining. Trying to do unusual things doesn’t always work as planned. For instance I set the video framerate to 15fps. The recordings I get from it are still marked 25fps, but the on screen clock shows me we’re now playing in accelerated time. Dumb.

“Hilarious” thing: the default login is root/ismart12. You can change the HTTP login password easily, but that doesn’t change the SSH login that’s still there. Nice. I also found there were Telegram and Matrix accounts pre-configured; no idea if those were demos, or some automatic thing generated for me, or if by default the firmware just shuttles your video to some random people somewhere. The services weren’t enabled so it was probably harmless, but geez.

UniFi Dream Machine first thoughts

I liked the UniFi Security Gateway experience in Grass Valley so much I decided to replace my EdgeMAX with a UniFi router in San Francisco, too. I also wanted to add another WiFi access point and it’s nice to have a dedicated controller so I bought the home consumer UniFi Dream Machine, aka the UDM.

First impression: it all works out of the box! This is the first Ubiquiti device I’d be comfortable giving a random ordinary person and have them set it up. It was a bit daunting at first; there’s literally no instructions in the box, not even a single page “getting started”. That is dumb. But if you plug the device in and plug your laptop into one of the switch ports and open a browser window, it will grab you and direct you to setup (via a captive portal). The setup is very simple, too, setting up the basic home router folks need.

Too simple though; I really wanted to configure it before turning it on. No such luck. It demands an Internet connection, a remote access login(*), etc to even set up. I gave in and disconnected the old router and just lived with some downtime until I got the new one set up.

Really there wasn’t much to configure. I have my usual few tweaks: a static IP address for one host, a couple of forwarded ports. Fewer and fewer over time though and it was quite easy to get everything shifted over.

Except once again.. Ubiquiti fails to deliver local DNS. The various hacks for adding it to a USG all don’t seem to work either. I dunno, in Grass Valley the local DNS server at least started returning client names it had learned via DHCP after a few hours. I’ll give this time; I’ve seen some evidence it might be working.

More broadly the Dream Machine is lacking a bunch of features. Some of these are pretty fiddly / psecific things but a lot are fairly basic. It’s not clear if the OS can’t do it or if it’s just the UI doesn’t allow you to configure it yet. And the Dream Machine seems to lack a single config.gateway.json for advanced users to edit, the old back door way to enabling some features in UniFi routers. It’s a significant step back in flexibility. So far I’ve only run into one case where I’d want it, but...

(*) I’ve conceded to UniFi’s remote login. The selling point for me was installing the controller software on my mobile phone and being able to remotely look at my network even when not on site. Super handy. What’s weird about this UDM is it doesn’t even seem to support local login; I think it’s cached my cloud login credentials locally for when the network is down but I’m not sure. You can still log in as root too but that doesn’t even use the normal UniFi credentials, instead the login is username root and your cloud login password for the local password. Spooky.

We’ll see how the device is doing after a couple days’ use. I do like UniFi’s platform in general. Also impressed with the WiFi hardware here, a 4x4 antenna setup is nothing to sneeze at. It’s so good I may never bother setting up my old access point as a secondary in San Francisco.

Also I have an advanced project, creating a VPN tunnel between my two houses. Been wanting to do that for years, looks like Ubiquiti has a shortcut method for that. You can also set up a VPN server which would be a big help for me when travelling; I need to look into exactly what that gets you.

QGIS 3.14: where the fuck am I?

I just spent 30 minutes trying to figure out how to figure out where I was on a QGIS map. Specifically I wanted to be able to click on the map and copy the coordinates. The way to do this has changed in various QGIS versions so old docs are wrong. QGIS 3.14 (the new hotness) just changed it again.

Bottom line: install the QGIS Coordinate Capture plugin from the plugin repo. It’s at version 0.2 right now. Then select the hand tool (the pan tool) and right click on the map. A little option to copy the coordinate will pop up along with a chooser for which CRS you want. Note you have to be in the hand tool: the Identify Features tool doesn’t have it.

The confusion at the moment is because the Coordinate Capture function was removed in 3.14. The discussion looks well meaning, someone refactoring functionality and saying “this should be reimplemented in a nicer way”. Only instead of first shipping the nicer way they just removed the old way and then called it a day. The worst kind of open source fuckery.

That change means the method in the 3.10 docs doesn’t work; there’s no longer a Coordinate Capture panel. Nor is there a toolbar as some docs reference. Nor does it show up in “Derived” under Identify Features as some QGIS2 docs suggest. Apparently this really fundamental feature has moved around a lot over the years. This plugin seems like a temporary hack, I suspect the method will change again soon.

OSM data in QGIS for simple print maps

I’ve been wanting to make some print maps in QGIS using OSM data for roads. There’s a bunch of ways to do this from simple to complex, but I think I found a way that works for me.

  • Start with an OSM extract in .osm.pbf format. These are produced daily for countries and regions and are manageable size.
  • Import it as a layer into QGIS, which has native support for .osm.pbf format. However it will be slow because it is not indexed.
  • Convert to GeoPackage in QGIS, with the defaults. All the property names, etc will be carried over and you’ll get a spatial index.
  • Use the new GeoPackage layer in your maps, you can delete the old OSM PBF layer entirely.

The main drawback is you’re dealing with OSM schema. Ie, drawing roads involves deciphering all the possible tag values for “highway”. It’d be nice to use some processed dataset converted to a simpler schema but I don’t know of an easy way to get a free one.

If you don’t care about licensing, MapTiler has some very nice OSM Planet tiles you can easily import in new versions of QGIS using their MapTiler QGIS Plugin. You can import these as raster maps or vectors. The vectors come with some schema translation and styling so you start with an OSM-looking map right there in QGIS and then modify it as you wish. The downside is I’m not sure you can use this data for, say, a print project without a licensing agreement from MapTiler. Also I didn’t see any easy way to control the level of detail so if you want to override their idea of feature selection at a zoom level you may be out of luck.

Unifi LTE notes

Update (Dec 2021): do not buy this product. It does not work well; there are numerous problems with the failover. And at least in my case, the cell service was terrible. Worse, Ubiquiti’s management of it is terrible. The web UI for cancelling the subscription is broken. And once my Unifi network saw the Unifi LTE once it will not let go of it. I keep finding vestiges of it in the management console (including a popup message every single page load) and cannot figure out how to remove it. (If this happens to you try the classic console. Apparently this is yet another missing feature in the new UI.) UniFi LTE is a bad product.

I finally have a home network cellular backup option; I bought a UniFi LTE. This integrates with the rest of a Ubiquiti home network via their UniFi platform to give seamless failover to an AT&T cell tower when your main ISP is down. Price is $200, $15/mo, $10/GB. Right now there’s a sale where it’s $5/mo and $5/GB until May 2021; kinda hoping they keep it that way, we’ll see.

The bad

I’ll get the bad out of the way first. The LTE device is AT&T only, with a hardcoded SIM. You cannot use any other network provider and you must buy your contract via Ubiquiti on AT&T. Their network is high quality, but if you’re using a lot of LTE data, AT&T is expensive. My intention is to only use this as failover, hopefully never more than a few GB a month, so I’m willing to accept this limit. It’s a dumb limit though. If you want more flexibility there are a variety of LTE modems sold as hotspots. Also a bunch of routers have LTE failover built in, particularly things meant for installation in trucks and RVs.

The other bad is the UniFi LTE is definitely a Ubiquiti proprietary product. It will only work if you have one of their USG or Dream Machine routers. Many routers (including those two) support a more generic WAN failover, where you have a second WAN port and load balancing or failover rules to use it. The UniFi LTE is not that. In fact you don’t plug it into your router at all, it can go anywhere on your LAN and looks like a local ethernet device. (The docs say the router “makes a tunnel” to the LTE when it needs to route that way.)

One final bad: the numbskulls at Ubiquiti failed to include a power adapter. $200 and there was no way to turn the thing on. The docs are cryptic saying “use a UniFi switch to power it”. Digging deeper and I see the UniFi LTE is an 802.3at device; most UniFi switches that supply POE are 802.3af, a lower power standard. What’s weird is the LTE device only needs 8.5W, well within the capabilities of 802.3af, and some reports are that the device works on 802.3af. I didn’t chance it. (It does have the ability to pass another 8.5W through to a second POE port, that’d require more power than 802.3af requires, but it’s optional.)

Anyway this $110 8 port switch is the cheapest thing I could find that Ubiquiti sells that provides 802.3at. I was stubborn and didn’t want to buy a switch, particularly since I’m not sure where I’m going to locate the LTE modem, so I bought a $20 Shenzen special 802.3at injector instead. It seems to work.

The good

The reason I put up with the bad is I wanted a no nonsense device with no confusion, something that would Just Work. And so far so good. I plugged it in and had it up and running within 5 minutes, including buying the contract service. The only fiddling I had to do is I was required to enable “remote management” on my USG; that’s some scary thing where your router state is accessible via the Internet with a password. I don’t love that idea but I relented.

I’m grateful for this simplicity. Doing it myself with an LTE modem would require researching a suitable modem, picking a carrier, picking a data plan for that carrier. Then getting it all working first on a laptop (for testing). And only then, plugging it in to the WAN port on my router and seeing if the failover actually worked. Probably in a way that violated the data contract I signed up for. Yuck. I’m happy I just bought my way out of all that effort.

Another bit of good; judging by the device’s shape and performance it has a pretty serious antenna in it. Ubiquiti got their start making excellent WiFi antennas and I’m hoping that extends to LTE. There’s also a coax connector for an external antenna but I think I’m unlikely to do better unless I put up a mast.

In practice

Like I said, I got it running with no stress at all. It seems to work.

There’s very little configuration on the device. About your only choice is the max data cap (3 GB / month by default) so you don’t get hit with an ugly bill if something goes wrong. I think I saw some reference to being able to set policy so some devices don’t get to use the cellular backup, probably involving a VLAN. Need to look into that.

I simulated a failure by unplugging my normal ISP (the simplest possible failure; detecting a flaky ISP is harder). The failover happened in under 15 seconds. The LTE connection was OK for this area: 14/1 Mbps and somewhat reliable and with lower latency than expected. (My experiments with a phone as hotspot are all over the place but often much worse). It switched back to the ISP when I plugged it back in, but took a minute or two. I did get email alerts about the outage but there was no obvious view on the Controller dashboard about the failover (there is one hidden status message). Anyway, it basically worked.

I’ve also had two unplanned failovers, both lasting less than a minute. I was away from the computer at the time so I didn’t notice. My ISP sometimes has hiccups where all my sessions are terminated and it’s out for a few seconds, I wonder if that triggered the failover? I don’t know that I mind exactly, but it’s something to keep an eye on.

I’ve read some complaints that networks were failing over to LTE, maybe on false pretenses, and then never recovering back to the preferred ISP. I don’t think I’ve seen that behavior yet. I did get a failure where I unplugged the LTE while I’d failed over to it. I then plugged my regular ISP back in expecting the network to go back to it. But it never did. I finally powered the router off and on and after 5 minutes (!) my network came back.

More generally I just wish the LTE failover state were much more prominent in the dashboard. Also that there be a big toggle switch I could hit manually to swap WANs.

Antenna placement

What I really want is a tool to help me better situate the LTE antenna. I can’t find one; I’ve asked here. There are some diagnostics, including enough signal strength readings that I can probably experiment with different placements but there’s no live tool guiding me which direction to point in or anything. I think their long distance WiFi link utilities do have that.

I’m astonished at that “Good signal strength” measurement; we have terrible reception here at my house. Phones get 0 or 1 bars. All I did was put the antenna in a window pointed roughly towards where I think a tower is.

What do all those numbers mean? This article was helpful. The key number there is the RSRQ or “Reference Signal Received Quality”; it’s sort of like SNR but for multi-channel connections. That -11dB qualifies for “good”. The RSRP number is also useful, it’s the raw signal strength for a single channel and -115 is not so good. Band B12 is a 700MHz frequency.

Annoyingly, I can’t find a time series graph of the history of these readings. The Performance graph shows dropped packets, etc so that may be helpful but there’s no simple graph of RSRQ.

As for where the towers are, this article has lots of useful advice. Looking on CellMapper I think I found out which cell tower I’m connected to; there’s a A3E49 on the map north of me and the cell ID (blanked above) I have is 0A3E4911. The 11 stands for the cell to the south so that makes sense too. That tower is further away from me than I’d like but is way up high on a hill. Most of the other AT&T towers are lower, along the highway, which seems dumb. I need to do further experimentation with my phone as a signal tester.

I tried various locations in my house for the antenna. Some not very reliable data:

  • Office window: 0A3E4911, B12 RSRQ -12, RSRP -112 to -115
  • Office closet: 0A3E4911, B12, RSRQ -9 to -13, RSRP -114 to -125
  • Garage pointing north: 0A3E490A, B2, RSRQ -13 to -14, RSRP -119 to -120.
  • Garage point north after use: 0A3E4911, B12, RSRQ -10

Interesting the garage location uses a different cell (same tower) and band. The B12 bands are in the 700MHz spectrum, B2 is in 1900. I think that means the B2 option could be higher bandwidth. However it only stayed connected on B2 until I tried to use it, at which point it switched over to the other cell on B12. I don’t have a clear line of sight (including a metal garage door, among other things) so I suspect 700MHz is the better choice.

Conclusion

I’m pretty happy with the UniFi LTE, particularly at the current $5/GB sale price. It worked right out of the box once I found a power adapter for it. Now I need to run it for a few months and see what happens in practice.

Configuring failover behavior

Some extra notes written after the main piece.

After 48 hours I’m annoyed that the LTE is being failed over to for 5-15 seconds at a time. It’s happened maybe 8 times. These all might be legitimate primary failures, my ISP is flaky, but then it seems disruptive to fully change the routes since that terminates all active TCP connections. I’d rather the thing not respond to failures so quickly.

There’s very little docs on failover and no config options. I did find this discussion thread which says

It tests whether it can ping out via that interface to ping.ubnt.com. So it will detect a failure upstream. It takes a little longer to failover to not be overly-touchy, it’s immediate when you lose link, 3 failed monitoring checks when link is still present (which is, at most, 40 seconds from failure to failover).

Create an upstream failure, and watch “show load-balance watchdog” via SSH to USG. After 10 seconds you should see “run fails” increment to 1/3, then later 2/3, later 3/3 and it’ll fail over at 3/3.

I wonder if that’s still true (this was late 2019). It’s a reasonable heuristic! And that show command shows “run fails: 0/3” which suggests 3 is still the threshold.

Group wan_failover
eth0
status: Running
pings: 3160
fails: 1
run fails: 0/3
route drops: 4
ping gateway: ping.ubnt.com - REACHABLE
last route drop : Sat Sep 19 22:52:34 2020
last route recover: Sat Sep 19 22:53:07 2020

tun900
status: Running
failover-only mode
pings: 120
fails: 1
run fails: 0/3
route drops: 0
ping gateway: ping.ubnt.com - REACHABLE

This gives me a way to monitor and/or simulate their own failover algorithm too, I can at least verify it’s doing what it thinks it’s doing.

I think I found the config JSON on the USG router that controls this too. Following these instructions about config files I ran mca-ctrl -t dump-cfg to inspect the config. Among other things I found this block:

"load-balance": {
  "group": {
    "wan_failover": {
      "flush-on-active": "enable",
      "interface": {
        "eth0": {
          "route-test": {
            "initial-delay": "20",
            "interval": "10"
          }
        },
        "tun900": {
          "failover-only": "''",
          "route-test": {
            "initial-delay": "60",
            "interval": "600"
          }
        }
     },
     "lb-local": "enable",
     "lb-local-metric-change": "enable",
     "sticky": {
        "dest-addr": "enable",
        "dest-port": "enable",
        "source-addr": "enable"
     },
     "transition-script": "/config/scripts/wan-event-report.sh"

Updates and failures

Last night, after a couple of days of installation, we had the failure mode I was afraid of. The network failed over to the LTE at 9:30pm and didn’t switch back. Something else happened at 2:10am and again at 2:30am but it didn’t switch back to the ISP. Usually these last just a few seconds and it switches back to my ISP. This morning we were still on the LTE even though the ISP link was fine. Had to unplug the LTE and then reboot the router to get the thing back.

The main thing I’m seeing are clusters of 4 events; I’m thinking of these as failovers in response to a temporary short ISP outage.

  1. 15:48:06 LTE to state active
  2. 15:48:06 ISP to state inactive
  3. 15:48:40 LTE to state failover
  4. 15:48:40 ISP to state active

That’s what a normal working failover looks like. Not thrilled about having so many of them, but it seems to work. Here’s what happened last night

  1. 21:33:09 ISP to state inactive
  2. 21:33:10 LTE to state active
  3. 21:33:43 LTE to state failover
  4. 21:33:43 ISP to state active
  5. 02:09:39 LTE to state active
  6. 02:09:39 ISP to state inactive
  7. 02:30:21 LTE to state failover

That’s the event report.

First thing to note is that it was the 21:33 failover that actually started the problem. Even though events 3 and 4 make it look like the ISP should be active (not the LTE), I have independent logs of IP addresses that show me my home network was on LTE since 21:33. So that’s weird. The other weird thing about the 21:33 logs is that the events are backwards from normal; ISP to inactive first, then LTE to active. I don’t know how Unifi publishes events though so I’m not sure event ordering is strictly guaranteed. I suspect it is though and that timestamp difference (:09 vs :10) is evocative.

Then there’s the 02:09 events. No idea what those are about, it looks incomplete. I wonder if the router was using LTE but the watchdog infrastructure thought it was on the ISP? Whatever the case it’s a failure.

Ubiquiti is usually more reliable than this. I’m annoyed.

Kaiterra Laser Egg air quality monitor

I bought an air quality monitor, a Kaiterra Laser Egg+ CO2. You can see the readings from it here.

I bought this device because Wirecutter recommended it and it had a CO2 sensor. AQI or PM2.5 is the thing everyone cares about when there’s smoke, but I was also interested in CO2 levels in my house. This sensor does both. I also liked that Wirecutter said it had a good simple UI. And it has good cloud integration for data access. I’m looking forward to finally setting up Home Assistant to monitor it.

Setup out of the box is very easy. Charge the device (it has a battery!), turn it on. Install a mobile app, hold a button on the device a few seconds, and the mobile app walks you through the setup. Which mostly is just typing the wifi password for your network. I’m impressed with how these things get easier every time I get a new gizmo. I assume a Bluetooth handshake was exchanged.

Second half of the setup is getting the device to upload data to a cloud server somewhere. That was also easy; create a web account, then scan a QR code on that site on my phone and it automatically adopted my devices. From there I can publish a “kiosk URL” anyone can read. The URL is hilarious; just some JSON with the device ID and a web token signature all base 64 encoded. Eh, it works.

Now I want to get into the details. The docs don’t say a lot but there’s more info online here. By default it publishes an AQI number which I think is comparable to numbers like what PurpleAir or EPA publishes. (But which exactly? I don’t know other than it’s a US number.) It also publishes raw numbers for PM2.5 (in ug/m3) and CO2 PPM. And even more raw, there’s also “0.3μm per 0.1L of air”, a number which I guess is just a physical measurement and not adjusted at all.

Sitting outside in smoky air, The AQI and PM2.5 numbers are roughly in line with nearby sensors on Purple Air. The CO2 sensor read about 600 even when outdoors. I think that’s supposed to be 400 (which is normal outdoor a ir), so I went ahead and pressed the calibration button and now the reading says 400. It has some complex self-calibration but maybe this will help it along. I sure hope the smokey air doesn’t mean the CO2 level is naturally higher as well.

The CO2 sensor can directly measure global warming! Back in the 80s “normal” was 335 ppm; now it’s 415ppm. More details and history in this article.

Update: I got the device working with Home Assistant. Was as simple as configuring the HomeKit device that HASS found, which was apparently the Kaiterra. Type in the pairing code on the Kaiterra screen and I’m done.

RCS messaging works!

For the first time I was able to verify that RCS messaging between two Android devices (a Pixel 3 and a Samsung 20) worked. Even better, my friend with the Samsung was using Samsung’s messaging app and I was using Google’s. Interoperability!

Here’s how to tell if your messages are being sent via RCS or SMS:

SMS are light blue and have the “SMS” tag. RCS are dark blue and say “Delivered”. They also have read status, and notification, and nice handling of longer messages and multimedia and stuff. When you’re sending a message it’ll tell you if it’s going out RCS. Not sure how to tell when messages you receive are RCS vs SMS, but my friend says on his Samsung app there was a blue dot next to my messages.

Basically RCS has all the nice things Apple has had in iMessage for 12+ years now. Only RCS is an open standard and not Apple proprietary. I’m hoping someone makes a nice native desktop app for RCS at some point. Google has clever browser-hosted access to your phone’s Messages app, but it’s kind of a hack.

Google and the carriers rolled out RCS for most people about a year ago. But looking back at my phone I could only find one other RCS message so far. Most of my friends are Apple captives so that may be why; Apple will presumably drag its feet in ever supporting the open standard.

One big drawback is RCS doesn’t support end to end encryption right now. I thought this was a political concession to various oppressive nation’s spy agencies. But more recently it looks like Google may be adding encryption support. I still prefer Signal for all messaging, really, but it’s hard to convince others to use it.

USG notes, GV LAN configuration

Setting up yet another new router, a Unifi USG. I’m finally buying fully into the Unifi platform. I like the concept; one central management process that configures and monitors all your network equipment. Proprietary of course, but I’m willing to bet on Ubiquiti.

Setting up the USG is awkward since it’s the backbone of your network. These docs helped. My catch is my LAN is configured to be 192.168.3.* but the default network is 192.168.1.*. And even though the Unifi Controller could see the USG when I plugged it in (via LAN port) and send it a firmware upgrade, it wasn’t able to actually provision (configure) it. So I had to follow their instructions; plug in a laptop to the WAN port, use the minimal web config to change the subnet, then use the Controller to configure the rest. Annoyingly the Internet access on the laptop worked fine on the 192.168.1.* subnet but not 3.*; I suspect that minimal config on the USG itself doesn’t even set the DHCP router address right when switching. Anyway once I’d switched the USG’s network to 3.* the Controller was able to send the full configuration and everything works.

Yet another router configuration system with its quirks to learn. Most of the defaults seem fine. The only thing I’m missing is static DNS entries for local static IPs, something Ubiquiti has never been great at. Turning on dnsmasq didn’t help. It may not be possible at all, or require editing a config file. Update I waited a day and now /etc/hosts on the router has a bunch of entries from DHCP, which it will also serve via DNS. I do not have dnsmasq enabled. They are FQDNs only, ie hostname.nelson.monkey.org and not the naked hostname. That’s reasonable but it does mean your host doing the query needs to be configured to search that domain.

One annoying thing in the USG: it does not have a switch. It has 3 ports: LAN1, WAN1, and then LAN2/WAN2. That last port can not be switched or bridged to LAN1, it is treated as a third network with its own subnet and routing. You could probably kludge it so it works like LAN1 but the router will be doing extra work. (Hilariously there’s a 4th RJ45 on the thing labelled “console”. It is literally a serial port.)

Another annoying thing in the USG: it’s slow. Not routing, that’s fast. But it takes 45+ seconds for the thing to boot. And re-provisioning takes a long time, although at least it’s conveniently orchestrated.

LAN Configuration

Figured it was time to document my LAN configuration for the next time I have to do this. Not that stuff doesn’t change.

  • 192.168.3.1/24
  • domain name: nelson.monkey.org
  • WAN configured via DHCP, NAT mode
  • Static LAN DHCP entries
    Printer 84:25:19:0e:7b:0b 192.168.3.67
    Axiscam ac:cc:8e:20:47:8f 192.168.3.53
    gvl 94:c6:91:1e:c8:38 192.168.3.75
  • Static DNS entries for gvl and axiscam
  • SNMP enable community string “public” (for Munin on gvl)
  • Port forwarding: none
  • DDNS: none
  • UPnP disabled

The network is pretty closed off; the only way in from outside is via an autossh tunnel I have set up somewhere on a cloud server.

I would like to add a VPN configuration between my two houses though. Every time I’ve looked into that it was complicated, particularly getting it working while only in one place at the time.

Generator notes after 42 hour outage

We used our new generator in anger for the first time during a 42 power outage thanks to a PG&E PSPS, their response to their murderously unmaintained power network. It mostly worked fine and we didn’t even really notice any difference. Main problem was our ISP went down; that’s not our generator’s fault.

We used 10.7% of our propane tank for the outage; 54 gallons, or about 1.3 gal/hour. Or $150, if you look at it that way. The spec sheet says the generator uses 2.5 gal/hour at half load, 3.9 at full. It’s a 22kW generator and we’re using it nowhere near even half load. We average about 1500W over the day, so just 7% of capacity, but we’re apparently consuming 33% of max fuel. Not a big surprise but useful numbers to know.

Aside from the noise the main way I knew I was on generator is the lights flickered. And the cheap UPS in the server closet kept clicking off and on. (The fancy power conditoning UPS did not). Last time I looked at this I traced it to the well pump turning on; the momentary load generates a tiny brownout before the generator catches up. This time I noticed the oven heating also caused this kind of fluctuation a couple times a minute, a little weird since you’d hope the heating element was a steady load.

Unifi Network Controller on Ubuntu 20

Ubiquiti’s Network Controller comes in an apt installable version for Ubuntu. For the most part their instructions just work. The one wrinkle I ran into with my Ubuntu 20 system is that the service wouldn’t start with systemctl having an error “Cannot locate Java Home”.

The solution for this was to manually install an older Java.
apt install openjdk-8-jre-headless
Their controller seems to require Java 8. The apt page has some confusing instructions about preventing Java 11 from being installed with apt-mark, but at this point we’ve moved on to openjdk-14 in Ubuntu land. Anyway Ubuntu lets you have multiple JREs installed with no drama.

The network controller is running as an HTTP interface on port 8080. Terrible choice of port (this is changeable). Once you do initial setup though it seems to start redirecting you to port 8443 instead.

I needed to migrate the devices from the previous network controller I’d installed. This all seems to be anticipated in the UniFi system, there’s instructions here on “adopting” the device on the new controller. I had to stop the old controller from running for the new controller to see the devices before adoption.

I also set it up to email me alerts for important things on the network. That requires an SMTP server. I grudgingly gave it a Gmail password, but only after creating a specific app password at Google only for this device.

Why am I doing all this? I’m upgrading some parts of my home network (finally installing a cellular backup for the ISP) and am finally fully embracing UniFi, Ubiquiti’s current platform for their networking equipment. I have UniFi access points and ran their controller software once, grudgingly, to install them. But I still have an old EdgeMAX router that predates UniFi. Or rather will for one more day.

The UniFi Network Controller has turned into a pretty good piece of software, btw. I was impressed when it helped me diagnose a WiFi performance problem I had with an old 802.11n device.

Propane tank monitoring

Wanted to give a shout-out to Tank Utility, a company that makes a gauge for monitoring your propane tank level via the Internet. Unlike most IoS devices it works great!

It’s very simple; $200 gives you a ruggedized battery powered outdoor thing you mount on your propane tank. There’s a small sensor that clips on the “remote ready dial” on your propane tank, I think it reads the needle setting via a Hall effect sensor. You do a one-time setup with a phone app for the WiFi and then the device will just quietly report the propane level a couple times a day to their free cloud service.

For end consumers they provide a decent mobile app for monitoring propane level, they also have a simple API for downloading the status. I think their real business is selling to propane companies, they have a commercial offering that I imagine tells the propane company when it’s time to deliver more fuel.

The clever thing in the device is it works off a few AA batteries but is designed for a battery life of up to 5 years. I think the thing is basically fully powered off most of the time and only powers up to connect briefly to the network to send a reading.

The main risk with this device is if the company disappears it will stop being useful. I wrote and asked them if they had a contingency plan for that and unsurprisingly for a small company, they didn’t have a good answer. The company seems just cool enough I could imagine them doing some one last update that enabled people to run their own monitoring server. Hopefully the company has a long life and the question never comes up.

Separate speakers and headphones, take 2

My old system was annoying in that it only had one audio device for speakers and headphones. If I plugged in the headphones, the speakers would be disabled. It worked OK but it meant I was regularly plugging and plugging a fragile cord.

The new motherboard seems to have genuine separate audio devices for Speakers and Headphones. I can play to one or the other or both. I can set speakers for my default audio device and headphones for my default voice chat device. The Windows UI for switching between them is not awesome, but the functionality does work.

I wonder why this works now. The old motherboard has a “Realtek® ALC887 8-Channel High Definition Audio CODEC” (with LED lighting!). The new one has a “Realtek® S1220A 8-Channel High Definition Audio CODEC featuring Crystal Sound 3” (no LED lighting.) The old system was capable of treating the two outputs separately but I could never make it work reliably.

Now if I can just convince Windows to never, ever re-enable the crappy monitor speakers at the other end of my DisplayPort cable...

Turning off das Blinkenlights

In my last post I made fun of the RAM with LEDs mounted on it to flash in gaudy patterns. I’m serious; that crap annoys me. And for some reason blinking lights are all the rage for all sorts of PC stuff, you can’t get away from them. So I finally figured out how to turn them off on my PC.

The CM2 had the coolest lights ever. Also the display was totally for show.

ASUS X570-Pro: has a series of lights blinking RGB patterns on the motherboard. These are called “Aura” in the BIOS and you can turn them off there. These motherboards also have a whole special hardware device for driving individual LEDs in software; I never installed those. And the BIOS also makes a distinction about “functional lights”, which I imagine are a few LEDs and the Q-Code 2 digit display that tell you basic useful things like “is the motherboard working?” I left those on.

EVGA GeForce 1080 FTW: this has some very bright LEDs on the back, right at the display connectors. The NVidia Experience bloatware contains a standalone program called LED Experience that you can use to configure the LEDs. Setting effects to “off” results in the lights still being on. So instead I selected the effect of a constant color at brightness zero. Seems to work.

PC RAM speed: JEDEC vs XMP/DOCP/EOCP

I had one hiccup on my new machine: the RAM wasn’t running as fast as it should. Long story short: I enabled DOCP (aka XMP) on my Asus X570-Pro motherboard and it runs right now. No detailed overclocking or anything, just one setting. The tech behind all this is fascinating so I’m going to write more.

First, a shout out to the bros at Corsair who branded my RAM with the name VENGEANCE. I feel more deadly already. You can also buy DOMINATOR memory with flashing LEDs on it. No, really.

VENGEANCE Platinum RGB RAM all lit up

Memory timings

Modern PC memory is defined by a complex set of memory timings. I bought two CMK32GX4M2Z3200C16 modules, the specs of which are DDR4-3200 CL16 (16-18-18-36). WTF do all those numbers that mean?

The most important stat is the DDR4-3200. That’s the basic speed of the RAM I/O channel and bigger is better. The actual clock is half the number so it’s 1600MHz or 0.625ns cycles. You get two 64 bit words through per cycle, so that results in 25,600 MB/second throughput. Modern memory tends to vary from DDR4-2400 to DDR4-4800, with my DDR4-3200 being typical. (That’s the spec fastest memory my Ryzen 3700X can drive, although many folks overclock to DDR-3600 at least.)

The second most important stat is the CL16. That’s the cache latency, the delay between when a column is selected and the bits can be delivered. 16 means 16 cycles of 0.625ns, or 10ns. That’s a significant amount of time; RAM is much slower than CPUs run. Which is why CPUs have such big caches now. Smaller CL is always better; DDR4-3200 comes in CL14 to CL22.

What about the 16-18-18-36? The first number is the cache latency, the CL16. The other numbers in the 16-18-18-36 describe the rest of the RAM latency. 16 is the best latency you’ll get accessing a new memory cell; the second number 18 means you need to tack on another 18 cycles if you have to change rows, too. I’m not sure what the last two numbers exactly mean but in all cases lower is better.

One last number I didn’t mention; the RAM voltage. DDR4 RAM is standardized at 1.2V. But modern motherboards can overvolt (or undervolt) RAM to try to juice more reliability out of them. A lot of RAM works better at 1.35V.

SPD: JEDEC, XMP, DOCP, and EOCP

So, you buy a RAM module with a bunch of speed, timing, and voltage requirements. How does the motherboard know what to do? It figures it out by reading the SPD, the Serial Presence Detect. That’s a little side channel that RAM uses to tell the motherboard what it can do. Your system BIOS will tell you what the SPD of your RAM is saying. Or you can use a program like CPU-Z to tell you.

My RAM has at least 4 advertised timings; three JEDEC timings at 1333MHz, and one XMP timing at 1600MHz. So my motherboard could choose to run the RAM at any of those settings. But I paid for 1600MHz RAM, I want it!

Unfortunately only the JEDEC timings are “standard”. The X in XMP literally stands for “Extreme” (because again, RAM is made by bros). To run at 1600MHz the RAM module wants a little more voltage than is officially allowed. Fortunately the motherboard can provide it nicely. But a motherboard playing by all the rules will only use JEDEC timings.

In an Intel motherboard you enable the XMP timings by turning on the XMP setting. This is 99.99% safe to do. Unfortunately the XMP term or technology, is Intel proprietary. So AMD systems have other names for these things: AMP (AMD’s name), DOCP (ASUS’ name), and EOCP (Gigabyte’s name). That’s why I couldn’t find any mention of XMP anywhere in the motherboard manual or BIOS. It’s called DOCP on my ASUS board.

So back to the bottom line. Once I turned on DOCP, the motherboard said “oh we can run this RAM much faster”, and I got a ~10% performance boost out of my computer. Technically this is a little bit overclocking but it’s all within published specs of the parts and the motherboard sets it all automatically, so I’m not worried. And now I’m running proper DDR4-3200, the maximum that this CPU officially supports.

But it’s possible to go further, to overclock more. Hardcore nerds buy DDR4-4800 RAM and slap a liquid cooler on their CPU and push everything 10, 20% past what it’s rated to do. I have no interest in doing that myself.

Half a new gaming PC

I got most of a new gaming PC. ASUS X570-Pro motherboard, Ryzen 3700X CPU, 32 GB of DDR4-3200 RAM. Reusing all my old parts, including the GeForce 1080. $680 from NewEgg.

My old gaming PC gave up the ghost; wouldn’t turn on. After sitting in an 85F house for a few days and also maybe some messy power fed to it (albeit turned off). Looks like the motherboard died. I looked at just replacing the motherboard but new ones cost double what they did originally, used ones were sketchy, and there was one plausible looking new X270 motherboard for cheaper but it was a different brand and eh, good money after bad.

So asking friends for advice and a trip through LogicalIncrements I laneded on the Ryzen 3700X with the X570 chipset. Right in the sweet spot of very powerful but not absurdly expensive. Honestly picking a machine from parts these days is very simple if you’re not overclocking.

Motherboard selection is so confusing. You want to pick the right size (ATX for the old school giant computers) and chipset (X570 for the Ryzen 3700X). But beyond that.. I finally figured out ASUS made 2 “normal” motherboards and like 8 gamer boards, the main distinguishing factor of which is a variety of colored flashing lights. So I went for the fancy normal board. I could have saved $100 getting an ASUS X570-P, the barebones motherboard, but I figured it was worth paying extra for a better sound chip, ethernet adapter, and more I/O slots, etc. Probably money wasted but eh.

RAM selection is not so easy either. At some point I realized I wanted to buy the Corsair CMK32GX4M2Z3200C16 RAM, not CMK32GX4M2B3200C16 RAM. WTF? Who knows, but the first one is on the approved RAM list and the second one isn’t. It’d probably work fine, but why mess with that?

I reused my old case (Fractal Design Define R5), CPU cooler (Noctua NH-D15S), and power supply (Corsair RM750X). Props to Noctua for a cheap/free updated mounting bracket for the new CPU. All these parts turn out to be really nicely engineered and I’m glad I can reuse them. It runs so quiet! Also reused my existing SSD drives, Samsung 960 Evo and 970 Evo.

The big upgrade I didn’t do is the graphics card. This NVidia GeForce 1080 was top of the line when I bought it and it’s still able to push games pretty well. This week’s announcement of the new NVidia 3070 and Ampere friends is super impressive, so maybe in a few months I’ll upgrade.

I paid a local Grass Valley computer company to do the assembly because honestly I don’t have the patience. Particularly to remount a heatsink and get all the cables routed just right. They did nice work.

Still trying to figure out if the RAM is running right. I’m using CPU-Z and it makes me think the Memory is running slower than it could be. I need to check in the BIOS to be sure I guess.

Sometime recently Open Hardware Monitor got very good. Finally a no bullshit, standard UI temperature / fan speed monitor. Nice for keeping an eye that the thing is running smoothly.

Ethernet switch failure?

Around 6:30pm last night my network started getting slow. Some quick diagnostics showed I was getting 25% packet loss in my wired LAN; just pinging the router or other machines on the ethernet. This problem persisted between three pairs of machines: my desktop, my Linux server, and my Ubiquiti router. However it didn’t occur to a fourth computer, Ken’s desktop.

My best guess is the ethernet switch at the center of my house failed. It’s an old Netgear 16 port switch, maybe 10 years old. And it’s been awfully hot lately. The key indicator is if I switched my desktop to using WiFi it could talk to the router with no trouble. The WiFi AP is plugged directly into the router and doesn’t use the suspect switch.

The problem seems gone this morning. I checked on my server and it clearly had a bad night. It has a watchdog rule to reboot if the network is down, a rule that got a lot of use. The churn makes the Munin logs mostly useless but this graph of Munin’s own processing time is indicative. When the network is flaky Munin is very slow as it waits on timeouts.

So problems started around 0 1:00 UTC and persisted until 11:00 UTC, or 6pm to 4am local time. Can’t quite explain why Ken’s computer is fine; maybe only some of the ports failed? 10 hours also seems a long time to recover if it was just overheated temporarily.

I have a backup switch, still new-in-box. Debating replacing it pre-emptively or waiting for this one to fail a second time.

Update: I replaced the switch and power supply.

Firefox GPU RAM leak

Update: upgrading from Windows 10 version 1903 to 2004 solved this problem. It looked like 2004 solved the problem, and it might have helped, but my computer just barfed again with Firefox holding on to 25GB of VRAM. And with only like 6 tabs open.

Update 4: after several more months I can say Windows 10 2004 didn’t help anything. The really maddening thing is I have two nearly identical systems (same hardware, slightly different software install history). The problem occurs on one and not the other.

I’m chasing down a problem on my Windows system. Every few days it crashes, the GPU acts like its out of memory. I have a fancy 1080 Ti graphics card with 8GB of video RAM and don’t run things long term that use VRAM, so what’s the problem?

Firefox.

First trick was finding out what system processes were using video RAM. Process Explorer won’t show you. But the built-in task manager will. The “Performance” tab gives you a graph of GPU memory usage over time. And the “Details” tab will show you per-process if you add the display columns “Dedicated GPU Memory” and “Shared GPU Memory”.

When first launched Firefox allocates about 100MB of Dedicated GPU RAM. Then as I watched during the day it climbed; 2GB, 4GB... Even closing all tabs but one tab open to about:memory (as simple and passive a page as you could imagine) all that RAM was still open. After 24 hours it was 4GB. After 48 hours it was 17GB. (neat trick, since I only have 8GB of actual video RAM. I guess it pages?) Closing Firefox entirely does release the VRAM.

I’m still not sure what’s wrong with Firefox that it’s doing this. There are reports from users of this problem over the years: this bug is the best match, also this bug and that one. Not much resolution there. I also can’t find any tools to figure out what inside Firefox is holding the VRAM. That about:memory page is only for CPU RAM, not VRAM.

The most likely theory I’ve seen there is that hardware accelerated decoding of HTML5 video is the culprit. That the video decoder is somehow not releasing VRAM. FWIW my system has media.hardware-video-decoding.enabled set to true, the default. I think I can sort of reproduce that as a bug by watching Twitch and then closing it repeatedly. But not Youtube. I think a real culprit might be me browsing meme videos on Reddit using the Imagus extension (which opens media in a popup window). Another possibility is Reddit’s previews of RPAN streaming video. But I’ve not been able to reproduce it consistently in a way I understand.

Another theory I had was that it was related to the webrender experimental feature. But I have gfx.webrender.all set to false, so that’s not it. Also the leak seems to be triggered only by some kinds of pages, not all, and my impression is webrender would affect all pages.

One last bit of cargo cult advice gleaned from the Firefox bug reports is that Windows 1903 fix KB4497935 might improve things. Reading the Microsoft notes for that I don’t see how it’s related. But I am running 1903 without that patch. I think that’s the next thing I’ll try; install that patch and see if the problem goes away. (Also why am I not running a newer version of Windows?!)

Update: joke’s on me, I can’t install KB4497935 standalone. Installer refuses to run and says it’s not for my system. Maybe it was superseded by a later patch? In general I keep my systems updated, that seems likely. Anyway I’m going to just jump to Windows 10 version 2004 now, that’ll definitely mix everything up.

Update 2: I ran for a couple of days on 2004 and it definitely fixes the problem. At least, mostly. Firefox regularly returns big chunks if video RAM as soon as I close a tab. More importantly I kept it running for two full days and at the end it had maybe 500MB allocated. A bit more than the 100MB or so it started with, but well below the 8+GB that resulted in system crashes before. I don’t know what in particular fixed it, but something in the transition from Windows 10 1903 to 2004 either fixed or papered over the problem.

Update 3: I swear 2004 has helped. But just now I was playing World of Warcraft (uses 2GB of VRAM) with Firefox in the background with about 8 tabs. And WoW complained it had no RAM and when I checked, Firefox had 25GB of VRAM allocated to it. Quitting Firefox fixed it.

Computers are complicated.

UPS vs generator: PFC

I mentioned before my cheap UPS units didn’t work well on generator power. If something turned on (like a pump) that drew a lot of power the generator briefly didn’t keep up, the power dropped, and the UPS would switch to battery. Worse it would fail on my gaming PC, losing power entirely.

These are cheap UPS units, the minimal failover possible. My best guess why my gaming PC would shut down is it was drawing too much power. I never observed the thing taking more than 330W and the UPS was rated to 450W, but maybe that was enough to overload it. But the general unhappiness on generator power, the switching to battery, that seemed bad and fixable.

So far so good with a new UPS, a relatively expensive 1000W unit called the “CyberPower CP1500PFCLCD PFC Sinewave”. I think the key feature here is the PFC Sinewave, which is advertised as “provide sine wave output and correct minor power fluctuations without switching to battery”. That sounds like some form of power conditioning, even when not on battery. I think it’s a step up from basic Automatic Voltage Regulation, which “stabilizes the incoming AC signal to maintain output power at a nominal 120 volts by controlling high and low voltages without resorting to battery power”. Maybe AVR just clips the power at 120V while PFC actually creates a smooth sine wave? Dunno.

The PFC unit costs 33% more than a simple AVR. It may be overkill, I wonder if AVR would be enough to smooth out generator problems. Not sure I care, at this point I’m willing to pay a premium for things that work well.

The step up from this AVR/PFC stuff is a UPS that’s always running on battery. There’s AC power coming in to charge the battery, and AC power being generated off the battery, but AC never flows direct. These units are significantly more expensive (2x or more).

Oh, one downside of this CP1500PFCLCD is that it runs a fan when it’s on battery. Fairly noisy. Presumably a heat thing.

Ubuntu 20 vs Sonos: SMBv1

After I upgraded to Ubuntu 20.04 my music library stopped working on my Sonos. Turns out this is a Samba problem. Somewhere along the line Samba disabled SMBv1 by default; apparently it’s insecure and old. However some clients like Sonos only support SMBv1, so the result sucks.

The fix is easy. Add this to your smb.conf and restart Samba

server min protocol = NT1

I also have these lines lurking around for other obsolete clients, but I’m not sure they even work any more. They aren’t necessary for Sonos.

ntlm auth = yes
nltm auth = ntlmv1-permitted

Sonos sure could do a nicer job of error handling. The only error you get is “it failed” with a link to some irrelevant docs about Windows stack size. I figured out the real problem in this Reddit thread.

Apparently this is also a problem with Synology servers, which recently switched to SMBv2 or above only.

I don’t know if there’s a security risk in exposing SMBv1 this way. It’s all behind my firewall so I’m kind of hoping the Maginot line keeps me safe. Also it’s a freakin guest read only fileshare, why is there any login protocol at all? Ugh.

It’d be nice if Sonos upgraded to a newer SMB client, but apparently they’re not in a hurry to. And now given the major platform switch plus their emphasis on streaming services over local music, I’m a little afraid SMB may never be updated on Sonos.

Simple Unix file encryption

I want to password encrypt some Unix files. In the very old days you’d have used crypt(1) for this, but that’s deprecated now because the algorithm is junk. So many tools are deprecated now. The key thing is I need a simple tool that I can likely get working again in 10, 20 years. Also I want a file encryption tool, something that manages timestamps and deleting old versions and stuff.

I settled on using ccrypt. I don’t love that its on SourceForge but it was at least updated in the last couple of years, and the underlying cipher is good. Ubuntu 20 has it. One drawback is that it doesn’t compress files first, you’re on your own to do that.

Some other options:

  • mcrypt: the consensus choice for a crypt(1) replacement for a long time. Supports multiple algorithms. But it hasn’t been updated in 10+ years and is considered my many to be obsolete.
  • bcrypt: I used this for years, and it still works, but Ubuntu 20 stopped distributing it entirely. Still works when compiled from source. Not sure if the algorithm is still considered secure.
  • gpg: I’m not positive this has a symmetric file encryption mode but even if it does GPG has been such a hairball for so long, forget it.
  • openssl: apparently there’s a way to use this to encrypt files? No thanks.
  • zip: the original zip encryption algorithm is garbage, but various zip versions have replaced it. I don’t know there’s a standard one though.
  • 7z, rar, other archivers: same concerns as zip about being solid encryption and yet also being standard / stable.

Power monitoring generator, well

We have a new generator, since we live in a third world country where PG&E is unable to provide reliable electricity. It works pretty well, a fancy Generac standby unit with load shedding. Even has a decent website monitoring the generator via WiFi, also there’s hacker software for reading the generator’s state from a serial diagnostic port.

Anyway, when we’re on generator power the UPS units sometimes complain, switch to battery power briefly. I think I’ve also noticed the lights flickering. That got me worried the generator was putting out bad power so I hooked up my IoTaWatt to monitor the AC power.

The IoTaWatt’s main function is to monitor power draw through individual circuits. It directly measures current. But it also monitors voltage and frequency via an AC transformer sensor. Near as I can tell it samples that data many times a second but the most detailed data I can get from the status API is once a second. The most detailed graphs are every 5 seconds.

Generator load

Voltage and Frequency. Generator switches on at 12:06

As the above graph shows, the voltage and power doesn’t really change much when we switch over to generator power. Both PG&E and the generator are providing about 122V. The generator’s frequency isn’t quite as stable as PG&E was but a variance of ±0.1Hz isn’t that bad. (PG&E sometimes approaches that variance too.)

Well-related power blip

The graph above shows what happened as 12:17:30, one of the times my UPS kicked in. Turns out just then the well pump turned on (the red line), adding about 1.5kW load (or about double total power, the blue line) in that instant. The generator didn’t quite react fast enough. The power draw of some other loads (yellow and purple, basically room lights) dips briefly. More telling: the frequency of power, the black line, drops significantly, by nearly 0.15Hz. That’s the sign the generator is overloaded, it starts running more slowly and the frequency drops. It recovers quickly enough, but it’s enough to make a sensitive UPS unhappy and cause a visible flicker in the lights. Note the voltage (green line) doesn’t notably drop; I imagine the generator has a voltage regulator that smooths this out.

So that’s why the lights flicker and the UPS complains. I think that’s just a limitation of a consumer generator. It’s plenty of power to make everything run, but it’s not quite as clean as when you have utility power.

Well

Looking at this reminded me to take another look at what the well pump was doing.

It’s still coming on every 30 minutes or so even when there’s no water demand at all, which suggests a leak somewhere. I know it’s not outside, because I turned that valve off. I’m pretty sure it’s not inside either, I’d have noticed. Maybe the well is leaking back into itself, against the check valve? Dunno. Like I said before it’s wasting about $0.50 of electricity a day, but otherwise seems mostly harmless.

Above is a cumulative graph of well power usage over 24 hours (blue) with transitory power (green). As you can see we use a lot of water overnight, when the irrigation is running, about 5kWH or $2 worth. The well doesn’t stay on continuously for much of this, other than one period about 6:15am. Our water system has no buffer of any kind; no tanks or reservoirs.

Ubuntu 19.10 to 20.04 upgrade failure

I seem to be cursed when it comes to Ubuntu updates. I just tried upgrading Ubuntu 19.10 to 20.04 (ie: eoan to focal) on a ordinary home server. Once again do-release-upgrade failed right as systemd was being updated. In the past that’s because the systemd upgrade broke my network configuration, because of course I’m doing the upgrade via ssh. (In a screen session though!) This time around it was worse, because the system wouldn’t boot:

- - -[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]- - -z

Well that’s exciting.

Turns out this is a well known problem with an easy solution. Basically if something interrupts an apt upgrade of the kernel at the wrong time, the kernel will be installed and chosen as the default but the matching initrd ramdisk to make it bootable won’t be properly installed. (ramdisk creation seems to be deferred to the very end of the apt process). The result is the system won’t boot with the new kernel. UEFI may be part of what makes this a challenge.

Fortunately there are usually other older kernels also installed that still work on the hard drive, so all you have to do is convince GRUB or whatever boot loader you’re using to boot an older kernel. Then you can go in and fix things.

The command that seems most clearly to fix things is
dpkg --triggers-only linux-image-5.4.0-29-generic
Of course you need to substitute the right package name there, for the latest kernel that’s not booting. You can find it this way by listing all packages installed with “triggers pending”:
dpkg -l | grep ^it
Another bit of advice on that Stack Overflow page is to run
dpkg --configure -a
This will force any packages that were installed but not configured to configure themselves. My aborted Ubuntu upgrade seems to have left me with ~40 unconfigured package, this fixed them all in a jiffy.

I sure wish I knew why upgrading systemd sometimes breaks networking on Ubuntu. It’s happened on two different systems of mine. And it’s an absolute disaster if you only have local access to the machine. Hilariously, do-release-upgrade still advises against running it if you’re ssh into the machine. How am I supposed to update the machine, fly to the datacenter and type at the keyboard?!

I also wish that apt or do-release-upgrade were a little more robust in leaving you with a bootable kernel.

The good thing here is that apt and dpkg are very robust themselves. This is the third time I’ve had do-release-upgrade fail on me now, but each time I can pretty much rely on apt and dpkg to fix whatever mess was created.

Bonus round: USB keyboards

This whole ordeal got a lot more complicated because I couldn’t find a keyboard to plug into the Intel NUC hardware to access the boot console. I use an old USB wired Apple Mac 101 key keyboard on my regular computer. For some bizarre reason that fails to work when plugged in to the NUC for accessing the BIOS. I ended up having to wait two days for Amazon to ship me a cheap $10 Chinese keyboard. That’ll teach me to not have a bunch of old computer parts lying around the house.

Making Amiibo for Animal Crossing

Nintendo has this system called Amiibo where you buy little figurines for a game and then scan them on your Switch console to do various in-game things. Breath of the Wild Amiibo unlock outfits, for instance. And Animal Crossing New Horizons Amiibo unlock new villagers to come live with you.

But Amiibo are expensive! New they are in the vicinity of $20 on Amazon. And there’s some collector / scarcity thing going on too so some of the rare ones are like $100. I’m not a big fan of paying real money just to unlock digital content. I mean sure I’ll pay for a major DLC, but I have no ethical problem creating my own unlock for a character.

Anyway, it turns out that Amiibo are just NFC 215 tags. And those are easy to write with pretty much any NFC-capable mobile phone, or with a $30 bit of NFC hardware. (Surprise! Your phone can write tags as well as read them!) And of course you can easily find the tag data online.

I ended up following this guide on Reddit. The FAQ is helpful too. In short:

  • Buy some blank NFC 215 tags on Amazon. They cost anywhere from $0.25 to $1.00 each depending on volume and shipping speed.
  • Get an NFC writer. I used TagMo on my Android Pixel 3 phone. It’s an unauthorized app, so you’re taking a small security risk installing it.
  • Get the special unfixed-info.bin and locked-secret.bin files installed on the tag writer. They’re only 80 bytes each. See the Reddit guides for where to find these.
  • Get the Animal Crossing tag data. This requires downloading files of dubious licensing status. A site called NFC Bank is a popular source.
  • Burn the tag. You can then scan it again to test it.
  • In game go to Isabelle and choose the Amiibo option for inviting visitors. Scan your new tag with the game controller.

The one small bummer is the cheap tags aren’t reusable. There’s alternate hardware which will spoof NFC tags for you. I think also some more expensive writable tags are re-writable.

Another option if this all seems too hard is you can apparently buy pirated Amiibo tags on Etsy, eBay, etc. Folks put a lot of effort into making nice cards or buttons for them too so they look good.

Firefox browser versions for Android

Summary: Firefox Browser is the stable consumer product. It’s about to be replaced with Firefox Preview, a major new release you may want to switch to early. There’s also a collection of betas and nightly builds.

One thing that’s nice about Android is that Firefox works nicely on it; there’s no iOS requirement that all browsers really just be reskinned versions of the vendor’s browser component. I’ve set up Firefox to be my default browser and that setting mostly sticks other than Google launching Chrome occasionally on me. I think Firefox is even used as an embedded browser in other things, but I’ve never been sure.

Anyway, the confusing thing is there’s so many things called Firefox on the Google Play store. Here’s a rundown of them all.

Firefox Browser (org.mozilla.firefox): this is the one you probably want, the mainline consumer app. This is currently version 68.8.0. This is the old Firefox that’s been around for awhile; this is not the new version announced in January 2020.

Firefox Preview (org.mozilla.fenix): this is the new hotness. Version 4.3.0 for me right now, but also says “GV: 76.0”. It’s a major update involving a port to GeckoView. See also these details of new features. Dark mode, more privacy, an option to put the toolbar on the bottom of the screen (near your thumb), a Private Browsing button right on the tab selector. Main change though is a full new rendering engine. Supports fewer addons, but does have uBlock Origin. This new stuff is slated to be released to the public as the Firefox Browser pretty soon.

Firefox for Android Beta (org.mozilla.firefox_beta): this looks like a slightly older version of Firefox Preview. Currently reports version 75.0.0-beta.6, also “GV: 75.0”. I would guess ordinarily this would be the cutting edge beta version of Firefox but right now during the transition to the new hotness, Firefox Preview is getting updates faster. Not positive.

Firefox Nightly for Developers (org.mozilla.fennec_aurora)
Firefox Preview Nightly for Developers (org.mozilla.fenix.nightly): I didn’t test these. I assume they’re just nightly builds of the two main development lines. FWIW the Preview Nightly currently reports “GV: 78.0a1” so it looks fairly far ahead of the main Firefox preview

Firefox Focus (org.mozilla.focus): a privacy-oriented experimental browser. Version 8.2.0 (75.0) right now. I think this was most relevant a couple of years ago and has taken a backseat to what is now Firefox Preview, which includes some of the same privacy features.

There’s also a bunch of stuff using the Firefox brand name that isn’t a browser at all. Firefox Private Network VPN (org.mozilla.firefox.vpn): is Mozilla’s new project selling VPN service to users. Firefox Lockwise (mozilla.lockwise) gives access to the Firefox password store. I think they’re trying to become a password agent like 1Password? Firefox Send (org.mozilla.firefoxsend) is a tool for sharing files. Last update was March 2019, not sure if the project is abandoned. Notes by Firefox is yet another text memo product. Firefox ScreenshotGo organizes screenshots with OCR and text search. And finally Mozilla Stumbler is a wardriving tool for building out Mozilla Location Service data. Last release Feb 2019.

Android Tablet: Samsung Galaxy Tab S5e

I just got a new Android tablet to replace my 2017-era iPad. Since moving to an Android phone last year (Pixel 3) I’ve come to realize I just like Android more. For ordinary stuff ordinary people do, Android is good, just as good as iOS. Sure there’s nits to pick with both systems, but they’re both great.

What I like about Android is that it also allows a level of more sophisticated stuff. There’s a brilliant capability for apps to interact with each other, for instance, setting things up like Unix pipelines. Android out of the box lets you customize the keyboards, the launcher, really most aspects of the system UI; no jailbreaking required. And a fair number of the Android apps seem more hacker friendly than their iOS equivalents.

Android’s ecosystem also does seem genuinely more open. Firefox integrates as a browser way better on Android than Apple ever allowed. Want to add more storage? There’s an SD card slot. (Why the F has Apple never allowed that?) Want to buy a book in the Kindle app? Of course you can; it’s not like iOS where Apple demands their 30% cut. Want to sideload an app from some random site? No problem, just disable the security check and you can. (A double edged sword, to be sure.)

The big downside to Android is that the vendors don’t distribute vanilla Android, they hack and munge and add crap. Worse they subtract value, particularly in how they sit on operating system versions for months, years, forcing folks to run out of date buggy versions. Google really needs to get more control of this problem.

Hardware

Another problem with the Android ecosystem is the hardware quality varies. I dorked around with an Amazon Fire 7 briefly but the hardware is such garbage there was no joy in using it. (To be fair, it was super cheap.) And tablets are seen to be a losing market for some reason, particularly on Android, so there’s not a lot of options.

I read a bunch of guides online (this one was the best) and landed on the Samsung Galaxy Tab S5e. It has an excellent screen (2560x1600 AMOLED), is very thin and light, and at $350 is cheap enough to feel like an accessory / toy, not a whole laptop. The Galaxy Tab S6 is the new flagship, better in most every way, but at $650 it’s awfully pricy. The only thing it’s really missing is S Pen support but I had no desire to have that anyway. There’s an S6 Lite coming but it seems worse than the S5e for the same price, I don’t quite get it.

The S5e hardware seems great. Very solidly built. Nice camera I’ll never use, a working fingerprint reader for unlocking, wifi seems good. Screen is lovely although there’s some weird white balance software at work that’s not helping. Only complaint so far is I can’t find a magnetic cover just for the screen; all the cases are wraparound and cover the back too. Oh well.

Software

So, what about the software? First, the big problem; it’s still only running Android 9. Android 10 came out eight months ago. Being on 9 puts me well ahead of a lot of crappier Android devices, but I hate being beholden to Samsung to get around to putting out an OS release.

Still it works nicely as a stock Android system, there’s none of the lockdown shenanigans that Amazon Fire does trying to keep you from customizing. The GBoard keyboard installs fine, including local voice recognition. Samsung’s launcher is OK but I switched to Nova Launcher mostly because it alphabetizes the apps tray view. Also it’s nicely customizable.

Samsung does install a bunch of its own crap, but it mostly stays out of the way. Bixby was the biggest annoyance but Nova Launcher mostly hides it. For some reason there’s two Clock apps and two Calendar apps and the like, one Google and one Samsung. Meh, I can live with it. It’s annoying Samsung won’t let me remove their preinstalled stuff.

But Android is hacker friendly, so you can install them! I followed this guide to uninstall a bunch of apps using adb to get a command line shell on the tablet. (Try that on an iPad, lol.) Another option is to use a guide like this one along with an app and config files which debloats the device for you. I wanted to control it myself, so I did it by hand.

I already had adb on my system thanks to having Android Studio. The adb.exe executable is in /Users/nelson/AppData/Local/Android/Sdk/platform-tools for me. Here’s a list of stuff I uninstalled by hand:

  • com.microsoft.skydrive
  • com.microsoft.office.officehubrow
  • flipboard.boxer.app
  • com.samsung.android.calendar
  • com.samsung.android.contacts
  • com.sec.android.app.popupcalculator
  • com.samsung.android.email.provider
  • com.sec.android.app.kidshome
  • com.sec.android.app.samsungapps
  • com.sec.android.app.samsungapps
  • com.sec.android.widgetapp.samsungapps
  • com.sec.android.app.sbrowser
  • com.sec.android.gallery3d
  • com.samsung.kidsplay
  • com.samsung.android.app.notes

Special GSAM bonus notes

I use the GSAM Battery Monitor to track battery usage for apps. It works fine by default, but it can work better if you grant extra permissions to the app to let it get at some debugging APIs. There’s multiple conflicting instructions online about how to do this, including a very nice tutorial in the app itself that works right until the final crucial command. I think this worked fine on my Pixel 3? But it didn’t on this tablet, what finally worked was at the bottom of this discussion:

adb -d shell pm grant com.gsamlabs.bbm android.permission.BATTERY_STATS

TCL Series 6 TV

Just got a new TV, a TCL 6 Series and couldn’t be happier. I bought it after this glowing review. Pretty much every other review says the same thing; excellent picture quality for the price. It’s quite cheap even for an LCD TV, and definitely way way cheaper than an OLED.

I’m not able to judge picture quality except to say it looks great to me. It’s better than the 2013 era Samsung panel it replaced; brighter, bigger, sharper. The 4K 60fps demo reels look amazing. Of course the default picture settings are oversaturated garbage, but fixing that isn’t too hard.

The key picture setting for this screen is “movie mode”. That means “don’t blow out the colors”. However when you enable that it also for some dumb reason defaults to “warm color temperature”, which shifts all the colors to the red. So set that back to normal. Also it turns off Local Contrast which is one of the nice features of the set, so turn that on to high. Then turn off all the fancy motion interpolation type stuff and it looks pretty great.

I particularly like that there’s a quick setting for “darker / normal / brighter”, which means you might actually change that based on time of day and room lighting. There’s also a game mode for HDMI inputs that has decent latency (19ms, or just about one frame).

One nice feature for this set is that its operating system is Roku. Not some dumb badly designed TV manufacturer stuff, just good ol’ Roku with its open ecosystem of third party channels. I’ve been using Roku devices for years, mostly for Plex and Netflix and Amazon, it’s nice to have it native in the TV. I managed to get ARC (“Audio Return Channel”) working so the sound is still being sent to my fancy AV receiver for decoding.

Speaking of the receiver, I’m less clear on what to do with it now. It’s limited to 1080p (or 2160p @ 30 fps, lol). And seems to block HDR too, or at least my PS4 won’t do HDR through it. I guess I could just plug all my inputs in to the TV and use the receiver solely as a digital audio decoder + amplifier. The wiring is tidier if the receiver is a switch, but then I can’t pass 4K/HDR content through it. If I didn’t already have speakers installed in my walls I think I might just get a nice soundbar and call it a day.

Still haven’t considered the joy of making my old Logitech universal remote drive the new system. Need to settle down how the receiver fits in first.

4K is still such a bandwidth hog I can’t imagine I’ll be using it much if any for watching video. Would like it for games though. HDR interests me much more, it’s great we can finally get higher contrast ratios on TV sets. Apparently there’s competing standards for HDR, awesome. This panel supports both Dolby Vision and HDR10, which I guess are the two most common formats. Hopefully that’s good enough.

Upgrading from an unsupported Ubuntu (18.10 to 19.10)

Update (March 2020): I’ve heard from 10+ people who say these instructions work for them, I think it’s reliable. See also this Ask Ubuntu post. Some folks are finding their way to this blog searching for “An upgrade from ‘cosmic’ to ‘eoan’ is not supported with this tool.” That makes sense, it’s the error the upgrade tool gives. Finally, if you see an error about “Upgrades from 18.04 on the i386 architecture are not supported” that is sadly true; 32 bit support stopped in 18.04. I don’t know how to help you with that.

A couple of weeks ago I blogged about being unable to upgrade from Ubuntu 18.10 (cosmic) to 19.10 (eoan), or even 19.04 (disco). Ubuntu 18.10 is fully end of life and deprecated and the do-release-upgrade tool we normally use to upgrade things refused to run. (Note that this tool is bundled in the ubuntu-release-upgrader-core package) Fortunately one of my readers Alejandro saw my post and suggested a solution. I just tried it and it works. Details below.

The underlying problem is do-release-upgrade on 18.10 was trying to upgrade directly from 18.10 → 19.10. But that’s not possible. And it’s no longer possible to upgrade 18.10 → 19.04 because 19.04 is also not supported. So you’re stuck.

The gist of the solution is to hack a config file to force an 18.10 → 19.04 update. It turns out Ubuntu’s do-release-upgrade tool is a generic program, the version installed on an 18.10 system is not 18.10 specific. Instead it downloads metadata files from the Internet and uses those to figure out what to do. Alejandro’s suggestion boils down to intercepting those metadata files after download and hacking them to point to 19.04 instead of 19.10. The packages needed to do the 18.10 → 19.04 upgrade are still online, do-release-upgrade just wasn’t finding them.

Needless to say, the instructions below come with a big warning this may break your system. It worked for me, but no idea if it will work for you.

18.10 → 19.10 steps

  1. zRun do-release-upgrade on the 18.10 system. This will give you an error about being unsupported. But behind the scenes, the tool will download some metadata files we want to modify.
  2. As root, go in to /var/lib/update-manager and copy the file meta-release to a new file meta-release2. This file was downloaded by do-release-upgrade from the Internet and tells the upgrader how to upgrade.
  3. Edit meta-release2. Remove all entries for eoan entirely. Modify the disco entry so it says Supported: 1
    Update April 2020: reader F.K. write to say “I found that ubuntu repo returns 404 and `do-release-upgrade` can’t run update. I changed all link in meta-release2 for disco to  http://old-releases.ubuntu.com/  and its works.” I can’t test this but it seems plausible of Ubuntu finally moved the disco update files out of the live repo (say, in preparation for the 20.04 release.)
  4. Edit the file /usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py. Change this line of code
    self.metarelease_information = open(self.METARELEASE_FILE, "r")
    To read
    self.metarelease_information = open(self.METARELEASE_FILE + "2", "r")
    That will tell the upgrader to use your modified file instead of the original. (It will also avoid any redownloads overwriting your changes.)
  5. Run do-release-upgrade. It should now be doing an upgrade 18.10 → 19.04. Let that run as normal and reboot.
  6. Congratulations! You’re now running 19.04. Remove the /var/lib/update-manager/meta-release2 you made.
  7. Since 19.10 is supported, all you have to do to upgrade 19.04 → 19.10 is run do-release-upgrade again. No hacks necessary, you’re back on the main path.

Like I said, it worked for me. I’m a little surprised Ubuntu doesn’t support this officially out of the box, it seems simple enough. I suspect they just want to have nothing at all to do with older systems. Still if it were me I’d add some flag to enable at-your-own-risk upgrades for people like me who were stuck.

I think I also could have upgraded my system simply by editing /etc/apt/sources files and relying on apt dist-upgrade. That’s the underlying tool that’s doing all the work anyway. But the Ubuntu upgrade scripts have a little extra stuff in them and it’s nice to be able to run it just in case it’s important.

I’m very grateful to Alejandro for his emailing me the suggestion on the fix.

Adding a new SyncThing node

I’ve been using SyncThing for awhile now to keep several Windows PCs in sync. Mostly the Documents folder, also some saved games. It’s been working great since I set it up, so well I’ve nearly forgotten how it works.

I decided to add it to my laptop today. Which begs the question; what’s it like to bring in a new machine to an existing sync cluster, one with possible conflicts in the folders? It mostly went OK but some awkwardness.

To add a new machine to the node all you have to do is install SyncThing and then go to “Add New Device” on the new machine. I have a hub-and-spoke system (3 Windows spokes, one Linux hub that’s the primary copy) so I just added the Linux hub device. Approve it on the GUI of the hub machine, accept the folders it offers, and it all worked OK.

Well mostly. I had some file conflicts, as expected. There’s a conflict resolution tool but it’s very confusing. It talks in terms of “original” and “conflicted” file and I’m wondering; original to whom? It seems to have no idea of three way syncs or merges. I looked and realized I had a backup of all the files and none were important anyway, so I just blindly accepted “take the newest” for all the conflicts.

The uglier problem was errors that some files were not transferring, with an error in the GUI of “file modified but not rescanned; will try again later”. I looked online and found this is often a symptom of a case mismatch. Windows filesystem is case insensitive but still stores cases, maybe it got confused with the Linux copy. I finally resolved these by deleting the files everywhere across my cluster and then restoring it to the hub from a backup, then letting the new copy propagate. Ugly but effective.

The last problem I had was one file refused to copy: sync_ffs.db. That’s a file that a different sync system (FreeFileSync) uses. It has some magic properties that make it unwriteable or something. I simply instructed SyncThing to ignore that file, no more problem.

So all in all a bunch of ugly manual work. Which is in keeping with SyncThing; it’s a great tool but it’s not exactly civilian friendly. The good news is that once it’s set up and syncing it seems quite reliable.

I can’t imagine what topologies more complex than hub-and-spoke behave like.

How big can an ethernet network be?

Switched ethernet is magic. You buy relatively cheap devices, plug everything into them, and packets get where they’re supposed to go without any complication. Well that’s the simple version at least; modern networks with managed switches and VLANs can get complicated. But the basic system is simple. My question is how big does that scale? How many switches and ports can I have on a switched ethernet network?

The classic folklore answer is apparently 7 hops. The network can be no bigger than 7 hops in diameter. That’s pretty big though. Assuming you had 8 port switches in a tree configuration, I think that’s 8^7 = 2,097,152 devices. But IIRC each switch has to maintain a state table of the MAC address of every one of those 2M devices; I imagine in practice there’s not enough RAM for anywhere near that much.

The 7 hops number apparently comes from IEEE 802.1d which formally defines the Spanning Tree Protocol that underlies Ethernet switch routing. Basically magical elves run around your network and divine its topology, then construct a minimal spanning tree so everyone can reach everyone. From what I’ve read it’s not clear that 7 hops is a hard limit so much as it is guidance about practical limits. I suspect it’s mostly governed by latency.

802.1d is very old though and has been superseded. 802.1Q codifies VLANs and the multiple spanning tree protocol. 802.1aq adds Shortest Path Bridging, which I think is a way to let an ethernet use multiple physical routes to increase bandwidth. I’ve never used any of this stuff, but I suspect it changes the assumptions that underlie that 7 hops rule of thumb. OTOH I wonder in practice. With VLANs and managed switches it’s logically reasonable to consider much larger networks working on layer 2, without IP routing involved.

Cheap PC hardware watchdog

I have a Linux PC server that flakes out and locks up solid every few weeks. I tried using a software watchdog to fix it but it didn’t help. My guess is the whole CPU is freezing, so even the watchdog can’t run.

I’ve fixed the problem for now with a hardware watchdog. Some $10 anonymous Chinese hardware designed for Bitcoin mining rigs.

It looks like a USB device, but the USB is only for power. The main I/O are two pairs of wires: one that connects to your hard drive activity LED, one that connects to your hardware reset switch. Yes, it’s that dumb. Basically it just watches the LED and if it hasn’t flashed in awhile (no idea how long, maybe a minute?) it sends a reset to the motherboard.

It looks like a USB device, but the USB is only for power. The main I/O are two pairs of wires: one that connects to your hard drive activity LED, one that connects to your hardware reset switch. Yes, it’s that dumb. Basically it just watches the LED and if it hasn’t flashed in awhile (no idea how long, maybe a minute?) it reboots the computer.

It seems to work, although I haven’t had a real test yet. Most importantly, it hasn’t caused a false reboot after 36 hours of testing. It did reboot the computer when I ran /sbin/halt though, which is a good sign. I had to stare at the panel of my computer for awhile to verify the HDD activity light was actually flashing. Apparently this light works even for modern SSDs plugged in via M.2!

(Fun fact: /sbin/shutdown -h, the command I always use to halt computers, doesn’t actually halt. See this systemd man page for details. “-h” is a synonym for “--poweroff”. You want “-H” or “--halt” to actually halt the CPU without also shutting off the system power. I imagine this is for historical reasons; back in the old days you couldn’t turn the power off with software. Then when that became possible it became the default because it’s almost always what you want.)

There’s a bunch of versions of this hardware watchdog idea; this one is reasonably well documented. Power could also come from an old school Molex connector or using the 9 pin USB motherboard connector, maybe with an adapter. I just routed the wires outside the case and used an external USB port. It’s all spectacularly dumb.

The one hassle with the device I bought is it doesn’t have cable splitters, it replaces the existing LED and switch. I bought some ridiculously overpriced splitters. (Turns out this kind of cable and connector is called “Dupont Line” or “Dupont Cable”.) Now my LED isn’t flashing any more; either I screwed up the wiring or there’s not enough power once split.

When I saw the USB port I assumed this device worked by monitoring the USB port itself. Test if the USB host was working. But that’s a fairly high level test and you could imagine various scenarios where it wasn’t appropriate. I imagine most computers doing useful work are still tickling the hard drive regularly enough this approach is better; if nothing else, than for logging.

Update Mar 29 2020: I’ve had this for a few weeks now and it’s rebooted my computer twice. At least one time I looked closely and it seems it really should have, the machine had locked up. So good job!

Wanderings tracker vs GPSLogger

Summary: after 9 months, the GPS data being logged by GPSLogger on Android looks good to me. At least good enough for Wanderings’ location tracking and heatmap.

One casualty of my switch from iPhone to Android is my own Wanderings app, a lightweight GPS tracker that Brad and I worked on together. There’s an iPhone app that tracks your movements and records data and a webapp that displays the data. But we don’t have an Android version of our tracker and I’ve been unmotivated to learn enough Android to write one.

I have been running Mendahk’s excellent GPSLogger though and it is faithfully recording my location every day to GeoJSON and CSV files in Google Drive. I finally got around to collecting all that data and visualizing it with our web app. Qualitatively it looks the same as the data collected a year ago by the Wanderings tracker. That’s good! See screenshots below.

I haven’t done a deep quantitative comparison. But GPSLogger recorded 218,451 points over 284 days, of which 90,877 points were more than one minute apart from each other (a cutoff we use). By comparison our own tracker only stored 6248 locations for me over 574 days. That’s 319 points a day compared to 11! GPSLogger calmed down a whole lot though starting in September, down to about 70 points a day. I suspect that’s when I disabled passive location tracking, resulting in many fewer points logged.

Still GPSLogger is recording 7x as many points as Wanderings. The extra points are harmless to the visualization output but they do incur some storage and processing overhead. The Wanderings tracker is using the iOS Significant Location Change service and only seems to record points when you’re really moving. GPSLogger is configurable in recording granularity. I have it being somewhat aggressive: GPS/GNSS locations, network locations, and a 60 second logging interval with a 10 meter distance filter to log a new point.

I went ahead and looked at distances between points in the GPSLogger output using geopy’s calculation. A whole lot of pairs of points are less than 20 meters apart. I don’t really know what’s correct here, since you do want to capture data with fidelity when the subject is moving. Probably overthinking it. Here’s a quick and dirty histogram of distances for all pairs less than 100 meters apart.

And here’s the promised gallery of app screenshots. Two similar time periods, one year apart. The older is the iPhone tracker and the newer is GPSLogger on Android. They really do look similar.

Getting at Google Drive files from Linux

Google Drive has no Linux support. That’s hilarious. Lots of folks have hacked things up though. I settled on rclone as a command line tool because it seemed maintained and was available in Ubuntu. It’s a generic cloud drive tool able to get at files, etc from many different providers.

The one-time-setup for Google Drive access is awful. It requires OAuth, which is a nice idea but then has the lovely usability of OAuth vs. command line tools. Lots of copying and pasting tokens. Even worse they really want you to set up your own API key. The end result is I had to do a bunch of “register as a Google developer” stuff, including maybe even generating a review request for my OAuth app called “Nelson’s private experiment do not use” (since private apps are only available to GSuite customers). The irony of this being somewhat my fault; I built the very first Google API key system back in 2001. No good deed goes unpunished.

Anyway, once set up it seems to work. My credentials are apparently stored in ~/.config/rclone/ Example commands:

  • rclone ls ‘Google Drive:/GPSLogger for Android/’
  • rclone --progress sync ‘Google Drive:/GPSLogger for Android/’ ‘./gdrive’

I’ve found some awful behavior from Google though; Google Drive seems to be converting my CSV text files into Google Sheets; I can’t get the CSV back, no matter which Google Drive client I try. I filed a bug on GPSLogger about it, but I wonder if it’s my own mistake.

Can’t upgrade Ubuntu 18.10 to 19.10

(Major update: see this blog post for a workaround to upgrade from 18.10.)

I’ve got an Ubuntu 18.10 (cosmic) system. I want to upgrade it to the latest (19.10, eoan). I understand I probably have to upgrade it to 19.04 (disco) first, that’s fine.

Except I can’t.

# do-release-upgrade
Checking for a new Ubuntu release
Your Ubuntu release is not supported anymore.
...
An upgrade from 'cosmic' to 'eoan' is not supported with this tool.

That’s it. No options to help. I get it, 18.10 isn’t supported anymore. But it’s only 15 months old. Surely the old upgrader files are lying around somewhere?

So off to the cargo cult Internet I go.

First thing that looks promising is “How to install software or upgrade from an old unsupported release?” They advise using the old-releases sources as a way to get, well, old releases. That seems promising except following the advice about updating sources.list and running apt update doesn’t work

# apt update
Err:9 http://old-releases.ubuntu.com/ubuntu cosmic Release
  404  Not Found [IP: 91.189.88.153 80]
E: The repository 'http://old-releases.ubuntu.com/ubuntu cosmic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.

So something about the source repo directory structure doesn’t match what apt wants? Or did Ubuntu somehow screw up the release signatures? Beats me.

So I went in to sources.list and tried hacking them all to include [trusted=yes], to ignore this error. Yeah, that’s a scary idea. Doesn’t work though. Or rather “apt update” seems to run an O(n^2) update on 124 different URLs, for ~15,000 separate updates. Or something, I dunno, it’s clearly wrong.

I’m stuck. I understand Ubuntu’s support window, or I thought I did. I didn’t realize that being just a few months out of date left you out in the cold forever. I think a full reinstall is my only option.

Update

I tried asking on FreeNode #ubuntu. No one there knew an answer. Got some suggestions on things to try though. By far the best solution is a full reinstall, but I really hope not to do that. The other suggestion is sort of documented here: basically you just hack your sources list and rely on apt-get dist-upgrade to correctly upgrade the system, bypassing the do-release-upgrade script entirely.

My concern is that do-release-upgrade does some extra thing, like modifying config files, that the dist-upgrade won’t do. But after talking about it I think that’s not true, apt really should be able to do the job. I also remember now I had trouble with do-release-upgrade once before and relied on apt to finish an upgrade for me and it worked fine. It may be it’s OK not to run that script.

Update 2

I updated a different system from 19.04 to 19.10 using do-release-upgrade. It sure didn’t look like that script was doing much other than setting up sources and running apt. I think doing this by hand for my 18.10 system (to 19.04 first, then 19.10) is OK.

Update 3

I went a little further down the rabbit hole of “what does do-release-upgrade” actually do. Useful resources: this old Stack question, this gist essay.

A key thing it does is download an updater from a metadata file and presumably run it. (There’s a shell script named “disco”). It might work to do that by hand, or else you can inspect it to try to figure it out. It’s a lot of code though.

I downloaded the disco updater (which is for 18.10 -> 19.04) and took a quick look. A specific thing to inspect is DistUpgradeQuirks.py. The disco updater has a couple of quirks. IT checks if you’re on an i386 and refuses to run. And it runs a function called _replaceDebsWithSnaps(), which is sort of self explanatory. I didn’t bother trying to figure out which debs were involved. There’s also a list of demoted packages which I imagine is a way to remove obsolete stuff. The powerpc build chain features prominently in the disco version.

So anyway, I now know that do-release-upgrade is doing more than just setting up sources and running apt. But it’s not doing a lot more, at least than I can see, and ignoring that stuff may be safe.

Cyberpower pwrstatd revisited

Eight years ago I wrote a blog post about the Linux software for my UPS. I was pretty negative about it. What’s funny is now 8 years later I’d forgotten about that post and re-installed that software and thought “hey, that’s not so bad”. Mostly because they publish a dpkg which just works. But revisiting my post I see my complaints still apply: requires root, no source code, aggressive shut down options. They’ve even added a thing now where it schedules the whole UPS to turn itself off 10 minutes after the outage. WTF?

Anyway, reconfiguring the daemon so that it never shuts anything down itself, it’s OK software. Not great, not bad. Mostly what I want is the munin plugin for monitoring the thing. I put one in my blog post; someone picked it up, improved it, and has it on Github now. Open source works!

OTA digital TV notes

Did you know TV shows are broadcast for free over the airwaves? It’s amazing; no need to pay the cableman or satellitelady their rent. At least, if you want to watch ad supported non-premium programming.

OTA digital TV has gotten pretty simple. Basically there’s just MPEG-2 streams floating around at ~600MHz for the taking. I just got a tuner and antenna to pick them up. An HDHomeRun Connect Duo for the tuner and a Clearstream Eclipse antenna. Total cost: $100 to $150. There’s other options, see Wirecutter.

So far so good; without any effort to set up the antenna right, in San Francisco I can get 46 channels. Really it’s 12 channels, but there’s multiplexing so where channel 2.1 is KTVU in HD, channel 2.2 is KTVU-SD and channel 2.3 is a random movies channel.

The diversity of channels is pretty neat. I’m enthralled by channel 60.5 PJKFNX which is showing First Nations Experience, a whole channel of indigenous peoples programming. I think YouTube is the only other place I could find content like that.

Devices

The antenna is nothing exciting. Some flat piece of floppy vinyl with some very stiff coax cable coming out. This particular Eclipse antenna has a 20 dB amplifier attached to it. No idea if the amplification is necessary, or if more would be better.

I like the HomeRun tuner. It takes power and antenna in, has ethernet out. That’s it. The device serves MPEG streams and some diagnostic info via a web interface. Very simple and hackable.

Software

I’m currently watching via the HDHomeRun Windows app. It’s a fine bare-bones viewer, backed with some sort of program guide. They run a DVR service too; I wonder if they even bother recording anything or if it’s more of a Sling-like setup. There’s mobile apps too and I think a new Roku app.

The HDHomeRun includes a basic HTTP API for programmatically getting a list of channels and watching MPEG-TS streams. This caveat is fascinating

The client will have a slightly different concept of how long one second is due to slight differences in the client clock timebase vs the broadcaster clock timebase. The client must adjust its concept of real time to match the incoming video stream

No one watches live TV anymore though. I bought this in part because I finally got a Plex Pass and one of the value-adds for that is Plex has DVR software. Setup of the Plex DVR was easy, the program guide is good, and it seems to record OK. Recording seems to run a transcoder stream at 150% CPU on my system which is odd, I have both commercial skipping and transcoding compression disabled. Maybe it’s just having to collect and assemble the chunks. The final output is a .ts container that has what looks like the broadcast MPEG-2 and AC3 streams in it. I’ve set up recording a show regularly, we’ll see how it does.

One thing I’ve noticed is a lot of the older video I’m seeing is interlaced. And I guess decombing isn’t a standard feature. It’s ugly.

Update the DVR seems to work great. I also enabled commercials skipping and transcoding for smaller storage. It seems to work OK. Commercials skipped even in a live news broadcast, which suggests they’re doing some live detection mechanism and not relying on a content database.

Transcoded to 6Mbps 720p (H.264) using about 1.5 CPU cores out of my system’s 8, so the impact isn’t too bad. Resulting file is 3GB/hour for 720p, which is not great, but for a fast transcode it’s not bad. You can see the settings they’re using here; as the commenter points out, a lower CRF would be a nice space / quality tradeoff. Right now it’s not configurable.

Channel availability

I’m currently getting channels 2, 4, 5, 7, 9, 38, 42, 44, 50, 54, 60, and 66 (with many variants). That’s the major “broadcast” networks (ABC, CBS, NBC, and regretfully FOX) plus a bunch of other random stuff. Most channels have 99%+ signal quality, but 60.5 is only 84%. Still looks fine to watch. Note this testing is being done right before the FCC repack when stations get renumbered to free up some bandwidth.

There’s several sites that’ll let you check what channels you should expect. Results below. To simplify things I’m assuming if I get one channel I get all the other related multiplexed ones.

Note each test has a different list of stations. I think what my antenna auto-detected is a strict subset of all of those. What these online sites tell me is I can probably get a few more channels with better antenna placement. I will note I did a second scan and got the exact same result of 46 channels, so at least it’s stable.

AntennaWeb: 2, 4, 5, 7, 9, 11, 12, 22, 38, 42, 44, 45, 50, 52, 54, 60, 66

FCC: 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 14, 22, 26, 28, 36, 38, 44, 48, 54, 60, 65, 66, 68

TabloTV: 2, 3, 4, 5, 7, 9, 11, 12, 38, 42, 44, 45, 48, 50, 52, 54, 60, 65, 66

TVFool: see picture below. I’m not sure their database is current, but I love this nerdy visualization.

Facial recognition for the public: Yandex

You can use Yandex Image Search right now as a pretty good facial recognition system for anyone who has labelled photos on the Web. I believe this is the first generally accessible facial recognition system with a large database. Yandex isn’t designed for this purpose. The trick is to upload photos cropped to a face and it’ll work more or less to find similar faces.

This post was inspired by Bellingcat’s recent post on image search which noted Yandex’s image search as something particularly good and particularly called out the facial recognition. I’m just elaborating on what he found.

Update: see this article about ClearView, a company doing facial recognition with scraped photos from Facebook, etc. Also this Dec 2019 video reporting about Yandex facial recognition. The Daily Mail also published an article based on this blog post.

Demonstration with a selfie

Here’s a selfie I took today. It’s never been on the web before this post and appears in no databases as I do these searches. This is a good clear photo of me, which makes the results better, but it works with less good photos too.

Now pretend you didn’t know my name. Put the image in to Yandex. Here’s the result you get.

The first two images are me. Click on either of them and the web page it takes you to has my name on it. Now you know who I am!

It’s not perfect; there’s no name provided directly, someone has to read the linked page to find one. And a person still has to sift through the near-matches of faces. But it’s pretty good. The only limit is Yandex’s database. That’s kind of “the whole web”, but their index is nowhere as comprehensive as Google.

Demonstration with Andrew Yang

Recognizing myself is easy. How about a stranger? I used this today to identify who the “Yang” was in this image from CNBC. It’s supposed to be Andrew Yang, the presidential candidate, but it is not.

Crop the image to Yang’s face, put it in Yandex, and you get this

All five of the first images look like our guy. The first result on the Yandex result page also leads directly to his home page: Geoff Yang. Some CNBC intern is gonna be in so much trouble! (This post is not an endorsement of Andrew Yang.)

Facial recognition vs image search

The new thing here is that Yandex is working not just as a reverse image search tool; it seems to be doing facial matching. None of the images it finds look much like the original image; different aspect ratio, different background, different details. But the faces match. It even matches my selfie both to a much younger version of me without a beard and to a version of me holding a box up obscuring part of my face. That’s pretty wild.

FWIW, here’s what other image search engines do with my selfie. I tested Google, Baidu, Bing, and TinEye. TinEye returned 0 results.

Google
Baidu
Bing

Look at all the beardy white guys with some yellow in the image! None of them are me. It’s not a bad guess; I gave it a head shot, it found me similar head shots. But it didn’t find my face. Yandex finds my face. (Arguably TinEye’s 0 results is the right answer for this query; this image does not exist online.)

Why this matters

We’re on the cusp of a major change in day to day privacy with facial recognition algorithms. AI has now gotten good enough that it can do excellent facial recognition; modern software can take a blurry photo of half a face and match it to other faces of the same person. It’s a pretty scary future, particularly as already put into place by authoritarian governments like in Xinjiang, but it is inevitable and unstoppable.

Right now an ordinary person still can’t, for free, take a random photo of a stranger and find the name for him or her. But with Yandex they can. Yandex has been around a long time and is one of the few companies in the world that is competitive to Google. Their index is heavily biased to Eastern European data, but they have enough global data to find me and Andrew Yang.

If you use Google Photos or Facebook you’ve probably encountered their facial recognition. It’s magic, the matching works great. It’s also very limited. Facebook seems to only show you names for faces that people you have some sort of Facebook connection to. Google Photos similarly doesn’t volunteer random names. They could do more; Facebook could match a face to any Facebook user, for instance. But both services seem to have made a deliberate decision not to be a general purpose facial recognition service to identify strangers.

There is at least one public recognition service out there: FindClone (hat tip to Brad F). You can read more about FindClone here. (It used to be known a FindFace, and SearchFace.) However it’s limited to photos from VKontakte, the Facebook for the Russian speaking world. It’s a big dataset. But it’s not international like the Yandex search engine is.

I imagine within a few years this “look up a name from a face” will become as common as “look up a name from a phone number”. Not quite ubiquitous because everyone finds it creepy, but easy enough to access if you need it.

Update December 2022

Microsoft / Bing now has Who Is That which does facial recognition, but only for famous people. It does not work with my image.

Yandex seems to have dialed back or removed the facial recognition. Searching my image above now gives a bunch of generic portraits, no longer me.

Update September 2023

See A Face Search Engine Anyone Can Use Is Alarmingly Accurate, about PimEyes.