add: 新增起始TTL参数

This commit is contained in:
sjlleo
2022-06-10 21:20:43 +08:00
parent 9df6c2f23c
commit 1789448d6c
6 changed files with 7 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) {
fmt.Printf("traceroute to %s, 30 hops max, 32 byte packets\n", ispCollection.IP)
ip := net.ParseIP(ispCollection.IP)
var conf = trace.Config{
BeginHop: 1,
DestIP: ip,
DestPort: 80,
MaxHops: 30,

View File

@@ -29,6 +29,7 @@ var dataOrigin = fSet.String("d", "LeoMoeAPI", "Choose IP Geograph Data Provider
var noRdns = fSet.Bool("n", false, "Disable IP Reverse DNS lookup")
var routePath = fSet.Bool("report", false, "Route Path")
var tablePrint = fSet.Bool("table", false, "Output trace results as table")
var beginHop = fSet.Int("b", 1, "Set The Begin TTL")
var ver = fSet.Bool("V", false, "Print Version")
func printArgHelp() {
@@ -105,6 +106,7 @@ func main() {
}
var conf = trace.Config{
BeginHop: *beginHop,
DestIP: ip,
DestPort: *port,
MaxHops: *maxHops,

View File

@@ -45,7 +45,7 @@ func (t *ICMPTracer) Execute() (*Result, error) {
go t.listenICMP()
for ttl := 1; ttl <= t.MaxHops; ttl++ {
for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ {
if t.final != -1 && ttl > t.final {
break
}

View File

@@ -44,7 +44,7 @@ func (t *ICMPTracerv6) Execute() (*Result, error) {
go t.listenICMP()
for ttl := 1; ttl <= t.MaxHops; ttl++ {
for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ {
if t.final != -1 && ttl > t.final {
break
}

View File

@@ -63,7 +63,7 @@ func (t *TCPTracer) Execute() (*Result, error) {
t.sem = semaphore.NewWeighted(int64(t.ParallelRequests))
for ttl := 1; ttl <= t.MaxHops; ttl++ {
for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ {
// 如果到达最终跳,则退出
if t.final != -1 && ttl > t.final {
break

View File

@@ -16,6 +16,7 @@ var (
)
type Config struct {
BeginHop int
MaxHops int
NumMeasurements int
ParallelRequests int