whoami

Lucas Jenß

cat /etc/motd

The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.

Close-up of white dominoes with black dots standing on green felt surface, shallow depth of field, focused mood

ls -la ~/languages/

total 8
drwxr-xr-x
▶ PHP
▶ Ruby
▶ Scala
▶ C#
▶ JavaScript
▶ Objective-C
▶ Shell Scripting

ls -la ~/toolchain/

total 7
drwxr-xr-x
▶ Typo3
▶ Akka
▶ Capistrano
▶ Git
▶ MAMP
▶ Adobe Illustrator
▶ NSTrackingArea (Cocoa)

uname -a

platforms
drwxr-xr-x
▶ Mac OS X
▶ Unix

Simulating network latency in the Android Emulator

Testing an Android app on a fast workstation can hide the problems users meet on a crowded mobile network. A request that returns in 20 milliseconds locally may take several seconds during peak-hour conditions, causing loading states to overlap, retries to fire and timeout messages to appear at the wrong time. Controlled latency makes those transitions visible before release.

The Android Emulator includes console controls for emulated radio conditions. They can add a fixed delay and limit throughput without routing all test traffic through an external service. The important qualification is that a radio profile is a test condition rather than a perfect mobile network: it may not reproduce jitter, packet loss, carrier DNS or the behaviour of a real handset.

A reliable test starts with a measured baseline, changes one network property, and confirms the change at the application boundary. The quickest route is the emulator console, while a physical handset remains useful for final validation on Australian mobile networks.

Separate latency from other network conditions

Latency is the delay experienced before data can move through the network. Throughput determines how quickly larger payloads transfer, while jitter introduces variation between otherwise identical requests. Packet loss forces TCP to retransmit data or can make an application fail outright. A command that adds 120 milliseconds of latency is therefore quite different from one that restricts bandwidth, even if both make a request appear slower.

Australian conditions make a single delay value misleading. Sydney and Melbourne users may have fast metropolitan 4G or 5G, while fixed NBN connections and regional routes around Perth, Adelaide and Brisbane can behave very differently. For wider infrastructure tests, complementary ideas in NSX-T load configuration can shape routed traffic beyond one emulator, although device-side checks should remain part of the workflow.

Apply delay through the emulator console

Start the intended Android Virtual Device, confirm its serial with adb devices, and record a baseline response time. An emulator normally identified as emulator-5554 uses console port 5554, while later instances commonly use 5556. The console can then be controlled through ADB:

adb devices
adb -s emulator-5554 emu network status
adb -s emulator-5554 emu network delay lte 120
adb -s emulator-5554 emu network speed lte 12000

The delay value is expressed in milliseconds, while network speed normally uses kilobits per second. Supported profile names vary between Android Emulator releases, so use help network to check whether lte, umts, gsm or another profile is available and substitute an accepted name when necessary.

If ADB cannot reach the console, connect directly with Telnet and authenticate using the token generated by the emulator:

telnet localhost 5554
auth YOUR_TOKEN
help network
network delay lte 120
network status

The token is normally stored in $HOME/.emulator_console_auth_token on macOS and Linux or %USERPROFILE%\.emulator_console_auth_token on Windows. Keep it out of shared scripts and logs. Restarting the emulator is the safest way to restore unrestricted baseline conditions.

Verify the delay from inside the app

Do not assume that a successful console command changes every request. Traffic to 127.0.0.1 stays within the device, while the emulator alias 10.0.2.2 points towards the development machine. These paths may bypass or respond differently to the emulated radio condition. Use a controlled endpoint reachable through the tested route, and confirm that DNS, redirects, proxy settings and any QUIC connection are following the path you expect.

Measure at both ends of the request. Record the client’s start and completion times, the server’s receipt time, status code and retry count. On Android, a monotonic value such as SystemClock.elapsedRealtime() is safer than wall-clock time for calculating duration. Separately time DNS and TLS setup so a slow lookup is not mistaken for server latency. For repeatable scripts and endpoint checks, I keep a compact developer toolkit available, then compare several identical requests instead of trusting one sample.

Compare the available testing methods

The emulator console is the quickest option for routine application testing. It is deterministic and targets the virtual device directly. More elaborate controls are useful when the scenario specifically requires jitter, packet loss or detailed proxy behaviour.

Method Controls Repeatability Best fit Main limitation
Emulator console Fixed delay and throughput High API, UI and timeout testing Limited jitter and loss modelling
Host tc netem Delay, jitter, loss and duplication High Advanced packet-level scenarios Requires root and correct routing
Local proxy or VPN Application request delay Medium HTTP flows and certificate testing Extra setup; some traffic may bypass it
Physical Android device Full carrier and radio stack Low to medium Final Australian network validation Less repeatable and slower to reset

For routine mobile-app work, the console route offers the best balance of speed and control. If jitter or loss is essential, tc netem can be applied to the host interface that genuinely carries the emulator traffic, but it may affect other workloads and can require careful isolation. A local proxy is useful for application-level delays, although certificate installation and non-proxied protocols add complexity.

Run a repeatable Australian test profile

Create named scenarios rather than changing several values without recording them. A reasonable starting set is a metropolitan mobile profile at 50 milliseconds, a regional or congested profile at 120 milliseconds, and a severe timeout scenario at 250 milliseconds. Add conservative throughput limits for file transfers and uploads. Treat these as test inputs, not universal claims about Australian networks, because radio coverage, handset mode and carrier load can change the result considerably.

Keep time handling in the same test plan. Brisbane remains on UTC+10 throughout the year, Sydney and Melbourne shift between UTC+10 and UTC+11, and Adelaide uses a half-hour offset. Explicit UTC timestamps and ISO 8601 offsets prevent daylight-saving changes from being mistaken for network delay. For Australian releases, repeat critical flows on hardware and carriers common in the local market, including Telstra, Optus and Vodafone connections.

  • Record a baseline before applying any network condition, then reset the emulator between clearly separated scenarios.
  • Change latency, throughput, jitter and loss independently so the cause of each behavioural change remains identifiable.
  • Test at least 50, 120 and 250 milliseconds, using 120 milliseconds as the central profile for timeout and retry handling.
  • Use a controlled external endpoint rather than only localhost, and verify which DNS and proxy routes the application takes.
  • Capture client timings, server timestamps, retry counts and screenshots for every run.
  • Repeat the most important scenario on a physical handset to check radio behaviour, DNS and real carrier routing.

Run the baseline request now, repeat it with a 120-millisecond profile, and publish the measured timings and visible interface changes in your team’s test log.


cat ~/interests.json

KeyValue
editorTerminal-first workflow
osMac OS X / Unix
vcsGit, distributed version control
deployCapistrano, cron automation
graphicsSVG, Adobe Illustrator troubleshooting
networkingIP validation, SSH, VPN

git log --oneline --reverse

2013-10-30

Solving SVG import issues in Adobe Illustrator CS6 and CC

When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.

2013

Solving NDK build issues on OS X

Troubleshooting native development kit compilation problems on Mac OS X.

2013

Programmatically adding PHP generated TypoScript to the backend configuration

Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.

2013

ArgumentError: Could not parse PKey: no start line

Debugging an SSH key parsing error encountered during deployment.

2011-08-04

Validating IP-Addresses in PHP

Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.

2011-07-09

Cocoa: Using NSTrackingArea

A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.


cat ~/contact.txt

github: github.com/x3ro
stackoverflow: x3ro
coderwall: coderwall.com/x3ro
twitter: @x3rames