--- phase: 01-capture-and-classification plan: 01 subsystem: classification tags: [go, gopacket, protocol-classification, tdd, packet-capture] # Dependency graph requires: [] provides: - "Go 1.24.1 module initialized (github.com/netsynth/netsynth)" - "classify/types.go: TrafficClass (11 constants), ClassifiedPacket, WindowSnapshot shared types" - "classify/rules.go: Rule struct and DefaultRules slice with 12 ordered protocol rules" - "classify/classifier.go: Classifier with NewClassifier and Classify(gopacket.Packet) methods" - "Unit tests for all 11 traffic classes, 14 test cases, all passing" affects: - 01-capture-and-classification - 02-audio-synthesis - 03-clustering # Tech tracking tech-stack: added: - "github.com/gopacket/gopacket v1.5.0 — packet decode and layer type assertions" - "github.com/packetcap/go-pcap v0.0.0-20251215 — in go.sum for Phase 1 capture plan" - "github.com/spf13/cobra v1.10.2 — in go.sum for Phase 1 CLI plan" patterns: - "Config-driven rule slice (not switch) for classification — per D-02" - "First-match-wins rule evaluation over ordered []Rule slice" - "Classifier struct accepting rules at construction for testability" - "test package (classify_test) using gopacket SerializeLayers for synthetic packet construction" key-files: created: - "classify/types.go — TrafficClass, ClassifiedPacket, WindowSnapshot shared contracts" - "classify/rules.go — Rule struct, DefaultRules with 12 ordered protocol rules" - "classify/classifier.go — Classifier, NewClassifier, Classify method" - "classify/classifier_test.go — 14 test cases covering all 11 traffic classes" - "go.mod — module github.com/netsynth/netsynth, go 1.24.1" - "go.sum — all dependency checksums" modified: [] key-decisions: - "Go installed at /home/dev/tools/go-install/go (no sudo available) — export PATH=$PATH:/home/dev/tools/go-install/go/bin required" - "DefaultRules uses ordered slice with DstPort=0 as catch-all — enables first-match-wins without switch" - "ICMP checked before TCP/UDP in Classify to handle ICMP packets that decode no port" - "go mod tidy removes go-pcap and cobra from go.mod until they are imported in later plans" patterns-established: - "Classifier struct pattern: NewClassifier(rules []Rule) accepts rules at construction, enabling custom rules in tests" - "Synthetic packet construction: gopacket SerializeLayers with Ethernet+IPv4+TCP/UDP/ICMP layers" requirements-completed: [CLAS-01] # Metrics duration: 4min completed: 2026-03-25 --- # Phase 01 Plan 01: Bootstrap and Protocol Classification Engine Summary **Config-driven packet classifier with 12 protocol rules identifying ICMP, DNS, HTTPS, HTTP, SSH, SMTP, NTP, DHCP, other-TCP, other-UDP, and unknown traffic via ordered []Rule slice** ## Performance - **Duration:** 4 min - **Started:** 2026-03-25T11:09:11Z - **Completed:** 2026-03-25T11:13:13Z - **Tasks:** 2 - **Files modified:** 6 ## Accomplishments - Go 1.24.1 installed and module initialized with gopacket, go-pcap, and cobra dependencies - 11 TrafficClass constants + ClassifiedPacket + WindowSnapshot types established as shared contracts for all downstream phases - Config-driven classifier (no switch) with 12 ordered rules; first-match-wins; ICMP handled separately from TCP/UDP port matching - All 14 TDD tests pass covering all 11 traffic classes and rule ordering behavior ## Task Commits Each task was committed atomically: 1. **Task 1: Install Go 1.24, initialize module, create shared types** - `15e8143` (feat) 2. **Task 2 RED: Failing tests for all 11 protocol classes** - `f233e80` (test) 3. **Task 2 GREEN: Config-driven classifier implementation** - `48ef6e5` (feat) 4. **Task 2 TIDY: go mod tidy after imports added** - `25e0dc3` (chore) _Note: TDD task had test commit (RED) then feat commit (GREEN), plus a tidy cleanup._ ## Files Created/Modified - `classify/types.go` - TrafficClass (11 constants), ClassifiedPacket, WindowSnapshot, AllClasses() - `classify/rules.go` - Rule struct, DefaultRules slice with 12 ordered protocol rules - `classify/classifier.go` - Classifier struct, NewClassifier, Classify method (no switch) - `classify/classifier_test.go` - 14 test cases, 243 lines, all protocol classes covered - `go.mod` - Module github.com/netsynth/netsynth, go 1.24.1, gopacket direct dep - `go.sum` - All dependency checksums including go-pcap and cobra for future plans ## Decisions Made - Go installed to `/home/dev/tools/go-install/go` (not /usr/local — no sudo access); PATH export needed in each shell session - ICMP classification checked before TCP/UDP since ICMP has no ports — avoids the "no transport layer" fallthrough for valid ICMP packets - `go mod tidy` trimmed go-pcap and cobra to indirect/removed since they have no code importing them yet; they will be re-added as direct deps when capture and CLI plans import them ## Deviations from Plan None - plan executed exactly as written. The only operational difference was installing Go to `/home/dev/tools/go-install/go` instead of `/usr/local/go` due to lack of sudo access — functionality is identical. ## Issues Encountered - No sudo access — Go 1.24.1 installed to `/home/dev/tools/go-install/go` instead of `/usr/local/go`. PATH must include `/home/dev/tools/go-install/go/bin` in each session. - `go mod tidy` removes go-pcap and cobra from go.mod when no code imports them. This is expected Go behavior; these dependencies will become direct when imported in Plans 02-04. ## User Setup Required None - no external service configuration required. Note that running `go` commands requires: ``` export PATH=$PATH:/home/dev/tools/go-install/go/bin ``` ## Next Phase Readiness - classify package is complete and compiles; all types are stable contracts for downstream phases - Plan 01-02 (capture pipeline) can import classify and start building on top of ClassifiedPacket/WindowSnapshot - Plan 01-03 (aggregation) can import WindowSnapshot directly - No blockers --- *Phase: 01-capture-and-classification* *Completed: 2026-03-25*