https://github.com/james-p-d/traceroute
A simple command-line tracert implementation in Python 3 using ICMP packets
https://github.com/james-p-d/traceroute
icmp python python3 traceroute tracert
Last synced: 13 days ago
JSON representation
A simple command-line tracert implementation in Python 3 using ICMP packets
- Host: GitHub
- URL: https://github.com/james-p-d/traceroute
- Owner: James-P-D
- License: mit
- Created: 2019-11-04T20:40:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-11-06T11:43:37.000Z (almost 4 years ago)
- Last Synced: 2024-11-17T10:35:40.276Z (11 months ago)
- Topics: icmp, python, python3, traceroute, tracert
- Language: Python
- Homepage:
- Size: 159 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Traceroute
A simple command-line tracert implementation in Python 3 using ICMP packets
## Details
Traceroute is a networking tool designed for tracing the movement of packets across a network. In this Python 3 implementation, [ICMP](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol) 'ping' packets are used, much like the Windows `tracert.exe` program (and unlike Unix `tracert` which typically uses UDP packets).
The application sends a sequence of ICMP packets to the host, initially with the [Time-To-Live](https://en.wikipedia.org/wiki/Time_to_live) field set to `1`. As the packet travels across the network to its final destination, each node it passes through will decrement the TTL field by `1`. When the field reaches zero the node will respond by saying that the packet could not reach its destination.
```
+------+ +--------+
| | TTL = 1 | |
| | --------> | |
| HOST | | node 1 |
| | timeout | |
| | <-------- | |
+------+ +--------+
```Having now identified the first node that the packet passes through, tracert now sends another ICMP packet with TTL set to `2`, which will timeout when it reaches the second node, and so on.
```
+------+ +--------+ +--------+
| | TTL = 2 | | TTL = 1 | |
| | --------> | | --------> | |
| HOST | | node 1 | | node 2 |
| | timeout | | timeout | |
| | <-------- | | <-------- | |
+------+ +--------+ +--------++------+ +--------+ +--------+ +--------+
| | TTL = 3 | | TTL = 2 | | TTL = 1 | |
| | --------> | | --------> | | --------> | |
| HOST | | node 1 | | node 2 | | node 3 |
| | timeout | | timeout | | timeout | |
| | <-------- | | <-------- | | <-------- | |
+------+ +--------+ +--------+ +--------+
```Eventually, an ICMP packet will be sent with a sufficiently large TTL value that it can reach the final destination, at which point the process is complete.
```
+------+ +--------+ +--------+ +--------+ +--------+
| | TTL = 4 | | TTL = 3 | | TTL = 2 | | TTL = 1 | |
| | --------> | | --------> | | --------> | | --------> | |
| HOST | | node 1 | | node 2 | | node 3 | | TARGET |
| | success | | success | | success | | success | |
| | <-------- | | <-------- | | <-------- | | <-------- | |
+------+ +--------+ +--------+ +--------+ +--------+
```