- C++ 78%
- Python 8.2%
- C 6.9%
- Makefile 6.5%
- Shell 0.4%
| include | ||
| src | ||
| .gitignore | ||
| get_address.py | ||
| Makefile | ||
| README.md | ||
| start.sh | ||
Tunnet
Tunnet is a C++ application that utilizes a TUN virtual network interface to intercept IPv6 transit traffic, specifically ICMPv6 Echo Requests. By analyzing incoming packets, Tunnet can dynamically fabricate custom ICMP responses (such as "Time Exceeded" or synthetic "Echo Replies") to simulate custom network hop topologies.
It is specifically designed for testing and manipulating outputs of routing diagnostic tools like mtr (My traceroute) and traceroute6.
Features
- TUN Interface Interception: Connects to a virtual TUN interface to read and respond to IPv6 traffic programmatically.
- Dynamic Traceroute Simulation: Constructs synthetic network topologies in response to
traceroute6ormtrprobes based on encoded parameters in the destination IPv6 address. - Time-Based Cycling: Creates visual animated effects in
mtrby cycling returned hop IPs dynamically based on system time. - Target Address Generator: Includes a Python utility (
get_address.py) to generate properly formatted IPv6 addresses that dictate how Tunnet synthesizes paths.
Requirements
- Linux operating system (with TUN/TAP support enabled in kernel)
- C++23 compatible compiler (e.g. GCC)
- GNU Make
- Python 3 (for the
get_address.pyutility) - Root/sudo privileges (required for TUN interface creation) (cap_net_admin doesn't suffice)
Building Note
Simply run make in the root directory to build the release. By default, it builds the unoptimized debug target.
Use make release for optimized output.
make
Running
Run the built executable my_program as root, or use the provided startup script.
sudo ./my_program
# or
./start.sh
Using get_address.py
Use the get_address.py script to generate a target IPv6 address for passing into your trace applications (mtr, traceroute6). The script allows you to dictate how many hops and how wide (lines) the synthetic trace paths will output:
python3 get_address.py <base_ipv6> <hop_count> <line_count>
Example:
python3 get_address.py 2001:db8:: 10 3
- Hop Count: Range 0 to 31 (Determines how deep the fake structure will route).
- Line Count: Range 0 to 7.
Structure
src/main.cpp: The core loop orchestrating the reading and responding loop.src/tun.cpp/include/tun.h: TUN interface abstraction and management.src/packet.cpp/include/packet.h: Handles ICMPv6 checksum calculation and response crafting.src/trace.cpp/include/trace.h: Core logic calculating the deterministic synthetic IPs formtr/traceroutes.src/logger.cpp/include/logger.h: Logging operations for packet statistics.