以编程方式模拟数据包丢失和延迟
我有一个通过 rpc 公开其服务的服务器和一个使用这些服务的客户端。为了测试此设置,我需要引入数据包丢失和延迟。我在stackoverflow上找到了一些技术,例如tc、修改iptables等,但它们都需要root密码来模拟丢包。有没有一种方法可以在不需要 root 密码的情况下模拟这些数据包丢失。
注:代码是用GO编程语言编写的
I have a server that exposes its services over rpc and a client that uses these services. To test this setup, I need to introduce packet losses and delays. I found a few techniques on stackoverflow like tc, modifying iptables etc but all of them need root password to simulate the packet loss. Is there a way to simulate these packet losses without needing a root password.
Note: The code is written in GO programming language
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是隔离数据包处理代码,并创建它的模拟版本(或 ifdef 部分),以进行测试,以您选择的方式表现错误。
这可能足以满足您的需求。
对于工业强度测试、商业或关键应用程序,您至少需要一个具有 root 密码的盒子。 :) 也许还有更奇特的测试设备,它们可能会以更奇特的方式出现故障。
One way is to isolate your packet handling code, and create mock-version of it (or ifdef'd sections) that, for testing, misbehave in the manner of your choosing.
That may be enough for your needs.
For industrial-strength testing, for a commercial or critical application, you'll want AT LEAST a box where you have root password. :) And perhaps more exotic test equipment that can misbehave in more exotic ways.