Showing posts with label computers. Show all posts
Showing posts with label computers. Show all posts

Tuesday, January 3, 2012

Help, uploading makes my internet slow!

Consumer broadband connections aren't designed right. They sound good on paper, of course "The majority of users download far more than they upload, so giving them higher download speeds and only a tiny amount of upload speed makes sense". In truth, it usually sort of kind of works... so long as all you ever do is download.

I don't only ever download, though. I create content now and then, and some of it is quite large. Large enough to take well over 10 hours to upload through the wee tiny upload pipe my provider gives me.

On the face of it this isn't really a problem. The material I'm uploading isn't remarkably time sensitive, and I don't produce it at a rate that exceeds my connection's ability to upload it. The problem is what happens to the download side of the pipe while this upload is going on.

Communication is a two-way street, you see. We need to be able to send out a request before we can get any data back, and we need to send out an acknowledgement before we get the next chunk and so on. Unfortunately our ability to send out these requests and acknowledgements is essentially cut off when the upload pipe is saturated, and we end up with packets backing up to the point where having any sort of interactive online experience is impossible, as is achieving anything close to a reasonable download rate for the few requests that do manage to make it through.

The solution to this, of course, is actually remarkably simple: We just have to keep the pipe from backing up by limiting the rate that we send data out. Of course, to avoid just moving the logjam further upstream, we also want to make sure that we throw out stale packets so they don't take up as much space, and thus time, in the queue.

Now I use a linux box for my main internet gateway, sitting between my connection to the world at large, and the legion devices on the warm, cozy side of the LAN. This means that setting up this rate limiting is a simple and straightforward task.

Or it would be, if the documentation weren't utter shit.

I actually spent quite a few hours paging through man pages and google looking for the magic incantation that would allow me to set up a sane rate limit queue on my linux box before coming up with the solution. To save you the trouble, here it is:

tc qdisc add dev shaw root tbf rate 60kbps burst 1540 latency 100ms

The command we're executing is "tc". The "qdisc" part means were issuing a queueing discipline command. The "add" means we're adding a new queueing discipline. All fine and dandy so far.

Now we specify the device we want to operate on. I've used "ifrename" to name my external interface "shaw", because that's who my provider is. Yours will probably be something uncreative like "eth0", but that aside the "dev shaw" part specifies the correct ethernet interface on my particular system.

The "root" part is the simple part of a complex puzzle. You can actually create a whole tree full of queues that feed into each other, each with different limits, algorithms, and a whole lot of other overcomplicated and unnecessary junk. We just want one queue, so we want it to be the root.

The "tbf" part is where we've specified the type of queue, in our case it's a "token bucket filter". Without going into too much detail, data is only sent downstream when there's enough "tokens" in the "bucket" to "pay" for them, and the tokens are replenished in wall-time thus achieving the rate limiting.

We specify this rate limit explicitly with the next part, "rate 60kbps". My upload bandwidth is actually 0.5mbit which translates to roughly 64kbps, but we want to make sure that we don't run too close to that limit or the logjam might form again at the cable modem.

The next part, "burst 1540" is where things start going off into the weeds. The documentation regarding this part of the command goes on about some technical details of how this needs to be set very large for things to work properly on fast connections because of kernel tick resolution limits. Of course, this is at least 5 years out of date since the kernel went tickless back in 2007 or so. In either case, this specifies the maximum size of the bucket (after which no more tokens can be added to it) and we want it to be at least big enough to pay for a full ethernet frame.

Finally, perhaps the most important part for keeping the logjam from forming, is the "latency 100ms" part. This defines how long a packet can linger in the queue before it's thrown out to make way for newer packets. Now one might think that throwing packets out would tend to make a complete mess of things, but in fact this is exactly what we want to do as reliable stream protocols like TCP will throttle back in the face of packet loss, reducing the logjam, and isochronous protocols will of course benefit more from having packets dropped rather than delivered late.

By deploying this rate limiting queue on my linux box I was able to ensure interactive internet performance while at the same time sacrificing little to no upload speed performance. This makes me happy, and I hope if you come into a similar situation that it'll make you happy too.

Friday, December 16, 2011

That not so fresh feeling

So last night I decided that I had enough of Safari crashing randomly, and dying completely when I tried to upgrade it. I knew that somewhere along the line something had gone wrong with my system, and it was time to admit that the prudent thing to do was to wipe the system and install a fresh copy of Lion.

Now I had basically been running the same OS install since 2007, which was originally a (short lived) install of Tiger, followed by Leopard once it was released that fall, then Snow Leopard and finally Lion this year. People will say "oh, well, you really should do a fresh install when a new OS comes out, so that..." and then their train of thought goes off into some cargo-cult chicken-bone-rune casting mumbo jumbo, or at least the technological equivalent thereof.

The thing is, so long as the filesystem itself isn't corrupted, there should be no difference between a freshly installed system and one that had been upgraded from a previous install, no matter how long ago that install was performed. Any deviation therein is nothing less than a failure on the part of the developers, in this case Apple's OS division. And so, to Apple's MacOS release packaging team, I have one thing to say: Son, I am disappoint.

But my disappointment runs deeper than that. You see, on windows there exists a little known utility called "SFC", which stands for "System File Checker". As the name implies, it runs a checksum over all (or most) of the important system files and can replace any that deviate from expectations. As far as I can tell, though, there's no equivalent to this on MacOS X.

The sad thing is it would be dead simple to integrate into Disk Utility. There's already a framework in place, the ever so lovely "repair permissions" routine that seems to be the first line of action in every OS X tech support script. It would, in theory, be quite simple to extend this to record and verify checksums on all the vital files, and then, at the very least, indicate which files are damaged if not replace them automatically.


In the mean time, though, I'm at least glad that nuking the drive from orbit, reinstalling, and migrating the data, apps and settings back from my time machine drive is at least a reasonably seamless process.

Saturday, June 25, 2011

Please DIAF, Flash Plugin

So last night as I was settling down getting ready for bed, I decided to watch a few youtube videos to close out the day, as I often do. Additionally, as is common for these late night viewings, I hit the "full screen" button on youtube's controls.

Now, for most people, clicking a button marked "full screen" would imply some sort of desire to watch a video in full screen perhaps. Not according to Adobe, though. For them, hitting "full screen" means "crash the computer and force an instant reboot". Thanks, Adobe.

As a result of this, my root drive became unrecoverably corrupted (I'll put some of the blame on Apple's FS team for that part, journaled filesystems should never die like that). Thankfully my Time Machine backups came to the rescue and I didn't lose any data, but all the same it was a pain in the ass and kept me up well past my intended bed time.

On the bright side, when I logged in to post this I noticed that Blogger has added mobile device templates, which I took the opportunity to enable. As such, my blog should now be much easier to navigate from handheld devices. Now if only they could do something about improving the mobile posting experience...

Tuesday, May 31, 2011

Mystery Solved

As I completely forgot to mention in a previous blog post, I retasked Bob's old desktop PC into my server, as my old server was getting a bit flaky due to a damaged DIMM slot.

The new hardware worked quite well, except that, very rarely, I'd come to find that the system had mysteriously rebooted. There was never any crash log or any instability leading up to the reboot, it'd just suddenly, every few weeks, reboot itself.

Then, this afternoon during a particularly strong gust of wind, the power flickered and my server rebooted again, and finally the lightbulb went on. I trudged my way downstairs to inspect the matter first-hand, and was at first a bit stymied as the UPS, which had been my first guess as to the culprit, was not showing any signs of distress from either overload nor from worn batteries.

None the less, when I pulled the plug and the UPS cut over to battery power, my server instantly powered down and started spasming as it attempted to power back up again. During this time, the overload warning on the UPS remained silent, indicating that it was still well within its design load.

With this new information, I was able to narrow it down to the power supply inside the server itself. When I upgraded the system, I had only moved the old drives over along with one of the ethernet cards; I hadn't bothered to swap out the power supply as it seemed to be a perfectly serviceable 500w unit, and the one in the old server was only 550w, though it was a high quality aftermarket unit.

Since I still had the power supply from the old server, I swapped it in. I powered up the system (worked first time!) and pulled the plug on the UPS and... nothing! It just kept chugging right along as if nothing had happened.

I am looking forward to not having any more random reboot troubles from my server.

Tuesday, March 15, 2011

So, what is it you *do* here?

Sometimes people ask me what it is I do. This is the answer, roughly speaking. (scroll down, for some reason the second video is at the top, but they're in the correct order below that)

Monday, January 3, 2011

The bloody aftermath

So, I moved my server this evening. Finally got all the essential services off the homebox and out into the cloud. Mad props to Linode for not sucking!

Only thing that isn't working quite right is my Jabber server, but I'm hoping that it'll sort itself out once the DNS refresh percolates out through the tubes. I may have to poke at it a bit tomorrow, but it's not a big deal. There will probably be a few glitches with delayed emails until then too, but that's just part of the game.

It took a bit longer than I expected to do the switchover as I waited until now to copy over the spamassassin databases without realizing they're about 100-120MB each. Takes a few minutes to squeeze that through a 512kbit uplink.

Tuesday, December 14, 2010

A minor scare

So yesterday, when I was out in the Polo Park area after writing my exam, I had left my backpack with my laptop in the car (I know, I know). It was still there when I returned a few hours later, but unfortunately the cold temperature had taken its toll.

When I woke up my laptop when I got home, to my horror I saw a series of teal streaks on the display. Needless to say, I was not pleased.

The streaks were on the order of a pixel or two wide, and up to an inch long. They seemed to react to pressure, so I surmised that whatever was happening wasn't just outright pixel death. I played a bit of minecraft to see if exercising the pixels with a changing picture would help things along, and after a little while of playing it seemed that the streaks were starting to get better.

Then the inspiration hit me: condensation inside the panel! The cold temperatures and high relative humidity inside my car had clearly caused some water or frost to infiltrate the panel and condense, messing with the function of the display.

To test this theory, I got out my hair dryer and, starting on low, heated up some problem areas. To my delight, they reacted by shrinking and lightening. After 10-15 minutes of heating, the areas I was concentrating on had vanished into perfect, flawless pixels, and I continued my way around the monitor cooking off the streaks. In the bottom corner, the last and worst trouble spot, I had to switch the hair dryer onto high, but those pixels too were soon brought back to life.

All in all, I'm annoyed but happy, and find myself with yet another reason to hate winter.

Friday, November 12, 2010

The magic of bluetooth

I've been wanting to get a game controller for a while, so that I could more easily play emulator games on my computers, but one way or another I never really got around to it. The trouble is that the market for PC game controllers isn't very big, and is as such not very well served.

This afternoon, though, I was out shopping and decided that enough was enough: it was time to get myself a controller. Rather than get a PC game controller, though, I instead opted for a PS3 DualShock 3 controller, with the assumption that I'd be able to make it work with my computers, since it's just a bluetooth device after all.

I figured I might need to do some tinkering or scrounging for some hacked drivers or something, but much to my delight it turns out that OS X has built-in support for the DualShock 3 controller, so all I had to do was plug it in to sync/charge it, and it immediately connected via bluetooth and provided full HID capability.

This pleases me.

I haven't managed to get it connected to my Wintendo, though, as my PC currently lacks bluetooth. I've added a bluetooth dongle to my xmas list, though, so hopefully that problem won't persist forever.

Sunday, November 15, 2009

My poor internets!

So it would seem that, out of nowhere, my network switch just up and died. Plug in more than 3 devices and it just pukes all over the place.

This isn't a huge deal since I was planning to replace it with a gig-e switch sooner or later, but I would have rather done it on my own schedule.

Guess I'll be taking a trip down to Memory Express tomorrow.

Tuesday, March 3, 2009

Next on the shopping list

So it looks like apple came out with a new Mac Mini today. It's even better than I expected: not only does it support the 2560x1600 resolution required to run a 30" display, it can do so while also driving a second display at 1920x1200! Sweet!

It's so going on my christmas list. So many things to buy...

Friday, January 16, 2009

iTunes, virtually speaking

So the one thing keeping me using Windows on my laptop when I'm off in the wonderous world of California was having to use iTunes to keep the music on my iPod fresh. But now, no longer, as I have been able to successfully sync my iPod with iTunes running under VirtualBox!

It turns out that it was actually working fine all along, but due to a bug in VirtualBox the VM would grind to nearly a halt, so it would look like it was frozen up. Running VirtualBox on my much faster desktop system resulted in perfect execution.

I guess I'll just have to upgrade my lappy to a shiny new Lenovo X200.

Sunday, October 19, 2008

The day the batteries died

Well, it had to happen eventually, the batteries in my keyboard finally got low enough to trigger the "low battery" warning on my computer. For the record, I charged this set on March 11th 2008, and the keyboard has been running continuously from that day until today, October 19 2008.

And in 30 minutes, I'll be starting the cycle all over again.

Speaking of batteries, on Friday I had to replace the batteries in my UPS again. Every 3 years like clockwork. It reminds me that I need to buy another few UPSes to cover the rest of my gear, like my server. When I have more money...

Monday, September 29, 2008

Horrible, terrible freedom

I did a bit of poking around this evening, and I finally managed to get my prism54 card working with WPA in Linux. Hooray! No longer will I have to suffer with the blight of windows just to securely connect to the internets while on the go, and I didn't even have to use the ndiswrapper windows drivers.

I think I'm going to try dragging my lovely black boatanchor to school on Tuesdays and Thursdays so I can surf the web without having to deal with the filthy lab computers. We'll see how long it takes before I get sick of the extra weight.

Saturday, September 27, 2008

Just what the doctor ordered

This morning I went out to the Memory Express grand-opening in Winnipeg and picked up a new power supply for my old desktop slash new server. Got a Crucial 550 watt one, and after wrestling it into place I'm happy to say that my system is now alive and well.

Installing Debian onto the 4-drive RAID was fairly straightforward, though the process could be streamlined a bit.

The server is actually impressively quiet, even with all four drives thrashing away. I'd almost be tempted to keep it up here, but I don't need the extra heat.

Friday, September 26, 2008

Oh fiddlesticks

Today I finally got my SATA card, which is the last piece I need to be able to assemble my old desktop into my new server.

At least, I thought it was.

Unfortunately, it turns out that with all the goodies and gubbins I've crammed into my poor little Antec case a 350 watt power supply just isn't quite enough to spin things up. In fact, it apparently isn't even enough to spin 1/4 of things up. (despite the fact that an online PSU calculator claims that a 250w supply should be ample)

So, now I face the lovely task of either spending $100-$150 on a new case, or $50-$100 on a new power supply. I sure wouldn't mind one of these.

I knew that I was going to have to get a new case/psu eventually, but I was hoping to put that off until I upgraded the rest of my server.

Friday, August 22, 2008

Have you no sense of awe?

In here, you *whisper*.

Well, actually you yell, since you can't hear anything over the roar of cooling fans sucking heat away from the over 14 thousand CPUs in one system alone.

Yesterday I had the opportunity to be shown around the Ames supercomputing/visualization center. I got to see the Columbia supercomputer, a few other systems, a few petabytes of tape robot, and the really awesome hyperwall.

I also got a chance to take a few pictures of the afore mentioned items, though they really don't capture the full experience. The only thing I couldn't take pictures of were the army's Cray systems (I think an X1 and an XT5) even though they were completely standard off-the-shelf crays. I'll be putting the pictures up on my site as soon as I get things back up and running properly.

Saturday, August 9, 2008

The miracles of technology

So this evening I was playing around with my Centro, mostly checking what part of the world is in shadow in the nifty world clock app, when suddenly my computer made this bizarre noise and an icon popped up in the task bar saying "A computer is near by, would you like to transfer files?".

This came as a bit of a shock to me, to say the least. I wondered if I had fallen victim to some form of malware or trojan, so I quickly googled the error code and discovered that it was windows itself popping up the message, in response to a successful connection via IRDA.

It then occured to me that both my laptop and my phone have IR ports on them, a fact that I had up until this point completely and utterly ignored (and/or forgotten).

After a little bit of fiddling around, I managed to get the palm hotsync to sync my Centro over the IRDA connection. I've never done that before.

It's funny to think about IR port: a barely noticed flash in the pan of technology that had come and gone almost ten years ago, nowadays completely and utterly replaced by bluetooth and other RF technologies. Now, all these years later, almost entirely forgotten and on the eve of its final demise, the dusty corpse reanimates like a silicon zombie to wirelessly fling my bits of contact information back and forth over an invisible link.

I wonder: if technologies were really alive, what they would think of their passing... For me, it just makes me feel old.

Wednesday, July 23, 2008

Wikiality

I decided to give the MoinMoin wiki software a whirl on my server for managing the static content on my web site. It's closed off so only I can edit it, so it's not exactly collaborative or anything, but I can't imagine I'd want anyone else editing the content anyway.

I've stuck it on my server at wiki.ubb.ca. So far it's just got the welcome page and a highly abridged version of my xmas list.

I'll still be using Gallery2 for my photos and I'll probably get phpicalendar up in a more official capacity for my calendar, etc, but I figured this would be a nifty way to deal with all the detritus that used to just be stuck in static html files that I loathed editing.

Friday, July 4, 2008

SSL can be so... cryptic

Setting things back up on my server today, and having a puzzling time of it when it comes to my SSL certificates.

I started out by getting my jabber server back up and running and puzzling over why it wouldn't talk to the Google Talk servers. Scrounging around the net a little, I discovered that I needed to have SSL set up on my server to satisfy the peculiar tastes of The Goog.

Except that didn't work, and it took quite a bit more puzzling to determine that it didn't like my self-signed certificate, but substituting it with a certificate that I signed with a self-generated CA key would work. Go fig.

Then, while I was on an SSL kick, I decided to enable https on Apache, so I dutifully cooked up a key and crt, signed it with the CA key I just generated and... Firefox refused to trust it. Not only did it refuse to trust it, but it went so far as to even refuse to let me set an exception, and the errors it gave were utterly vague and generic.

It took me a few more hours of generating keys, searching the net, and screaming at the utterly useless documentation to figure out that I needed to use a self-signed cert instead of one signed by my fake CA.

What a pain in the ass.

Wednesday, July 2, 2008

Down, down, down in a burning ring of fire

My server went down with a hardware failure yesterday afternoon, probably from overheating. I won't be anywhere near it to fix it until the end of August.

If you need to email me, I have a mac.com email address that I can send to you. Just reply to this post if you need it.