in cmd/ziffy/node/sender.go [63:112]
func (s *Sender) Start() ([]PathInfo, error) {
icmpAddr, err := net.ResolveIPAddr("ip6:ipv6-icmp", "")
if err != nil {
return nil, fmt.Errorf("unable to resolve source address: %w", err)
}
icmpConn, err := net.ListenIP("ip6:ipv6-icmp", icmpAddr)
if err != nil {
return nil, fmt.Errorf("unable to listen to icmp: %w", err)
}
defer icmpConn.Close()
if s.rackSwHostname, err = rackSwHostnameMonitor(s.Config.Device, s.Config.LLDPWaitTime); err != nil {
log.Warn("unable to learn name of rack switch via LLDP")
}
s.inputQueue = make(chan *SwitchTrafficInfo, s.Config.QueueCap)
s.icmpDone = make(chan bool)
s.icmpConn = icmpConn
s.currentRoute = 0
go s.monitorIcmp(s.icmpConn)
log.Infof("sending %v flows of PTP %v packets to %v from source port range %v-%v with max hop count of %v and min hop count of %v and "+
"sweeping %v other addresses in target network prefix with a per hop timeout of %v. Total flows %v.\n\n",
s.Config.PortCount, s.Config.MessageType, s.Config.DestinationAddress,
s.Config.SourcePort, s.Config.SourcePort+s.Config.PortCount-1, s.Config.HopMax, s.Config.HopMin, s.Config.IPCount, s.Config.IcmpTimeout,
s.Config.PortCount+s.Config.PortCount*s.Config.IPCount)
for i := 0; i < s.Config.PortCount; i++ {
s.routes = append(s.routes, PathInfo{switches: nil, rackSwHostname: s.rackSwHostname})
_, err := s.traceRoute(s.Config.DestinationAddress, s.Config.SourcePort+i, false)
if err != nil {
log.Errorf("traceRoute failed: %v", err)
continue
}
s.currentRoute++
s.popAllQueue()
}
if s.Config.IPCount != 0 {
s.sweepRackPrefix()
}
// Waiting for late packets, if any
time.Sleep(s.Config.IcmpReplyTime)
s.popAllQueue()
s.icmpDone <- true
return s.clearPaths(), nil
}