{"thread":{"id":"55942","subject":"Simulating network throttling","startedAt":"2021-06-16T04:56:29Z","lastAt":"2021-06-17T07:19:25Z","messageCount":4,"participants":["Bagas Sanjaya","Bryan Turner","brian m. carlson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"427577","messageId":"65b4040c-2a9c-7d49-43ce-dad7d5a9c62d@gmail.com","threadId":"55942","inReplyTo":null,"subject":"Simulating network throttling","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-06-16T04:55:49Z","receivedAt":"2021-06-16T04:56:29Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Hi,\n\nI would like to test my Git repository in case the network is throttled \n(that is the network speed is reduced from its full speed). For example, \nI would like to test git clone under maximum download speed of 9.6 KB/s \n(GPRS speed).\n\nI know how to test for throttling in browser, but since Git is \ncommand-line application, is there any way to simulate network throttling?\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"427578","messageId":"CAGyf7-HyUHJacvpwx6R+_hCVsK_t3F1mQ++2_4-NeJWB9uUjdA@mail.gmail.com","threadId":"55942","inReplyTo":"65b4040c-2a9c-7d49-43ce-dad7d5a9c62d@gmail.com","subject":"Re: Simulating network throttling","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2021-06-16T04:59:00Z","receivedAt":"2021-06-16T04:59:14Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On Tue, Jun 15, 2021 at 9:56 PM Bagas Sanjaya <bagasdotme@gmail.com> wrote:\n>\n> Hi,\n>\n> I would like to test my Git repository in case the network is throttled\n> (that is the network speed is reduced from its full speed). For example,\n> I would like to test git clone under maximum download speed of 9.6 KB/s\n> (GPRS speed).\n>\n> I know how to test for throttling in browser, but since Git is\n> command-line application, is there any way to simulate network throttling?\n\nI've had some luck using toxiproxy[1] to MITM the connection, at least\nover plain HTTP. It's worth noting a warning brian m. carlson has\ngiven others in the past about this sort of thing, though, which is\nthat many MITM solutions are not fully transparent, which can result\nin protocol errors and other abnormal behaviors from Git. Your mileage\nmay vary.\n\n[1] https://github.com/shopify/toxiproxy\n"},{"id":"427638","messageId":"YMqB1mT9yeRCuA/N@camp.crustytoothpaste.net","threadId":"55942","inReplyTo":"CAGyf7-HyUHJacvpwx6R+_hCVsK_t3F1mQ++2_4-NeJWB9uUjdA@mail.gmail.com","subject":"Re: Simulating network throttling","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-06-16T22:57:26Z","receivedAt":"2021-06-16T22:58:03Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-06-16 at 04:59:00, Bryan Turner wrote:\n> On Tue, Jun 15, 2021 at 9:56 PM Bagas Sanjaya <bagasdotme@gmail.com> wrote:\n> >\n> > Hi,\n> >\n> > I would like to test my Git repository in case the network is throttled\n> > (that is the network speed is reduced from its full speed). For example,\n> > I would like to test git clone under maximum download speed of 9.6 KB/s\n> > (GPRS speed).\n> >\n> > I know how to test for throttling in browser, but since Git is\n> > command-line application, is there any way to simulate network throttling?\n> \n> I've had some luck using toxiproxy[1] to MITM the connection, at least\n> over plain HTTP. It's worth noting a warning brian m. carlson has\n> given others in the past about this sort of thing, though, which is\n> that many MITM solutions are not fully transparent, which can result\n> in protocol errors and other abnormal behaviors from Git. Your mileage\n> may vary.\n\nThat is a warning I frequently give, both here and on Stack Overflow,\nbut I think if you're using a controlled environment and proxying data\njust for yourself, the only person you're hurting is you, so I'm not\ngoing to complain about it very much.  It may nevertheless result in\nfalse failures that you'd otherwise want to avoid, though.\n\nOn Linux, you can also use the tc command to do traffic shaping and\npolicing to allow only a certain amount of bandwidth, and you can use it\nin conjunction with iptables or nftables to do it only on certain ports\nor IPs.  It's very powerful and doesn't suffer from the limitations of\nproxies, but it also is rather complicated to set up, so you may want to\ntry a proxy first to see if it meets your needs with less work.\n\nOpenBSD's (and FreeBSD's, Darwin's, etc.) pf supports the same\nfunctionality but with a much nicer and easier to use interface (and I\nsay this as a Linux user).\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"427669","messageId":"YMr3dwW/hnNhptFN@coredump.intra.peff.net","threadId":"55942","inReplyTo":"YMqB1mT9yeRCuA/N@camp.crustytoothpaste.net","subject":"Re: Simulating network throttling","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-06-17T07:19:19Z","receivedAt":"2021-06-17T07:19:25Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jun 16, 2021 at 10:57:26PM +0000, brian m. carlson wrote:\n\n> On Linux, you can also use the tc command to do traffic shaping and\n> policing to allow only a certain amount of bandwidth, and you can use it\n> in conjunction with iptables or nftables to do it only on certain ports\n> or IPs.  It's very powerful and doesn't suffer from the limitations of\n> proxies, but it also is rather complicated to set up, so you may want to\n> try a proxy first to see if it meets your needs with less work.\n> \n> OpenBSD's (and FreeBSD's, Darwin's, etc.) pf supports the same\n> functionality but with a much nicer and easier to use interface (and I\n> say this as a Linux user).\n\nYeah, these are both good suggestions that work transparently with any\nprotocol. I second the notion that tc is complicated to set up. ;)\n\nIf you really just want a pipe that will do rate-limiting in one\ndirection, many tools (e.g., \"pv\", which is available in debian) will do\nit. That's hard to use with http, but you can stick it into an ssh\npipeline:\n\n  $ git clone git@github.com:torvalds/linux.git\n  Cloning into 'linux'...\n  remote: Enumerating objects: 8129587, done.\n  Receiving objects:   2% (163965/8129587), 70.89 MiB | 20.22 MiB/s\n  ^C\n\n  $ GIT_SSH_COMMAND='f() { ssh \"$@\" | pv -qL 512k; }; f' \\\n    git clone git@github.com:torvalds/linux.git\n  Cloning into 'linux'...\n  remote: Enumerating objects: 8129587, done.\n  Receiving objects:   0% (15263/8129587), 7.57 MiB | 512.00 KiB/s\n  ^C\n\n-Peff\n"}]}