Tuesday, April 22, 2008

Imperial and nautical units for Google Earth KML APRS view

The unit configuration selected in Options now applies to the Google Earth Network Link, which is produced when you click on the Google Earth KML link on aprs.fi. Fahrenheit temperatures are supported, too. US users should get Imperial units and Fahrenheit temperatures by default, UK users should get Imperial units and Celsius temperatures.

If you have installed the aprs.fi Google Earth APRS link before, and wish to change your units configuration, please do the following:
  1. Delete your existing link from Google Earth by right-clicking the top-level "APRS:" link and selecting Delete (not Delete Contents)
  2. Select your units configuration in the aprs.fi Options window
  3. Open a new KML link using the Google Earth KML link on aprs.fi
This way the new units configuration will be copied over to the Google Earth KML link. When you change your configuration again in the Options, you'll need to delete the existing link in Google Earth and open up a new one from aprs.fi.

Some UTF-8 character encoding issues were also fixed in the KML interface.

Saturday, April 19, 2008

Little enhancements

Joe, K7JD has been pointing out (for quite a while now) that there's more accuracy in the speed and altitude formats used on aprs.fi than would be appropriate. I've removed the decimal digit from the speed and altitude formatting functions now, since there isn't that much accuracy in the source data anyway.

Max, KG4PID pointed out that the info balloons on the map show really old weather data for stations which have sent even just a couple of WX packets sometime in the last summer. I made a small change to make it only show WX data updated within the past hour.

I've also compressed the big javascript files, so that they will download faster, especially on mobile devices. This process can also be called optimizing, since they will run slightly faster on many browsers, and obfuscating, since they're now much harder to read. Sorry about that.

Tuesday, April 8, 2008

Firefox 3 beta not working with aprs.fi

Zach Sadecki was the first to let me know that the Firefox 3 beta has some trouble with aprs.fi. I did some testing, and sure enough, it fails sooner or later with some JavaScript errors being printed in the Error Console. It has something to do with the decoding of the XML in the AJAX XMLHttpRequest responses.

I verified the site still works with Firefox 1, Firefox 2, MSIE 6 and 7, Konqueror and Safari, and went to report a bug in the bug tracking system of the Mozilla project, only to find that Zach had already issued Bug 425586 – javascript doesn't run that works fine on firefox 2.0. So, after a bit more testing, I added a comment there. This seems like a FF3 bug to me, one that is a bit hard to work around in aprs.fi code.

Zack also pointed out that the Gecko-based Epiphany browser suffers from the same problem.

It might be useful if you'd happen to find another ajax-based site which suffers from exactly the same problem. Please, drop a comment if you do.

Update: I've installed a workaround for this problem, and it seems to work. I'm re-parsing the AJAX XML using the GXml API.

Thursday, April 3, 2008

APRS bulletin group browsing

Tonight I added a small feature to the APRS bulletin board. It can now show bulletins belonging to a specific group, for example MAREA, EI or EVENT.

Directing bulletins to specific interest groups could make the bulletin board scale up a little bit, currently it is filled by just the same old web site and BBS/DX cluster advertisements.

A few days ago I did some programming on the hamdr APRS tracker firmware. It was fun to program C on a 16-bit embedded platform for a change. Tuned it's telemetry transmission a little bit, and added TLL NMEA waypoint sentence support.

Saturday, March 22, 2008

Trackers in airplanes

Only a moment's consideration will reveal the amazing possibilities for our aviation community.
Sam (KJ4CKK) has installed a Byonics MicroTrak-300 in his self-built RV6 kit aircraft (which took him 995.25 hours to build) and prepared a very nice guide for non-ham aviators about getting a license and installing an APRS tracker in a plane. Tracking airplanes is becoming more and more popular.

His plane's tactical callsign (as assigned by the FAA) is N399SB. Currently the last received position seems to have a lat/lng of (nearly but not exactly) 0/0 , probably a bad GPS fix, but just pick another day from the date menu on the right to see some of his flight tracks. They look even better on Google Earth.

Some more planes: N789PH (RV-9A) OH-XKR (Kitfox 4) OH-XST (experimental) N821RP (Long-EZ)

vansairforce.com has a discussion forum dedicated to APRS tracking of airplanes.

Friday, March 21, 2008

On duplicate and delayed packets

I've had a few questions about how my APRS site detects duplicate packets and position packets which arrive in the wrong order. I've responded to the questions over email, but maybe it'd be useful to write something down here for a wider audience.

I will present some background first, most of which is not news to anyone who has followed aprssig or APRS-IS traffic for a while.

Packets sent by APRS stations are usually received by multiple igates. A packet might be heard directly by one igate, and it might be heard much later again after a few digipeater hops. As a result, the APRS-IS network servers will receive multiple copies of each packet. To reduce load on the network, they try to catch the duplicates and discard them. javAPRSSrvr stores packets for 30 seconds and discards any duplicates received during that time.

But some duplicates still get through, because sometimes it takes more than 30 seconds for the packets to get to APRS-IS. Here's a couple scenarios causing this:

1. There are some broken digipeaters out there, which can buffer packets for quite some time before retransmitting them, due to a busy channel or a broken squelch/DCD circuit. A digipeater should not buffer a packet for more than a few seconds before transmitting it. If it can't spit the packet out rather quickly, it should discard the packet.

2. There are some igates which seem to buffer the packets before getting them on the APRS-IS. This is generally not a bug in the igate software or a problem in it's configuration. Instead, the delay can be caused by congestion or packet loss on the Internet link between the igate and the APRS-IS server it is connecting to.

If there is even little packet loss (due to congestion or a bad ADSL line, for example), the TCP connection between the igate and the APRS-IS server will do retransmissions to make sure everything gets through. When packets are retransmitted, the operating system's TCP stack will assume that the link is congested, and to reduce the congestion, it will slow down it's transmission rate (back off). Exponential retransmit timer backoff is used - if multiple transmissions are lost, the retransmit timer will be doubled, up to a fixed limit (which is usually around 60 seconds). As a result, it can take a minutes for an APRS packet to get to the APRS-IS from an igate. (I simplified the retransmission timer stuff on purpose, congestion control is actually more complicated than that nowadays, but the basic issue remans.)

This is how TCP works - it is doing exactly what it was designed to do. Maybe we should be using UDP on the igate uplinks, or SCTP (on platforms which support it). I personally think we can live with losing some packets on the Internet, since we're losing much more packets on the radio path anyway. When TCP is used, maybe there could be a ping-pong method to measure the latency between the server and the igate, and to drop the link if the round-trip time goes anywhere near 20 seconds. This would, of course, eat some more bandwidth.

The visible effect of delayed packets is that a packet transmitted from a moving car 64 seconds ago might arrive at aprs.fi later than a packet that was transmitted 4 seconds ago. If the car was moving at 100 km/h (27.8 m/s, 62 MPH), and that packet would go unnoticed and would be stored to the database as the latest good position, the car would suddenly jump back 1.6 km on it's track. When the next packet would be received, it'd quickly jump forward to it's current position.

Without additional filtering the above scenario is met very often, and it looks very ugly on the map. The hard part filtering the old packets and duplicates without losing too much valid data.

APRS position packets don't usually have timestamps. Some packets do have timestamps, but even then, the timestamps are not very usable - they are sometimes lacking a date, they are often sent in some other timezone than UTC (and there's no way to know which), and even though a GPS unit would provide very accurate time for free, the clocks of many APRS stations are still off (many are transmitting a fixed location without a GPS unit). It's a bit hard to tell whether a timestamp is usable or not, so aprs.fi is not currently using them for anything. It's simply using the time the APRS packet was received from the APRS-IS.

Since the timestamps are not very usable, it is hard to tell the original order they were transmitted in. If the packets would have good timestamps or sequence numbers, sorting them afterwards (in the database) might still have a significant performance impact. So, for now, I'm using them in the order they were received.

Here's what aprs.fi is currently doing:
  1. Packets having a latitude or longitude of 0 are dropped (usually a bad GPS fix).
  2. The distance between the previously accepted position and the new position is calculated. If it's less than one meter, the "last seen" timestamp of the previous position is updated and no new point is inserted in the database.
  3. If the previous packet was received within 5 seconds, the new packet is discarded.
  4. The speed required to move from the position indicated by the previously received packet to the position indicated by the new packet is calculated. Arrival times of the packets are used for the calculation, so this calculation does not accurately reflect the true ground speed of the target. If the calculated speed is over 500 km/h (311 MPH), the new packet is discarded. This gets rid of a lot of jumps caused by bad GPS fixes and out-of-order packets.
  5. The latitude,longitude,course,altitude set of the new packet is compared to the sender's previously accepted packets over the last 30 minutes. If an exact match is found, the new position is dropped as a duplicate. This step catches duplicates, while the previous step gets packets which are delayed or just far off.
These tricks (especially the speed limit) have some drawbacks. If you have a tracker on a jet aircraft or a satellite, you're out of luck. But I don't think any of the APRS satellites announce their position anyway - since they're moving very fast, they'd have to transmit the position very often for it to be useful, and it's probably better to use the channel bandwidth for relaying packets from ground stations and calculate the position of the satellite using tracking software.

If you fly overseas on a commercial jet and restart your tracker soon after a flight, it'll take some time before your new position is accepted. Typical passenger aircraft has a cruising speed of 800-900 km/h, so after a 3-hour flight it can take another 3 hours before you'll be on aprs.fi again.

The above algorithm is a compromise. It looses some good data, but for most of the time it seems to get rid of a lot of old data and clean up the map display a lot. It can be tuned in either direction, but with the current protocols it cannot be made perfect.

There are a couple things you can do to reduce the risk of duplicate and out-of-order packets from your tracker:
  • Do not use a very long digipeater path. A couple hops (WIDE1-1,WIDE2-1 or WIDE2-2, or whatever is recommended in your country) should usually be enough. Using a longer path will increase the possibility of out-of-order packets due to a longer, variable time spent during the digipeating.
  • Don't send packets very often. It's usually enough to send packets once per minute or two when you're moving, and once per 20-40 minutes when you're not. Smart Beaconing and proportional pathing are good things.
If you run an igate, please use the ping command to determine that your Internet uplink does not have any significant packet loss.

If you managed to read this far - thank you for your attention!

AIS from Lake Erie, USA

Thanks to Jeffrey, KC8NNO, we now have AIS ship tracking data from Toledo, Maumee Bay, Lake Erie, USA. Thank you!