Physics and Programming. Welcome to my blog :)

Physics! :)

Subscribe (RSS)

Traffic Cop: Network (2G/3G) Emulation on an OpenWRT Router

Written by Shuhao on 2015-09-02 00:30

A common issue in application development nowadays is that people do not always test their application against devices and networks that have very low performance. This is somewhat understandable, especially when not everyone has the resources to setup a big testing rig testing high end, mid tier, and low end devices on a variety of different networks. This is not to mention that even when there are the means to test, people probably skip it as it is a giant hassle to do so.

During Shopify's Hack Days, the lovely @amecila and I worked on a project to simplify testing against slow performing networks. The basic idea is to be able to control the bandwidth, latency, and packet loss for individual devices connected to a special WiFi network. This system was named "Traffic Cop".

Traffic Cop is an application running on a router with OpenWRT that allows you to emulate different networks such as 3G, EDGE (2G) for individual devices connected to this router.

All a client has to do is connect to this network, go to the router's IP address (at port 8080 by default), and select a network profile to simulate. You can then watch the client's ping latency, bandwidth, and packet loss rate match the ones indicated for that profile.

The whole project is open source here:

Spoiler! The finished product looks like the following:

Note: the UI text has been slightly updated in the current version, with "None" changed to "No profile" and the caption set to "Best available connection".

>> Continue Reading

Why are we on social networks anyway?

Written by Shuhao on 2014-09-14 00:00

We all have old fasion blogs. RSS is a perfectly fine thing to follow people. Why do we need social networks anyway? It seems rather redundant.

>> Continue Reading

Setting up Intellij with CyanogenMod/AOSP development

Written by Shuhao on 2014-04-27 23:05

Recently, I discovered a way to import the CyanogenMod source into Intellij. Since the documentation in this area is severely lacking, I thought I might share my experience. There are several things that I have yet to figure out, but the basic setup can be done in Intellij fairly simply (write code, browse code with CTRL+Click).

First, let's assume that you have successfully cloned the CyanogenMod/AOSP repository and built a version of android. The AOSP documentation for IDE development only documents Eclipse and it is fairly out of date. Google included a largely unupdated tool something called idegen under development/tools. However, it does generate correct mostly correct IntelliJ configurations.

>> Continue Reading

Software is Easy, Hardware is on Medium Difficulty

Written by Shuhao on 2013-11-11 11:11

The article Why Hardware Development Is Hard, Part 2: The Physical World Is Unforgiving just showed up on Hacker News. I encourage you to read it, as it is a fairly interesting read.

The article gave us some convincing arguments about why hardware is difficult, the main one being that hardware development takes time and money. When "change consume[s] real [and] physical resources", there is no room for errors and errors are expensive and sometimes even dangerous.

As an aerospace engineering student, I can definitely appreciate this point. It reminds me of those cases in software when we say that the production environment "blew up" because some configuration changed. I suspect that that phrase is not muttered by most aerospace engineers unless that is literally the case, which is definitely within the realm of possibilites.

>> Continue Reading

New website!

Written by Shuhao on 2013-11-10 21:30

After about 4 hours of fiddling around with my website, I finally ported this site to Foundation 4. It was long overdue as the looks of the old site was pretty boring, not to mention being a disaster on mobile.

Here is a list of all the major changes from this changeset:

  • The home page has been simplified. All sections are now 3 sentences or less.
  • The showcase page has been completely revamped to include screenshots and a friendlier look.
  • The blog is now one column.
  • The entire site is now based on Foundation 4.
  • The mobile site does not make me want to gouge my eyes out.

Some other things that still need to be worked on:

  • Include a comment section for the blog.
  • Include a print friendly version of my CV.

Is there an issue? Send me a patch here.

>> Continue Reading

Happy Monday: Meta blogging

Written by Shuhao on 2013-11-04 14:45

Happy Monday folks! It is two days away from two major exams for me, so I better keep my tradition of writing posts at slightly inconvenient times.

It occurred to my that over the years, I have written plenty of code. I would also say that I have gotten a lot better as a programmer from all the practice that I had.

Over the same time, the amount of words that I write went down. As an engineering student, there are very few assignments that make us write things without tainting it with pages and pages of tables, equations, and diagrams. This lack of practise has put me out of touch with communicating with writing as I often struggle to write about things and events that I find interesting. On top of that, English is my second language and writing in it is not my strong suit to begin with, so I feel like this is a problem that I have to address.

Incidentally, it is also NaNoWriMo, where people try to write an entire novel in a month. In honour of that, I thought I would try to take some time out of my schedule to write. Not a novel (I know :[), but blogposts on things that I find interesting.

You should subscribe! This way you can keep up on all of the awful things I'll come up with ;)

>> Continue Reading

Goodbye, Mozilla

Written by Shuhao on 2013-09-01 12:11

You know, I wish I had better writing skills. It is something that I never really picked up during my years here. As I sit here in this chair moving at almost 1000 km/hr 10 km above sea level, not knowing how to put my thoughts about the last few months into words, writing skills certainly would have been really handy. However, none of this shall prevent me from at least trying.

>> Continue Reading

Exploring Firefox crash data, Part 2

Written by Shuhao on 2013-08-29 14:01

A couple of weeks ago, I spent some time exploring Firefox crash data so that I can come up with a model to catch "explosive crashes" in a timely fashion. Over the last couple of weeks, I have evaluated and identified a model that is "good enough". Currently, the code is sitting in a pull request, waiting to be landed in Socorro.

This post will mainly focus on many of the models I have tried and did not include in my final implementation.

>> Continue Reading

Fun with Kerbal Space Program: To the Mun!

Written by Shuhao on 2013-07-27 21:57

T minus ten, nine, eight, seven, six, five, four, three, two, one, launch! With that, 5 rocket engines ignited and lifted off the launchpad along with a brave, but definitely stupid Kerbalnaut, for the Mun.


Last weekend, I picked up Kerbal Space Program from the Steam summer sale and I have been messing around with it since. Kerbal Space Program is a pretty realistic space flight simulator game where players get to develop their own space program. In the game, you can design and build rockets, spaceplanes, spacecrafts, space stations, and so forth. The game features a solar system somewhat resembling of our own, except with 1/10th the size but approximately the same amount of surface gravity.

The game is fairly difficult to get into. It took me a good solid two hours to just understand how everything worked. It is unfortunate as I have not yet taken my courses in aerospace for me to know what terms such as prograde and retrograde mean. However, after the built in tutorial and some YouTube videos, I was able to build some simple rockets that allowed me to venture out to space.

>> Continue Reading

Exploring Firefox crash data, Part I

Written by Shuhao on 2013-07-25 23:04

Recently I've taken on a new challenge at Mozilla: analyze Firefox crash stats to find "explosive" crashes. That is, finding events that have a high upward trend and should be a cause for concern for those in the engineering department.

So what are "explosive crashes"? Before we can get to that, we need to take a look at what each crash report consists of. When Firefox crashes, it sends back a core dump with some information to Socorro. Socorro takes the core dump and generates a signature. An example signature could be gfxContext::PushClipsToDT(mozilla::gfx::DrawTarget*) or CContext::RestorePipelineStateImpl<int>(SAPIPipelineState*) and they group similar/identical crashes together. Explosive crashes are signatures that experience a sudden increased in crash volume. We need to catch these signatures as they are usually related to an emerging bug. Since we get so many crashes per day (around 3000 crashes per minute), it is simply infeasible for human beings to go in and identify these explosive events. This is why we need an algorithm to detect these automatically.

>> Continue Reading

Page 1 of 2 | Older Entries