Flow mappers
diamond_miner.mappers
Functions for mapping flow IDs to addresses and ports.
We make the flow ID start at 0.
prefix_size
is the number of addresses in the prefix:
2 ** (32 - 24)
for a /24 in IPv4.
IntervalFlowMapper
Similar to the SequentialFlowMapper
but with an increment >= 1.
This allows to target addresses .1, .33, .65, ... in priority,
which are more likely to respond to probes[@fan2010selecting].
Examples:
>>> from diamond_miner.mappers import IntervalFlowMapper
>>> mapper = IntervalFlowMapper()
>>> mapper.offset(1)
(33, 0)
Source code in diamond_miner/mappers.py
RandomFlowMapper
Similar to the SequentialFlowMapper
but with a random mapping between flow IDs and addresses.
The mapping is randomized by prefix.
Examples:
>>> from diamond_miner.mappers import RandomFlowMapper
>>> mapper = RandomFlowMapper(seed=2022)
>>> mapper.offset(1, prefix=1)
(34, 0)
>>> mapper.offset(1, prefix=2)
(145, 0)
Source code in diamond_miner/mappers.py
ReverseByteFlowMapper
Maps flow n
to address reverse(n)
until we have done the whole prefix.
It then increases the port number sequentially.
Examples:
>>> from diamond_miner.mappers import ReverseByteFlowMapper
>>> mapper = ReverseByteFlowMapper()
>>> mapper.offset(1)
(129, 0)
Source code in diamond_miner/mappers.py
SequentialFlowMapper
Maps flow 0 to address 0, flow 1 to address 1, and so on until we have done the whole prefix. It then increases the port number in the same manner.
Examples:
>>> from diamond_miner.mappers import SequentialFlowMapper
>>> mapper = SequentialFlowMapper()
>>> mapper.offset(1)
(1, 0)