robertdavidgraham/masscan — pull request #104 by dadrian (2014-07-09 22:48:42+00:00)
Title: Fix sharding with multiple NICs / threads

Previously, sharding with multiple NICs resulted in number_of_shards +
number_of_nics total shards, rather than splitting up the current shard
by number_of_nics.

For example, --shard=1/50 on a system with two NICs would result in an
increment of 52 (50 + 2), when instead what you really want is an
increment of 100, offset by 50 on each NIC, e.g. NIC 0 starts at 0, NIC
1 starts at 50, both increment by 100.

Luckily, the old implementation didn't result any any single instance of
masscan scanning any host more than once, but if all shards were
distributed across multiple hosts/scans, certain shards would be
overlapped, e.g. --shard=1/50 would scan shards 1 and 2, --shard=2/50
would scan shards 2 and 3, etc. It also would result in errors when
random sampling, as more address would be scanned than expected with a
single shard, e.g. when scanning 1 of 50 shards you would not get a 2%
sample.