Tcpdive – A TCP Performance Profiling Tool
github.com
github.com
And it's a bunch of SystemTap scripts that trace send/receive/etc! Glad it isn't a kernel module, at least. :) So tracing send/receive does cost, which is covered in the README:
"The figure above shows Per-core CPU consumption of tcpdive is less than 10% while QPS is no significant influenced, which we believe is acceptable in most cases."
Actually, I'd say this was acceptable _because_ it is so clear in the README, and we can judge its usage beforehand. The overhead is actually pretty high, 2-10% CPU per core, but then that's what I'd expect for tracing send/receive using SystemTap. Again, by making it clear we can accept or not accept it beforehand and use accordingly.
eBPF should be making this type of tracing lower overhead...
I didn't create DTrace, but I did create the DTrace TCP provider and many networking scripts. A nice list of them is here: http://dtracebook.com/index.php/Network_Lower_Level_Protocol... . My scripts focused on tracing events, workload characterization at different levels, and some timing: connection lifespans, and 1st byte latency. (At least in that location; I've got DTrace scripts scattered elsewhere too). The tcpdive scripts have focused so far on perturbation study: congestion, retransmissions, resets. Also useful!
If you really want to assess how your application will perform on low-quality connections, it behooves you to understand what makes those connections suck, and what specific capabilities your OS of choice has for simulating or generating those conditions.
Statically setting latency to 500ms or packet loss to 10% is not realistic; it simultaneously exaggerates the kind of performance issues that exist in the real world and is much easier to compensate for than real network dynamics.
Similar results could theoretically be obtained with the TCP Dtrace provider, which was added in Solaris 11 if memory serves. I am not aware whether FreeBSD or MacOSX have any similar providers, but my info could be outdated.
The idea behind all these approaches is basically to target a specific TCP connection and generate an event each time a TCP packet arrives. For each of those events, a rolling estimation of the RTT is generated by the kernel and is used as a basis for calculations for the congestion window, which limits how many bytes can be subsequently sent. Various timeouts can probably trigger similar events and so on.
(edit: s/packets/bytes/)
Why not just use tethering?
http://www.webpagetest.org/ does this for waterfalls, you can select real-world 2G/3G and even LTE