Skip to content

Two ways to traceroute (one is TCP ICMP, another is UDP ICMP, TCP is better)

Notifications You must be signed in to change notification settings

michael080808/pyTraceRoute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

pyTraceRoute

Two ways to traceroute.
One is TCP ICMP, another is UDP ICMP.
The TCP is better than UDP, because UDP is more easily blocked by firewall.
Use Python 3 and Linux Mint 18.1 (Ubuntu 16.04.2 LTS)

UDP & ICMP Trace Route

Tracert/TraceRouter Process
1.Struct UDP Datagram, Set TTL(Time to Live) = 1
2.Send Out UDP Datagram, Record Time t1,
3.Receive ICMP Error Packets

    Timeout -> Middleware Router, Continue to 4
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
    |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   Type = 11   |   Code = 0    |           Checksum            |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |                            Unused                             |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |              IP Header   Original Data Fisrt 8B               |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

    Unreachable -> Endpoint Router, Stop the program.
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
    |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   Type = 3    |   Code = 3    |           Checksum            |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |                            Unused                             |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |              IP Header   Original Data Fisrt 8B               |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

4.TTL = TTL   1, Return Item 2.

TCP & ICMP Trace Route

Tracert/TraceRouter Process
1.Struct TCP, Set TTL(Time to Live) = 1
2.Try to start TCP connection, Record Time t1,
3.Receive ICMP Error Packets

    Timeout -> Middleware Router, Continue to 4
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
    |0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   Type = 11   |   Code = 0    |           Checksum            |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |                            Unused                             |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |              IP Header   Original Data Fisrt 8B               |
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

    Reachable -> Catch TCP [SYN, ACK], Endpoint Router, Stop the program.

4.TTL = TTL   1, Return Item 2.

TCP [SYN] -> ICMP [TTL Exceeded]

TCP [SYN] -> TCP [SYN, ACK]

IP(Internet Protocol):

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|Version|  IHL  |Type of Service|         Total Length          |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|        Identification         | Flags | Fragmentation Offset  |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| Time to Live  |   Protocol    |        Header Checksum        |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                        Source Address                         |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                      Destination Address                      |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                    Options                    |    Padding    |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                             Data                              |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

ICMP(Internet Control Message Protocol):

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     Type      |     Code      |           Checksum            |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|          Identifier           |        Sequence Number        |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                         Optional Data                         |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

TCP(Transmission Control Protocol)

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|          Source Port          |       Destination Port        |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                        Sequence Number                        |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|               Acknowledgment Number(if ACK set)               |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| Data  | | | |N|C|E|U|A|P|R|S|F|            Window             |
|       |0|0|0| |W|C|R|C|S|S|Y|I|                               |
|Offset | | | |S|R|E|G|K|H|T|N|N|             Size              |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|           Checksum            |   Urgent pointer(if URG set)  |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                            Options                            |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

UDP(User Datagram Protocol)

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|2|2|2|2|2|2|2|2|2|3|3|
|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|1|
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|          Source Port          |       Destination Port        |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|             Length            |           Checksum            |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|                             Data                              |
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

About

Two ways to traceroute (one is TCP ICMP, another is UDP ICMP, TCP is better)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages