DEV Community

Anderson Yu-Hong Cai
Anderson Yu-Hong Cai

Posted on

PR-02 at Hacktoberfest: From Issue to Pull Request: Adding Windows Network Monitoring to SysMood

Hacktoberfest: Contribution Chronicles

Introduction

Recently, I contributed a Windows-specific network monitoring feature to the open-source project SysMood — a small system stats CLI that originally showed only CPU and memory usage.

This post documents how I went from opening an issue to submitting a pull request, including what I built, the challenges I met, and what I learned along the way.

PR: https://github.com/RayBreeze/SysMood/pull/8

Background

  • Project: SysMood (lightweight CLI system monitor)
  • Goal: Add Network Sent / Received (KB/s) to the main display
  • Environment: Windows (MinGW / g++, CMake)

Workflow

  1. Opened Issue #7 proposing network monitoring for Hacktoberfest.
  2. Created a feature/network-monitor-windows branch.
  3. Implemented logic in network_monitor.h for quick testing.
  4. Adjusted main.cpp display and “mood” thresholds.
  5. Compiled, tested, and fixed bugs repeatedly.
  6. Submitted the PR with clear description and Closes #7.

Technical Highlights

  • API Used: GetIfTable (from iphlpapi) to retrieve interface counters.
    • Tried GetIfTable2 for 64-bit stats but reverted for broader compatibility.
  • Build: Requires linking -liphlpapi (CMake already handles this).
  • Filtering: Deduplicated interfaces by dwIndex and ignored inactive ones.
  • Overflow Handling: Added wrap-around logic since counters are 32-bit.
  • Sampling: Two readings (3s apart), rate = Δbytes / elapsed time.
  • Display: Unified units to KB/s with simple thresholds (0, 1, 10, 100, 1000).

Key Challenges & Fixes

  • Linking Error: Fixed by linking -liphlpapi.
  • Header Incompatibility: GetIfTable2 unavailable in MinGW → fallback.
  • Timing Bug: Corrected order of t0/t1 sampling and interval computation.
  • Unit Confusion: Clarified KB/s vs Kb/s and adjusted mood thresholds.

Lessons Learned

  • Windows IP Helper API quirks and MinGW compatibility details.
  • Importance of documenting quick build commands (g++ ... -liphlpapi).
  • Counter wrap-around is a real issue in performance stats.
  • Even small contributions benefit from clear issue planning and minimal PR scope.

Future Ideas

  • Support GetIfTable2 when headers allow (native 64-bit).
  • Move logic into src/network_monitor.cpp for cleaner structure.
  • Add an optional --network-debug mode for verbose output.
  • Consider smoother averaging for display (EMA or multi-sample).

Conclusion

This Issue → PR journey helped me understand Windows network monitoring in depth — from API details to linking traps.

For anyone planning similar contributions: start with a well-defined issue, test iteratively, and keep your PRs small and review-friendly.

Top comments (0)