I have application that using PcapDotNet
DLLs and send packets.
In some Pcap
files with high speed rate (~50 Mbit/Sec or ~9000 Packet per seconds) the play takes long time compare to the original Pcap
length\duration and I can see that ~25% of my CPUs (i have 4 cores) are utilized.
I have asked this question in the project page and the developer suggest I parallel my program so I can better utilize my resources because this is single thread program.
This is example of my function that sends the packets and it does the most pf the work, this function also include several events
like report how many packets sent etc... (not include in mt example)
So my question is, assuming that the function is the one that does the most work How can I divide my CPU resources in a better way?
using (PacketSendBuffer sendBuffer = new PacketSendBuffer((uint)capLength))
{
while (inputCommunicator.ReceivePacket(out packet) == PacketCommunicatorReceiveResult.Ok) // Read the packets from the file
{
if (packet != null)
{
try
{
_outputCommunicator.SendPacket(packet); // Send the Packets
_sentPackets++;
}
catch (Exception ex)
{
// Throw exception
}
}
}
}