Devlog #2: Writing the aggregator
TL;DR: Wrote the Aggregator that empties the queue every tick and turns hundreds of single events into one snapshot. Tested it with asserts. Hit a few silent bugs on the way.
Goal for this session:
Write the part that actually reads the queue from the fake generator and summarizes it.
What I did:
- Wrote the aggregator with flush() function
-
flush()takes everything out of the queue and returns one snapshot: bytes in, bytes out and packet count per process, plus a list of one-off events (DNS and connections) - Traffic with no known process goes under
"unknown"- Added a limit of 20000 events per tick, so a flood of events can’t make one tick last forever
This is how the snapshots looks like:
{ "t": 1791121104.34,
"processes": { "chrome.exe": {"bytes_in": 1000, "bytes_out": 200, "packets": 2},
"spotify.exe": {"bytes_in": 500, "bytes_out": 0, "packets": 1},
"unknown": {"bytes_in": 0, "bytes_out": 120, "packets": 1} },
"events": [ {"type": "dns", "process": "unknown", "request_name": "google.com"}
]}
Problems I hit:
- I used
=+ 1instead of+= 1so the program just set the counter to 1 instead of adding 1
What I learned:
-That the bugs that do not crash the script are worse than the ones that do
#Next up:
-
test_run.py: fake generator in a thread + aggregator every 100 ms - Turn per-tick sums into bytes/s
P.S. : BUKU BUKU GO!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.