Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have been working on a replay tool in python. I had to add sleeps because it was sending packets faster than the NIC could send them in order.


That's not a reliable way to do that. It should block.


it is actually more reliable to sleep than to block. by definition blocking is unreliable because you don't know exactly when it will unblock. You do know when a sleep will end though. I also want a variable delay between writes.


Uhhh. I think you need to study this topic some more.

> it is actually more reliable to sleep than to block. by definition blocking is unreliable because you don't know exactly when it will unblock.

A block will end when the nic can handle more data. You can't just wait a second and assume the nic can handle the data. That's where the "unreliable" part comes in. You assume it can handle the data, but you are not checking. And the way to check is either by polling, blocking, or receiving a signal. Waiting is not a way to check.

> You do know when a sleep will end though.

It makes no difference that you know when the sleep will end. It's irrelevant - all you care about is can the nic accept more data or not.

> I also want a variable delay between writes.

If you want variable delays then do that, but that has nothing whatsoever to do with making sure the nic doesn't lose data.


cool, I'll check the nic status before sending if I ever want to maximize throughput. But I'll probably rewrite it in C at that point too.


"Check the NIC status"? What network API are you using? Even if you're injecting with libpcap, you can still just select() on the device handle.


I am not using an API, I am writing to the driver


Just use Winpcap instead of wasting time reinventing this wheel.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: