This project is a learning journal of sorts, it started before my Data Structures course Spring of 26, and as I learn more I update this project with what I learned in/out of class whenever I have the time.
- Moved utility functions outside of net.c and into neth.c, and the prototype functions into neth.h as well as struct type and defines.
- Changed from singly linked list to dynamic array;
- Linked lists had caused memory fragmentation and cache misses because of the non-contiguous node allocation, while dynamic arrays are contiguous in memory, making iteration faster with better cache locality, and less per-element overhead.
I like to use gcc:
gcc -o net net.c neth.c ./net -a : List all connections regardless of state.
./net -t : List connections with "ESTABLISHED" state.
./net -l : List connections with "LISTENING" state.Priority: get rid of get inode by pid function because the time complexity is horrendous, switching to hash table for constant/linear time complexity.
- Better connection filtering and search by parsing dynamic command-line args. (optarg or getopt).
- Live monitoring of /proc/net/tcp that updates every 2-3 seconds instead of a static capture.
- DNS name resolution.
- Export to JSON or CSV.
- Maybe utilize eBPF in the future for faster captures.