Yes, you can do it for UDP easily, but anything TCP/stream based you can “throttle”, but can’t simulate dropped packets by a router, etc. unless using a raw IP proxy and you need to perform packet manipulation, etc. - not trivial.
What I’ve found is that using “delays” only test part of the equation - dropped packets cause an exponential delay at times depending on the tcp flow congestion strategy (configurable), the traffic patterns, and the physical network layer rates, etc. For most purposes, just delaying the request or response will suffice. > On Dec 11, 2018, at 6:45 PM, Ian Denhardt <i...@zenhack.net> wrote: > > Quoting robert engels (2018-12-11 19:39:46) > >> I am not sure you can do this at the application layer - you need kernel >> support to drop packets. > > One could write a mock implementation of e.g. net.Conn that does this > kind of simulation; have a goroutine that calls time.Sleep at random > intervals in the most basic case. If you want to test UDP, randomly drop > packets, reorder, etc. Could get fancier. No external support required. > > That was the kind of thing I interpreted Dan's question to be asking > about. > > I don't know off-hand of a good library that already does this though. > > -Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.