HuangLab-SYSU / block-emulator

MIT License
241 stars 64 forks source link

Network simulation in Linux #41

Closed zhazhalaila closed 1 month ago

zhazhalaila commented 1 month ago

Thanks for sharing the block-emulator.

It seems that you use Rate Limiting to simulate the network bandwidth (I'm not sure if this is the right way to do it). In linux, we can use traffic control to achieve this function.

iiinotlll commented 1 month ago

Thank you for your insightful feedback!

We indeed used rate limiting in Go to simulate network bandwidth constraints.

Since the code we provided does not involve control at the operating system level, the rate limiting approach is a workaround.

For operating systems, the traffic control you used is a better option.

zhazhalaila commented 1 month ago

Thank you for your insightful feedback!

We indeed used rate limiting in Go to simulate network bandwidth constraints.

Since the code we provided does not involve control at the operating system level, the rate limiting approach is a workaround.

For operating systems, the traffic control you used is a better option.

Yeah, you have constrains the bandwidth in the application level (using golang rate limit library). My worry about is that is a right way to do this? If I limit the bandwidth of each machine in 100kbps by rate limit library, is this machine really have 100kbps? How to get the real bandwidth of machine after use rate limit library?

iiinotlll commented 1 month ago

Yeah, you have constrains the bandwidth in the application level (using golang rate limit library). My worry about is that is a right way to do this? If I limit the bandwidth of each machine in 100kbps by rate limit library, is this machine really have 100kbps? How to get the real bandwidth of machine after use rate limit library?

Thank you for your questions. I understand your concerns.

My worry about is that is a right way to do this?

Network bandwidth management typically uses operating system-level tools and requires administrative privileges. As a simulator, BlockEmulator should not affect the real bandwidth of a certain machine. So, although the rate limiting library is not very accurate in simulating bandwidth control, we still choose it as a workaround.

If I limit the bandwidth of each machine in 100kbps by rate limit library, is this machine really have 100kbps?

No. The rate limiting library does not actually restrict a machine's network bandwidth; instead, it limits the speed of writes to a TCP listener. Therefore, when using the rate limiting library, BlockEmulator will not impact the real bandwidth of a machine but will only control the read/write speed to a certain iostream at the application layer.

How to get the real bandwidth of machine after use rate limit library?

After using the rate limit library, you can use some network monitoring tools to get the real bandwidth, e.g., iperf, netstat.

zhazhalaila commented 1 month ago

Yeah, you have constrains the bandwidth in the application level (using golang rate limit library). My worry about is that is a right way to do this? If I limit the bandwidth of each machine in 100kbps by rate limit library, is this machine really have 100kbps? How to get the real bandwidth of machine after use rate limit library?

Thank you for your questions. I understand your concerns.

My worry about is that is a right way to do this?

Network bandwidth management typically uses operating system-level tools and requires administrative privileges. As a simulator, BlockEmulator should not affect the real bandwidth of a certain machine. So, although the rate limiting library is not very accurate in simulating bandwidth control, we still choose it as a workaround.

If I limit the bandwidth of each machine in 100kbps by rate limit library, is this machine really have 100kbps?

No. The rate limiting library does not actually restrict a machine's network bandwidth; instead, it limits the speed of writes to a TCP listener. Therefore, when using the rate limiting library, BlockEmulator will not impact the real bandwidth of a machine but will only control the read/write speed to a certain iostream at the application layer.

How to get the real bandwidth of machine after use rate limit library?

After using the rate limit library, you can use some network monitoring tools to get the real bandwidth, e.g., iperf, netstat.

Got it. Thanks for your reply.