diff --git a/README.md b/README.md index 60dd073..0b56314 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ nexttrace --first 5 --max-hops 10 www.decix.net # Turn off the IP reverse parsing function nexttrace --no-rdns www.bbix.net +# Set the payload size to 1024 bytes +nexttrace --psize 1024 example.com + # Feature: print Route-Path diagram # Route-Path diagram example: # AS6453 Tata Communication「Singapore『Singapore』」 @@ -243,14 +246,18 @@ Arguments: -D --dev Use the following Network Devices as the source address in outgoing packets -R --route Show Routing Table [Provided By BGP.Tools] - -z --send-time Set the time interval for sending every + --send-time Set the time interval for sending every packet. Useful when some routers use rate-limit for ICMP messages. Default: 100 -i --ttl-time Set the time interval for sending packets groups by TTL. Useful when some routers use rate-limit for ICMP messages. Default: 500 - --_positionalArg_nexttrace_25 IP Address or domain name + -z --timeout The number of seconds to keep probe + sockets open before giving up on the + connection.. Default: 1 + --psize Set the packet size (payload size). + Default: 52 --dot-server Use DoT Server for DNS Parse [dnssb, aliyun, dnspod, google, cloudflare] -g --language Choose the language for displaying [en, diff --git a/README_zh_CN.md b/README_zh_CN.md index 57733ff..24fc583 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -138,6 +138,9 @@ nexttrace --first 5 --max-hops 10 www.decix.net # 关闭IP反向解析功能 nexttrace --no-rdns www.bbix.net +# 设置载荷大小为1024字节 +nexttrace --psize 1024 example.com + # 特色功能:打印Route-Path图 # Route-Path图示例: # AS6453 塔塔通信「Singapore『Singapore』」 @@ -250,14 +253,18 @@ Arguments: -D --dev Use the following Network Devices as the source address in outgoing packets -R --route Show Routing Table [Provided By BGP.Tools] - -z --send-time Set the time interval for sending every + --send-time Set the time interval for sending every packet. Useful when some routers use rate-limit for ICMP messages. Default: 100 -i --ttl-time Set the time interval for sending packets groups by TTL. Useful when some routers use rate-limit for ICMP messages. Default: 500 - --_positionalArg_nexttrace_25 IP Address or domain name + -z --timeout The number of seconds to keep probe + sockets open before giving up on the + connection.. Default: 1 + --psize Set the packet size (payload size). + Default: 52 --dot-server Use DoT Server for DNS Parse [dnssb, aliyun, dnspod, google, cloudflare] -g --language Choose the language for displaying [en, diff --git a/cmd/cmd.go b/cmd/cmd.go index 5196ebb..b8620d5 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -60,6 +60,7 @@ func Excute() { packet_interval := parser.Int("", "send-time", &argparse.Options{Default: 100, Help: "Set the time interval for sending every packet. Useful when some routers use rate-limit for ICMP messages"}) ttl_interval := parser.Int("i", "ttl-time", &argparse.Options{Default: 500, Help: "Set the time interval for sending packets groups by TTL. Useful when some routers use rate-limit for ICMP messages"}) timeout := parser.Int("z", "timeout", &argparse.Options{Default: 1, Help: "The number of seconds to keep probe sockets open before giving up on the connection."}) + packetSize := parser.Int("", "psize", &argparse.Options{Default: 52, Help: "Set the packet size (payload size)"}) str := parser.StringPositional(&argparse.Options{Help: "IP Address or domain name"}) dot := parser.Selector("", "dot-server", []string{"dnssb", "aliyun", "dnspod", "google", "cloudflare"}, &argparse.Options{ Help: "Use DoT Server for DNS Parse [dnssb, aliyun, dnspod, google, cloudflare]"}) @@ -206,6 +207,7 @@ func Excute() { AlwaysWaitRDNS: *alwaysRdns, IPGeoSource: ipgeo.GetSource(*dataOrigin), Timeout: time.Duration(*timeout) * time.Second, + PktSize: *packetSize, } if !*tablePrint { diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 6e5d288..4cee098 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -1,6 +1,7 @@ package trace import ( + "bytes" "encoding/binary" "errors" "fmt" @@ -252,8 +253,9 @@ func (t *ICMPTracer) send(ttl int) error { icmpHeader := icmp.Message{ Type: ipv4.ICMPTypeEcho, Code: 0, Body: &icmp.Echo{ - ID: id, - Data: []byte("HELLO-R-U-THERE"), + ID: id, + //Data: []byte("HELLO-R-U-THERE"), + Data: bytes.Repeat([]byte{1}, t.Config.PktSize), Seq: ttl, }, } diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index 8454e91..90979b6 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -1,6 +1,7 @@ package trace import ( + "bytes" "encoding/binary" "log" "net" @@ -249,8 +250,9 @@ func (t *ICMPTracerv6) send(ttl int) error { icmpHeader := icmp.Message{ Type: ipv6.ICMPTypeEchoRequest, Code: 0, Body: &icmp.Echo{ - ID: id, - Data: []byte("HELLO-R-U-THERE"), + ID: id, + //Data: []byte("HELLO-R-U-THERE"), + Data: bytes.Repeat([]byte{1}, t.Config.PktSize), Seq: ttl, }, } diff --git a/trace/tcp_ipv4.go b/trace/tcp_ipv4.go index e1f386f..8329e97 100644 --- a/trace/tcp_ipv4.go +++ b/trace/tcp_ipv4.go @@ -233,6 +233,11 @@ func (t *TCPTracer) send(ttl int) error { ComputeChecksums: true, FixLengths: true, } + + desiredPayloadSize := t.Config.PktSize + payload := make([]byte, desiredPayloadSize) + copy(buf.Bytes(), payload) + if err := gopacket.SerializeLayers(buf, opts, tcpHeader); err != nil { return err } diff --git a/trace/tcp_ipv6.go b/trace/tcp_ipv6.go index c0b2686..27deb3e 100644 --- a/trace/tcp_ipv6.go +++ b/trace/tcp_ipv6.go @@ -223,6 +223,11 @@ func (t *TCPTracerv6) send(ttl int) error { ComputeChecksums: true, FixLengths: true, } + + desiredPayloadSize := t.Config.PktSize + payload := make([]byte, desiredPayloadSize) + copy(buf.Bytes(), payload) + if err := gopacket.SerializeLayers(buf, opts, tcpHeader); err != nil { return err } diff --git a/trace/trace.go b/trace/trace.go index 8f97c0a..aca0f68 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -34,6 +34,7 @@ type Config struct { DN42 bool RealtimePrinter func(res *Result, ttl int) AsyncPrinter func(res *Result) + PktSize int } type Method string diff --git a/trace/udp.go b/trace/udp.go index 6277466..1385fbc 100644 --- a/trace/udp.go +++ b/trace/udp.go @@ -188,7 +188,12 @@ func (t *UDPTracer) send(ttl int) error { ComputeChecksums: true, FixLengths: true, } - if err := gopacket.SerializeLayers(buf, opts, udpHeader, gopacket.Payload("HAJSFJHKAJSHFKJHAJKFHKASHKFHHKAFKHFAHSJK")); err != nil { + + desiredPayloadSize := t.Config.PktSize + payload := make([]byte, desiredPayloadSize) + copy(buf.Bytes(), payload) + + if err := gopacket.SerializeLayers(buf, opts, udpHeader); err != nil { return err }