Skip to content

Commit 28f047e

Browse files
committed
Cap the number of probes to send
This commit does two things: It caps the number of probes to send per prefix and per TTL to 4095 after the first 256 probes. It also pins the ClickHouse server to version 22.8 because the latest ClickHouse version does not work with this version of diamond-miner
1 parent 76cafb8 commit 28f047e

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
services:
99
clickhouse:
10-
image: clickhouse/clickhouse-server
10+
image: clickhouse/clickhouse-server:22.8
1111
ports: ["8123:8123"]
1212
steps:
1313
- uses: actions/checkout@v3

diamond_miner/generators/database.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from diamond_miner.queries import GetProbesDiff
1717
from diamond_miner.typing import FlowMapper, IPNetwork, Probe
1818

19+
max_probes = 0
1920

2021
def probe_generator_from_database(
2122
client: ClickHouseClient,
@@ -45,6 +46,10 @@ def probe_generator_from_database(
4546
>>> (str(ip_address(probes[0][0])), *probes[0][1:])
4647
('::ffff:808:100', 24000, 33434, 1, 'icmp')
4748
"""
49+
if max_probes == 0:
50+
max_probes = 4095 # XXX make this a parameter
51+
logging.info("capping the number of probes to send at %d", max_probes)
52+
4853
rows = GetProbesDiff(
4954
round_eq=round_, probe_ttl_geq=probe_ttl_geq, probe_ttl_leq=probe_ttl_leq
5055
).execute_iter(client, measurement_id, subsets=subsets)
@@ -60,8 +65,8 @@ def probe_generator_from_database(
6065
addr_offset, port_offset = mapper.offset(flow_id, dst_prefix_int)
6166
dst_addr = dst_prefix_int + addr_offset
6267
src_port = probe_src_port + port_offset
63-
if src_port > (2**16 - 1):
64-
# TEMP: Log prefixes that overflows the port number and skip prefix.
65-
logger.warning("Port overflow for %s", row)
68+
# Note that port_offset is actually the number of probes sent after having already sent 256 probes.
69+
if port_offset > max_probes:
70+
logger.warning("not probing %s after having already sent %d probes", row, max_probes+256)
6671
break
6772
yield dst_addr, src_port, probe_dst_port, ttl, protocol_str # type: ignore

docs/dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ poetry run bumpversion patch # or minor/major
3131
Most tests require a running instance of ClickHouse with pre-populated tables.
3232
To start a ClickHouse server and insert the test data:
3333
```bash
34-
docker run --rm -d -p 8123:8123 clickhouse/clickhouse-server:22.6
34+
docker run --rm -d -p 8123:8123 clickhouse/clickhouse-server:22.8
3535
poetry run python tests/data/insert.py
3636
```
3737

docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ These components can be pieced together to conduct various kind of topology meas
1212

1313
To run the examples below, you need a running [ClickHouse](https://clickhouse.com) server:
1414
```bash
15-
docker run --rm -d -p 8123:8123 clickhouse/clickhouse-server:22.6
15+
docker run --rm -d -p 8123:8123 clickhouse/clickhouse-server:22.8
1616
```
1717

1818
You also need [`pycaracal`](https://github.com/dioptra-io/caracal) and [`pych-client`](https://github.com/dioptra-io/pych-client).

0 commit comments

Comments
 (0)