All work

BOTNET DETECTION / NETWORK TRAFFIC & MACHINE LEARNING

Network traffic.
Meaningful signals.

A flow-based approach to botnet detection, turning packet records into structured features for machine learning.

REPOSITORY PUBLISHED
2019
MY WORK
Packet labelling, bidirectional flow construction & feature engineering
PROJECT TYPE
Early machine-learning exploration
PUBLIC ARCHIVE
Design diagrams & source excerpts
5FIELDS IN THE FLOW KEY
2TRAFFIC DIRECTIONS
3,600 sFLOW-TIME THRESHOLD
2019REPOSITORY PUBLISHED

Based on the public README and Python source · reviewed 25 September 2026.

01 / THE PROBLEM

Finding useful signals
in network traffic.

A packet is a small piece of a larger conversation. This project explores botnet detection by grouping packet records into flows and extracting features that describe how those conversations behave.

The README frames the project around botnet and IRC traffic classification. The published source focuses on the data pipeline: labelling packet records, identifying bidirectional flows and calculating inputs for a machine-learning stage.

Red and blue botnet-themed artwork from the project README.
Botnet detection using machine learningThe cover artwork from the original repository. The engineering diagrams below describe the data flow.
PythonGraphLab / SFrameNetwork flowsFeature engineering

02 / THE DATA PIPELINE

Give each conversation
a consistent identity.

  1. Load and label packet recordsRead a CSV into a GraphLab SFrame, convert hexadecimal TCP flags to integers, and assign bot labels from a list of known endpoints and endpoint pairs.
  2. Build a bidirectional flow keyCombine the two IP addresses, their ports and the protocol. Order the endpoints consistently so packets travelling in opposite directions can share an identifier.
  3. Sort and segment the trafficSort by flow key and timestamp, then assign sequential flow numbers. The loop uses key changes, TCP FIN flags and a 3,600-second elapsed-time threshold as flow boundaries.
  4. Aggregate and retain the resultGroup packet records by flow, join computed statistics back to the data and persist the flow assignments for subsequent processing.
Flow-based feature generator linked to a flow identifier, packet-wise flow numbers and a CSV of extracted features.
Inside the flow generatorLevel 2 diagram from the README. Packet records receive flow identifiers before they are aggregated into features.

Keeping both directions together makes it possible to describe a conversation rather than treating each packet as an isolated observation.

03 / FEATURE ENGINEERING

From packet fields
to behavioural features.

The visible code includes several complementary ways of describing traffic. Each captures a different property of a flow rather than relying only on a raw packet record.

Directional packet ratio
Count forward and reverse packets using the canonical endpoint ordering. Compute reverse-to-forward volume, with a sentinel value of −1 when there are no forward packets.
First packet length
Find the earliest timestamp in each flow and join it back to the packet records. Average the lengths if more than one record shares that earliest time.
Average packet rate
Divide the packet count by the flow duration, with a zero-duration guard. The excerpt references a duration table whose construction is not included.
Protocol and payload clues
Flag UDP traffic and define a helper for recognising packets with no payload from segment lengths and protocol headers.

Other selected columns include duration, exchanged bytes, packet-length variation and equal-length packet ratios. Their complete derivations are outside the published sample.

04 / SYSTEM DESIGN

The feature pipeline
supports the classifier.

The README diagrams connect the flow generator to a separate machine-learning module. The first view establishes the detection task; the second shows how extracted features feed training, testing and optimisation.

Level zero diagram taking training or test data into a system and returning a botnet-or-benign prediction.
The detection system at a glanceOriginal Level 0 diagram from the README: traffic data in, a botnet-or-benign prediction out.
A flow generator supplies CSV features to a machine-learning module containing training, testing and optimisation stages.
How the features connect to modellingOriginal Level 1 diagram from the README. It documents the intended training, testing and optimisation cycle.

This separation gives the feature pipeline a clear role: produce a consistent representation of each traffic flow so that modelling approaches can be evaluated on the same inputs.

05 / WHAT THE REPOSITORY SHOWS

A feature-engineering
implementation to inspect.

The public main2.01.py is an exported notebook-style source sample. It shows the labelling rules, flow-building loop, aggregation logic and feature calculations. The referenced traffic CSV and complete modelling code are not included.

The README describes deep learning and comparison across classification algorithms. The available source does not include the fitted classifiers, train/test split or recorded metrics needed to reproduce those results. This case study therefore presents the demonstrated data-engineering work without an accuracy claim.

06 / LOOKING BACK

The representation
sets up the result.

The engineering work sits in the transition from packet rows to structured flows: making identifiers consistent, preserving direction, handling flow boundaries and deciding how to aggregate observations.

A stronger follow-up would test reverse-direction matching and boundary cases explicitly, publish the feature schema, and evaluate held-out captures or hosts. Because the initial labels are based on known endpoints, the evaluation should check whether a model generalises to new traffic rather than simply recognising those identities.

Measure the mistakes that matter.

Botnet recall, precision and the false-positive rate on benign traffic would make a classifier comparison more useful than a single overall accuracy score.

NEXT PROJECT

Artificially intelligent game

↗