2

Here is my use-case :

I'me developping Static Site Generator and stuff for them.

I would like to host on static pages (like gitlab-pages or github-pages) some demo of my stuff.

So I can't use server-side tricks to simulate slow connexion.

My demo page should look like this :

I've not found any service-worker built for this.

Any Idea where i can found one or how i can build one for this ?

1000i100
  • 400
  • 1
  • 3
  • 13

1 Answers1

1

The tc or Traffic Control command should be able to handle the job for you. tc can do a lot but it sounds like you just need to to 'shape` traffic:

SHAPING When traffic is shaped, its rate of transmission is under control. Shaping may be more than lowering the available bandwidth - it is also used to smooth out bursts in traffic for better network behaviour. Shaping occurs on egress.

Simulating something like cell delay is pretty easy, in the below example I inject a delay of 100 +/- 10ms on interface eth1.

tc qdisc add dev eth1 root netem delay 100ms 10ms

Naturally this is annoying because it is on a primary interface and it does not handle throughput limiting. To do that you need to go into how tc works more (parent/child queues, etc). This writeup explains how to throttle the bandwidth, so if you do that and then add the delay mentioned above, then you should have a pretty solid emulation.

Liam Kelly
  • 3,524
  • 1
  • 17
  • 41
  • if my use case was a debbuging/test case as developper, yes, it would do the job like many other tools (include in modern browser or proxy i found many things here in stackoverflow). But my use-case is to let end user test the perfomance of my tools just by clicking on différent links, when hosting all of that on static host like github-pages or gitlab-pages. I really think it could be done with service-worker, but i don't know how. – 1000i100 Dec 30 '20 at 17:46
  • A service worker probably does not have access to socket options so any emulation would be at OSI layer 4+. Even if you did not send packets to emulate delay or throttling, the OS TCP-stack would be sending control packets keeping the link up/happy. Generally Proxies are going to be at Layer 4 and can try to emulate more. `tc` is operating at the OS level and can get you the layer 2-3 control that really makes cell links unique. So as I mentioned before, even if you *think* you are emulating with a service-worker, under the hood it will not look like a cell link. – Liam Kelly Dec 30 '20 at 20:09