Insert late packets into corresponding path Fixes the scenario in which packets arrive after traceRoute finished
(routes []*PathInfo)
| 152 | // Insert late packets into corresponding path |
| 153 | // Fixes the scenario in which packets arrive after traceRoute finished |
| 154 | func (s *Sender) popAllQueue(routes []*PathInfo) { |
| 155 | for i := 0; i < len(routes); i++ { |
| 156 | for len(s.inputQueue[i]) > 0 { |
| 157 | sw := <-s.inputQueue[i] |
| 158 | if routes[sw.routeIdx] == nil { |
| 159 | continue |
| 160 | } |
| 161 | routes[sw.routeIdx].switches = append(routes[sw.routeIdx].switches, *sw) |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func sortSwitchesByHop(swArray []SwitchTrafficInfo) { |
| 167 | sort.Slice(swArray, func(i, j int) bool { |
no outgoing calls