1. secnetperf使用

1.1 help text

  1. help
  2. ./secnetperf -?
  3. secnetperf usage:
  4. Server: secnetperf [options]
  5. -bind:<addr> A local IP address to bind to.
  6. Client: secnetperf -TestName:<Throughput|RPS|HPS> [options]
  7. tput
  8. ./secnetperf -test:tput
  9. Must specify '-target' argument!
  10. Throughput Client options:
  11. -target:<####> The target server to connect to.
  12. -bind:<addr> A local IP address to bind to.
  13. -port:<####> The UDP port of the server. (def:4433)
  14. -ip:<0/4/6> A hint for the resolving the hostname to an IP address. (def:0)
  15. -encrypt:<0/1> Enables/disables encryption. (def:1)
  16. -sendbuf:<0/1> Whether to use send buffering. (def:0)
  17. -pacing:<0/1> Whether to use pacing. (def:1)
  18. -timed:<0/1> Indicates the upload/download arg time (ms). (def:0)
  19. -upload:<####> The length of data (or time with -timed:1 arg) to send. (def:0)
  20. -download:<####> The length of data (or time with -timed:1 arg) to request/receive. (def:0)
  21. -iosize:<####> The size of each send request queued. (def:65536)
  22. -tcp:<0/1> Indicates TCP/TLS should be used instead of QUIC. (def:0)
  23. -stats:<0/1> Indicates connection stats should be printed at the end of the run. (def:0)
  24. rps
  25. ./secnetperf -test:rps
  26. Must specify '-target' argument!
  27. RPS Client options:
  28. -target:<####> The target server to connect to.
  29. -runtime:<####> The total runtime (in ms). (def:10000)
  30. -port:<####> The UDP port of the server. (def:4433)
  31. -ip:<0/4/6> A hint for the resolving the hostname to an IP address. (def:0)
  32. -conns:<####> The number of connections to use. (def:1000)
  33. -requests:<####> The number of requests to send at a time. (def:2*conns)
  34. -request:<####> The length of request payloads. (def:0)
  35. -response:<####> The length of request payloads. (def:0)
  36. -threads:<####> The number of threads to use. Defaults and capped to number of cores
  37. -affinitize:<0/1> Affinitizes threads to a core. (def:0)

1.2 server

  1. # 启动服务器
  2. ./secnetperf

1.3 client

  1. # 发送1G字节流报文,每次1300字节
  2. ./secnetperf -test:tput -target:10.0.32.139 -upload:1000000000 -iosize:1300 -stats:1
  3. Started!
  4. Result: 999848200 bytes @ 883695 kbps (9051.517 ms).
  5. App Main returning status 0

2. secnetperf调用栈

2.1 server

总计开启线程 cpu*6 + 1

2.1.1 data path

  1. 开启cpu个数线程
  2. CxPlatDataPathInitialize
  3. #0 QuicMainStart (argc=0, argc@entry=1, argv=0x308afc8, argv@entry=0x308afc0, StopEvent=StopEvent@entry=0x7fffffffde70, SelfSignedCredConfig=SelfSignedCredConfig@entry=0x308afe0) at /root/source/msquic/src/perf/lib/SecNetPerfMain.cpp:131
  4. #1 0x0000000000404649 in QuicUserMain (argc=argc@entry=1, argv=argv@entry=0x308afc0, KeyboardWait=KeyboardWait@entry=false, SelfSignedCredConfig=SelfSignedCredConfig@entry=0x308afe0, FileName=FileName@entry=0x0) at /root/source/msquic/src/perf/bin/appmain.cpp:116
  5. #2 0x0000000000404ace in main (argc=1, argv=0x7fffffffe038) at /root/source/msquic/src/perf/bin/appmain.cpp:448

2.1.2 open

  1. 开启cpu个数线程
  2. MsQuic = new(std::nothrow) MsQuicApi
  3. #0 CxPlatThreadCreate -> CxPlatDataPathWorkerThread (epoll_wait)
  4. #1 CxPlatProcessorContextInitialize (Datapath=Datapath@entry=0x605560, Index=Index@entry=0, ProcContext=ProcContext@entry=0x605600) at /root/source/msquic/src/platform/datapath_epoll.c:608
  5. #2 0x00007ffff7961b57 in CxPlatDataPathInitialize (ClientRecvContextLength=ClientRecvContextLength@entry=48, UdpCallbacks=UdpCallbacks@entry=0x7fffffffddd0, TcpCallbacks=TcpCallbacks@entry=0x0, NewDataPath=NewDataPath@entry=0x7ffff7dc97e0 <MsQuicLib+320>) at /root/source/msquic/src/platform/datapath_epoll.c:701
  6. #3 0x00007ffff7925c9a in MsQuicLibraryInitialize () at /root/source/msquic/src/core/library.c:393
  7. #4 0x00007ffff7926271 in MsQuicAddRef () at /root/source/msquic/src/core/library.c:598
  8. #5 0x00007ffff79262ca in MsQuicOpen (QuicApi=QuicApi@entry=0x603080 <MsQuic>) at /root/source/msquic/src/core/library.c:1325
  9. #6 0x00007ffff79264b9 in MsQuicOpenVersion (Version=Version@entry=1, QuicApi=QuicApi@entry=0x603080 <MsQuic>) at /root/source/msquic/src/core/library.c:1405

2.1.3 new server

  1. 开启cpu*3个数线程 = data path(cpu个数) + quic worker(cpu个数) + tcp worker(cpu个数)
  2. TestToRun = new(std::nothrow) PerfServer(SelfSignedCredConfig)
  3. TcpEngine::TcpEngine
  4. 1. CxPlatDataPathInitialize
  5. 2. MsQuicRegistrationOpen (构造函数中调用)
  6. 3. TcpWorker::Initialize
  7. #0 0x00007ffff66bedb5 in clone () from /lib64/libc.so.6
  8. #1 0x00007ffff698e00f in create_thread () from /lib64/libpthread.so.0
  9. #2 0x00007ffff698f9c6 in pthread_create@@GLIBC_2.2.5 () from /lib64/libpthread.so.0
  10. #3 0x00007ffff795cd9c in CxPlatThreadCreate (Config=0x7fffffffdc30, Thread=0x30f3190) at /root/source/msquic/src/platform/platform_posix.c:583
  11. #4 0x00007ffff792d9e5 in QuicWorkerInitialize (Owner=Owner@entry=0x30f28f0, ThreadFlags=ThreadFlags@entry=0, IdealProcessor=IdealProcessor@entry=1, Worker=Worker@entry=0x30f3100) at /root/source/msquic/src/core/worker.c:83
  12. #5 0x00007ffff792f041 in QuicWorkerPoolInitialize (Owner=Owner@entry=0x30f28f0, ThreadFlags=0, WorkerCount=4, NewWorkerPool=0x30f2928) at /root/source/msquic/src/core/worker.c:783
  13. #6 0x00007ffff79255c6 in MsQuicRegistrationOpen (Config=0x7fffffffdda0, NewRegistration=0x308c848) at /root/source/msquic/src/core/registration.c:120
  14. #7 0x000000000040686c in MsQuicRegistration::MsQuicRegistration (AutoCleanUp=true, Profile=QUIC_EXECUTION_PROFILE_LOW_LATENCY, AppName=0x5b74e8 "secnetperf-server", this=0x308c840) at /root/source/msquic/src/inc/msquic.hpp:316
  15. #8 PerfServer::PerfServer (CredConfig=0x308afe0, this=0x308c830) at /root/source/msquic/src/perf/lib/PerfServer.h:23
  16. #9 QuicMainStart (argc=0, argc@entry=1, argv=0x308afc8, argv@entry=0x308afc0, StopEvent=StopEvent@entry=0x7fffffffde70, SelfSignedCredConfig=SelfSignedCredConfig@entry=0x308afe0) at /root/source/msquic/src/perf/lib/SecNetPerfMain.cpp:176
  17. #10 0x0000000000404649 in QuicUserMain (argc=argc@entry=1, argv=argv@entry=0x308afc0, KeyboardWait=KeyboardWait@entry=false, SelfSignedCredConfig=SelfSignedCredConfig@entry=0x308afe0, FileName=FileName@entry=0x0) at /root/source/msquic/src/perf/bin/appmain.cpp:116
  18. #11 0x0000000000404ace in main (argc=1, argv=0x7fffffffe038) at /root/source/msquic/src/perf/bin/appmain.cpp:448

2.1.4 listener

  1. 开启cpu个数线程 = quic worker(cpu个数)
  2. #0 CxPlatThreadCreate -> QuicWorkerThread
  3. #1 QuicWorkerInitialize (Owner=Owner@entry=0x62af20, ThreadFlags=ThreadFlags@entry=0, IdealProcessor=IdealProcessor@entry=2, Worker=Worker@entry=0x6edb70) at /root/source/msquic/src/core/worker.c:83
  4. #2 0x00007ffff7932041 in QuicWorkerPoolInitialize (Owner=Owner@entry=0x62af20, ThreadFlags=0, WorkerCount=4, NewWorkerPool=0x62af58) at /root/source/msquic/src/core/worker.c:783
  5. #3 0x00007ffff79285c6 in MsQuicRegistrationOpen (Config=Config@entry=0x7fffffffdd70, NewRegistration=NewRegistration@entry=0x7ffff7dc9808 <MsQuicLib+360>) at /root/source/msquic/src/core/registration.c:120
  6. #4 0x00007ffff7925152 in QuicLibraryOnListenerRegistered (Listener=Listener@entry=0x6eb380) at /root/source/msquic/src/core/library.c:1778 (StatelessRegistration)
  7. #5 0x00007ffff7926b2c in MsQuicListenerStart (Handle=0x6eb380, AlpnBuffers=0x602d90 <Alpn>, AlpnBufferCount=1, LocalAddress=0x7fffffffde30) at /root/source/msquic/src/core/listener.c:256

2.2 client

总计开启线程 cpu*4 + 1

2.2.1 open

  1. 开启cpu个数线程
  2. MsQuic = new(std::nothrow) MsQuicApi
  3. #0 CxPlatThreadCreate -> CxPlatDataPathWorkerThread (epoll_wait)
  4. #1 CxPlatProcessorContextInitialize (Datapath=Datapath@entry=0x605560, Index=Index@entry=0, ProcContext=ProcContext@entry=0x605600) at /root/source/msquic/src/platform/datapath_epoll.c:608
  5. #2 0x00007ffff7961b57 in CxPlatDataPathInitialize (ClientRecvContextLength=ClientRecvContextLength@entry=48, UdpCallbacks=UdpCallbacks@entry=0x7fffffffddd0, TcpCallbacks=TcpCallbacks@entry=0x0, NewDataPath=NewDataPath@entry=0x7ffff7dc97e0 <MsQuicLib+320>) at /root/source/msquic/src/platform/datapath_epoll.c:701
  6. #3 0x00007ffff7925c9a in MsQuicLibraryInitialize () at /root/source/msquic/src/core/library.c:393
  7. #4 0x00007ffff7926271 in MsQuicAddRef () at /root/source/msquic/src/core/library.c:598
  8. #5 0x00007ffff79262ca in MsQuicOpen (QuicApi=QuicApi@entry=0x603080 <MsQuic>) at /root/source/msquic/src/core/library.c:1325
  9. #6 0x00007ffff79264b9 in MsQuicOpenVersion (Version=Version@entry=1, QuicApi=QuicApi@entry=0x603080 <MsQuic>) at /root/source/msquic/src/core/library.c:1405

2.2.2 new client

  1. 开启cpu*3个数线程 = data path(cpu个数) + quic worker(cpu个数) + tcp worker(cpu个数)
  2. TestToRun = new(std::nothrow) ThroughputClient;
  3. TcpEngine::TcpEngine
  4. 1. CxPlatDataPathInitialize
  5. 2. MsQuicRegistrationOpen (构造函数中调用)
  6. 3. TcpWorker::Initialize
  7. 同【2.1.3 new server】调用栈一样