Skip to content

Commit

Permalink
removed the fanout logic on packethandler workers
Browse files Browse the repository at this point in the history
  • Loading branch information
mosajjal committed Jan 12, 2022
1 parent 9bdfa6a commit 0d56aaf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions capture/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ func (encoder *packetEncoder) run() {
)
foundLayerTypes := []gopacket.LayerType{}

var handlerChanList []chan rawPacketBytes
handlerChannel := make(chan rawPacketBytes) //todo: test this with a sized channel to see if it makes a difference
for i := 0; i < int(encoder.handlerCount); i++ {
log.Infof("Creating handler #%d", i)
handlerChanList = append(handlerChanList, make(chan rawPacketBytes, 10000)) //todo: parameter for size of this channel needs to be defined as a flag
go encoder.inputHandlerWorker(handlerChanList[i])
go encoder.inputHandlerWorker(handlerChannel)
}

for {
Expand Down Expand Up @@ -179,7 +178,7 @@ func (encoder *packetEncoder) run() {
}
encoder.processTransport(&foundLayerTypes, &udp, &tcp, packet.ip.NetworkFlow(), packet.timestamp, 6, packet.ip.SrcIP, packet.ip.DstIP)
case packet := <-encoder.input:
handlerChanList[rand.Intn(int(encoder.handlerCount))] <- packet
handlerChannel <- packet
}
}
}

0 comments on commit 0d56aaf

Please sign in to comment.