xiangenmin

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • xiangenmin
    Participant

      Thank you

      xiangenmin
      Participant

        xiangenmin
        Participant

          With your team’s technical guidance, my C# application integrating your driver has successfully reduced CPU utilization and is running stably. However, under the current operational parameters (20Mbps uplink/30Mbps downlink), the CPU utilization rate remains between 5%-10%. Are there any additional optimization methods to further reduce the software’s CPU resource consumption?

          xiangenmin
          Participant

            Thank you

            if (eventIndex >= 0 && eventIndex < waitHandlesManualResetEvents.Count) { waitHandlesManualResetEvents[eventIndex].Reset(); }

             

            waitHandlesManualResetEvents[eventIndex]

             

            Array index out of bounds

            此处代码会出现数组索引越界

            xiangenmin
            Participant

              private static unsafe void PassThruUnsortedThread
              (
              NdisApi filter,
              WaitHandle[] waitHandles,
              IReadOnlyList<AutoResetEvent> waitHandlesManualResetEvents)
              {
              const int bufferSize = 32;

              var buffers = new IntPtr[bufferSize];
              for (int i = 0; i < buffers.Length; i++)
              {
              buffers[i] = (IntPtr)filter.CreateIntermediateBuffer();
              }

              while (true)
              {
              WaitHandle.WaitAny(waitHandles);
              uint packetsSuccess = 0;

              while (filter.ReadPacketsUnsorted(buffers, bufferSize, ref packetsSuccess))
              {
              for (int i = 0; i < packetsSuccess; i++)
              {
              EthernetPacket ethPacket = buffers[i].GetEthernetPacket(filter);
              if (ethPacket.PayloadPacket is IPv4Packet iPv4Packet)
              {
              if (iPv4Packet.PayloadPacket is TcpPacket tcpPacket)
              {
              //Console.WriteLine($”{iPv4Packet.SourceAddress}:{tcpPacket.SourcePort} -> {iPv4Packet.DestinationAddress}:{tcpPacket.DestinationPort}.”);
              }
              }
              }

              if (packetsSuccess > 0)
              {
              filter.SendPacketsUnsorted(buffers, packetsSuccess, out uint numPacketsSuccess);
              }
              }
              }
              }
              }

               

              The demo has high CPU usage

              c# 调用驱动的时候,16核心cpu 占用16%

            Viewing 5 posts - 1 through 5 (of 5 total)