Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)
(시리즈 글이 8개 있습니다.)
개발 환경 구성: 533. Wireshark + C#으로 확인하는 TCP 통신의 MSS(Maximum Segment Size) - 리눅스 환경
; https://www.sysnet.pe.kr/2/0/12527

개발 환경 구성: 534. Wireshark + C#으로 확인하는 TCP 통신의 MSS(Maximum Segment Size) - 윈도우 환경
; https://www.sysnet.pe.kr/2/0/12528

개발 환경 구성: 535. Wireshark + C#으로 확인하는 TCP 통신의 MIN RTO
; https://www.sysnet.pe.kr/2/0/12529

개발 환경 구성: 536. Wireshark + C#으로 확인하는 TCP 통신의 Receive Window
; https://www.sysnet.pe.kr/2/0/12530

개발 환경 구성: 538. Wireshark + C#으로 확인하는 ReceiveBufferSize(SO_RCVBUF), SendBufferSize(SO_SNDBUF)
; https://www.sysnet.pe.kr/2/0/12532

개발 환경 구성: 539. Wireshark + C/C++로 확인하는 TCP 연결에서의 shutdown 동작
; https://www.sysnet.pe.kr/2/0/12533

개발 환경 구성: 540. Wireshark + C/C++로 확인하는 TCP 연결에서의 closesocket 동작
; https://www.sysnet.pe.kr/2/0/12534

개발 환경 구성: 541.  Wireshark로 확인하는 LSO(Large Send Offload), RSC(Receive Segment Coalescing) 옵션
; https://www.sysnet.pe.kr/2/0/12535




Wireshark로 확인하는 LSO(Large Send Offload), RSC(Receive Segment Coalescing) 옵션

지난번에 윈도우 환경에서 MSS 패킷 테스트를 하면서,

Wireshark + C#으로 확인하는 TCP 통신의 MSS(Maximum Segment Size) - 윈도우 환경
; https://www.sysnet.pe.kr/2/0/12528#lso_option

가령, send(10KB)를 하면 다음과 같이 MSS=1460 크기를 (리눅스와는 달리) 무시하고,

// 3-way handshake
1   0.000000    ..client_ip...  ..server_ip...  TCP 66  2872 → 15000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1
2   0.004824    ..server_ip...  ..client_ip...  TCP 66  15000 → 2872 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=256 SACK_PERM=1
3   0.004898    ..client_ip...  ..server_ip...  TCP 54  2872 → 15000 [ACK] Seq=1 Ack=1 Win=262656 Len=0

// send(10KB)
4   1.722068    ..client_ip...  ..server_ip...  TCP 10294   2872 → 15000 [PSH, ACK] Seq=1 Ack=1 Win=262656 Len=10240
5   1.726845    ..server_ip...  ..client_ip...  TCP 60  15000 → 2872 [ACK] Seq=1 Ack=2921 Win=131328 Len=0
6   1.726845    ..server_ip...  ..client_ip...  TCP 60  15000 → 2872 [ACK] Seq=1 Ack=5841 Win=131328 Len=0
7   1.728553    ..server_ip...  ..client_ip...  TCP 60  15000 → 2872 [ACK] Seq=1 Ack=8761 Win=131328 Len=0
8   1.728553    ..server_ip...  ..client_ip...  TCP 60  15000 → 2872 [ACK] Seq=1 Ack=10241 Win=131328 Len=0

10KB 데이터를 통째로 하나의 패킷으로 캡처되는 것을 확인할 수 있었습니다. 원인이 뭘까 궁금해서 네트워크 어댑터의 옵션 창을 살펴봤더니 왠지 느낌이 오는 옵션이 하나 있습니다. ^^

rsc_network_setting_0.png

"Large Send Offload Version 2"라는 이름에서 벌써 신뢰를 주는데요, 설명을 보면 정확히 저 현상으로 해석이 됩니다.

LSO is a technology in which the work of segmenting data into network frames is performed by the network adapter instead of by the TCP/IP stack. With LSO, TCP/IP sends very large data packets down to the network adapter driver and the network adapter hardware. The network adapter separates the data into smaller network-sized frames.


즉, TCP/IP 스택을 구현한 device driver는 (MSS 단위로 분할하지 않은) 대형 TCP 패킷을 NIC 장치로 내려보낼 수 있다는 것으로, 따라서 NIC 장치가 MSS 단위로 분할해 송신하는 작업을 대행해 주기 때문에 CPU의 부담을 덜어줄 수 있는 기술입니다.

정말 그런지 테스트를 해봐야겠지요. ^^

이 옵션을 네트워크 속성 창에서 제어하는 것도 가능하지만 PowerShell을 이용할 수도 있습니다.

Enable-NetAdapterLso
; https://learn.microsoft.com/en-us/powershell/module/netadapter/enable-netadapterlso

Disable-NetAdapterLso
; https://learn.microsoft.com/en-us/powershell/module/netadapter/disable-netadapterlso

Get-NetAdapterLso
; https://learn.microsoft.com/en-us/powershell/module/netadapter/get-netadapterlso

따라서 다음과 같이 비활성화시키면,

PS C:\WINDOWS\system32> Get-NetAdapterLso -Name "*"

Name                           Version         V1IPv4Enabled  IPv4Enabled  IPv6Enabled
----                           -------         -------------  -----------  -----------
Ethernet                       LSO Version 2   False          True         True
vEthernet (MyTestHyperVsw)     LSO Version 2   False          True         True


PS C:\WINDOWS\system32> Disable-NetAdapterLso -Name "vEthernet (MyTestHyperVsw)"

PS C:\WINDOWS\system32> Get-NetAdapterLso -Name "*"

Name                           Version         V1IPv4Enabled  IPv4Enabled  IPv6Enabled
----                           -------         -------------  -----------  -----------
Ethernet                       LSO Version 2   False          True         True
vEthernet (MyTestHyperVsw)     LSO Version 2   False          False        False

잠깐 네트워크 연결이 리셋되고는, 이후 동일하게 send(10KB)하면 다음과 같이 MSS 단위로 보기 좋게 패킷이 캡처되는 것을 확인할 수 있습니다.

1   0.000000    ..client_ip...  ..server_ip...  TCP 66  2606 → 15000 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1
2   0.004987    ..server_ip...  ..client_ip...  TCP 66  15000 → 2606 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=256 SACK_PERM=1
3   0.005055    ..client_ip...  ..server_ip...  TCP 54  2606 → 15000 [ACK] Seq=1 Ack=1 Win=262656 Len=0

4   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=1 Ack=1 Win=262656 Len=1460
5   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=1461 Ack=1 Win=262656 Len=1460
6   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=2921 Ack=1 Win=262656 Len=1460
7   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=4381 Ack=1 Win=262656 Len=1460
8   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=5841 Ack=1 Win=262656 Len=1460
9   1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=7301 Ack=1 Win=262656 Len=1460
10  1.266381    ..client_ip...  ..server_ip...  TCP 1514    2606 → 15000 [ACK] Seq=8761 Ack=1 Win=262656 Len=1460
11  1.266381    ..client_ip...  ..server_ip...  TCP 74  2606 → 15000 [PSH, ACK] Seq=10221 Ack=1 Win=262656 Len=20
12  1.273309    ..server_ip...  ..client_ip...  TCP 60  15000 → 2606 [ACK] Seq=1 Ack=2921 Win=131328 Len=0
13  1.273309    ..server_ip...  ..client_ip...  TCP 60  15000 → 2606 [ACK] Seq=1 Ack=5841 Win=131328 Len=0
14  1.273309    ..server_ip...  ..client_ip...  TCP 60  15000 → 2606 [ACK] Seq=1 Ack=8761 Win=131328 Len=0
15  1.273309    ..server_ip...  ..client_ip...  TCP 60  15000 → 2606 [ACK] Seq=1 Ack=10241 Win=131328 Len=0

테스트가 끝나면 돌려놓는 것도 잊지 마시고. ^^

PS C:\WINDOWS\system32> Enable-NetAdapterLso -Name "vEthernet (MyTestHyperVsw)"

그러고 보니, 리눅스에서는 그냥 MSS 단위로 보냈던 것은 아마도 해당 PC가 구형이어서 그 시절의 NIC 카드에는 LSO 기능이 없어서 그런 것 같습니다.




기왕 시작했으니 네트워크 설정 창에 있는 다른 옵션도 살펴보겠습니다.

Receive Segment Coalescing (RSC)
; https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh997024(v=ws.11)

RSC in the vSwitch
; https://learn.microsoft.com/en-us/windows-server/networking/technologies/hpn/rsc-in-the-vswitch

rsc_network_setting_1.png

전송 시에 LSO가 있다면 수신 시에 RSC가 있는 듯한데요, 다음의 문서를 보면,

Windows 가상 시스템의 VMXNET3 어댑터에서 LRO 사용 또는 사용 안 함
; https://docs.vmware.com/kr/VMware-vSphere/7.0/com.vmware.vsphere.networking.doc/GUID-ECC80415-442C-44E9-BA7A-852DDB174B9F.html

다른 환경에서는 RSC라는 이름 대신 LRO라고 알려진 기술이라고 소개합니다. 실제로 설명을 보면, LSO의 대칭인 기술로 보입니다. ^^

Receive segment coalescing (RSC). RSC takes multiple packets received within the same interrupt period and combines the packets into a single large package to be processed by the network stack.


이 옵션도 Powershell로 제어 가능하고,

Get-NetAdapterRsc
; https://learn.microsoft.com/en-us/powershell/module/netadapter/get-netadapterrsc

Disable-NetAdapterRsc
; https://learn.microsoft.com/en-us/powershell/module/netadapter/disable-netadapterrsc

Enable-NetAdapterRsc
; https://learn.microsoft.com/en-us/powershell/module/netadapter/enable-netadapterrsc

(disable/enable은 네트워크가 리셋되니 유의하시고) 사용법은 LSO 제어와 옵션 설정 방식이 같습니다.

PS C:\WINDOWS\system32> Get-NetAdapterRsc -Name "*"

Name                           IPv4Enabled  IPv6Enabled  IPv4Operational IPv6Operational IPv4FailureReason IPv6FailureR
                                                         State           State                             eason
----                           -----------  -----------  --------------- --------------- ----------------- ------------
vEthernet (Default Switch)     True         True         True            True            NoFailure         NoFailure
vEthernet (MyTestHyperVsw)     True         True         True            True            NoFailure         NoFailure

기본값으로는 enable 상태인데, 실제로 테스트를 하면 wireshark에서 LSO처럼 합쳐진 패킷으로 안 보이고 MSS 단위로 개별 패킷이 캡처됩니다. 이상하군요, 약간의 짐작을 더해 보면 100%라고 말할 수는 없으나, 이 옵션의 활성 상태와 상관없이 해당 NIC 장치에서 이것을 지원해야만 하는 것으로 보입니다.

다음의 글을 보면,

Performance Tuning Windows 2012: Network Subsystem Part 1
; https://www.monitis.com/blog/performance-tuning-windows-2012-network-subsystempart-1/

RSC 관련 통계 값을 구하는 방법이 나오는데,

PS C:\WINDOWS\system32> $x = Get-NetAdapterStatistics  "vEthernet (MyTestHyperVsw)"
PS C:\WINDOWS\system32> $x.rscstatistics

CoalescedBytes       : 0
CoalescedPackets     : 0
CoalescingEvents     : 0
CoalescingExceptions : 0
PSComputerName       :

제 컴퓨터에서는 0으로만 나오고 있으므로 NIC 장치가 RSC를 지원하는 유형은 아닌 것 같습니다. 참고로, 윈도우에 hyper-v가 설치되어 있으면 그런 경우에도 RSC 지원이 호스트와 VM 머신 간에 달라지는 경우가 있다고 합니다.

If the host adapter is not bound to the virtual switch, RSC is supported on the physical host. If the adapter is bound to the virtual switch, Windows 2012 will disable RSC on the physical host. RSC can be enabled for a virtual machine when SR-IOV is enabled. In this case, virtual functions will support RSC capability; hence, virtual machines will also get the benefit of RSC.


아쉽지만 wireshark에서의 재현은 나중으로 미뤄야겠습니다. ^^




근래에는 CPU의 부하를 줄이기 위해 어떻게든 통신 부하를 NIC(Network Interface Controller)에 전가하는 offload 기능들이 나오고 있습니다. 아래의 문서에서 이에 대한 설명을 담고 있으며,

Performance in Network Adapters
; https://learn.microsoft.com/en-us/windows-hardware/drivers/network/performance-in-network-adapters

TCP/IP Offload Overview
; https://learn.microsoft.com/en-us/windows-hardware/drivers/network/tcp-ip-offload

TCP/IP Task Offload Overview
; https://learn.microsoft.com/en-us/windows-hardware/drivers/network/task-offload

리눅스의 경우 다음과 같은 명령어로 기능의 on/off를 확인할 수 있습니다.

$ ethtool -k eth0 | grep offload
tcp-segmentation-offload: on
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off
rx-vlan-offload: on [fixed]
tx-vlan-offload: on [fixed]
l2-fwd-offload: off [fixed]
hw-tc-offload: off [fixed]
esp-hw-offload: off [fixed]
esp-tx-csum-hw-offload: off [fixed]
rx-udp_tunnel-port-offload: off [fixed]
tls-hw-tx-offload: off [fixed]
tls-hw-rx-offload: off [fixed]
macsec-hw-offload: off [fixed]
hsr-tag-ins-offload: off [fixed]
hsr-tag-rm-offload: off [fixed]
hsr-fwd-offload: off [fixed]
hsr-dup-offload: off [fixed]




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 3/19/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  [7]  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13449정성태11/21/20232351개발 환경 구성: 688. Azure OpenAI 서비스 신청 방법
13448정성태11/20/20232627닷넷: 2163. .NET 8 - Dynamic PGO를 결합한 성능 향상파일 다운로드1
13447정성태11/16/20232487닷넷: 2162. ASP.NET Core 웹 사이트의 SSL 설정을 코드로 하는 방법
13446정성태11/16/20232419닷넷: 2161. .NET Conf 2023 - Day 1 Blazor 개요 정리
13445정성태11/15/20232699Linux: 62. 리눅스/WSL에서 CA 인증서를 저장하는 방법
13444정성태11/15/20232456닷넷: 2160. C# 12 - Experimental 특성 지원
13443정성태11/14/20232492개발 환경 구성: 687. OpenSSL로 생성한 사용자 인증서를 ASP.NET Core 웹 사이트에 적용하는 방법
13442정성태11/13/20232322개발 환경 구성: 686. 비주얼 스튜디오로 실행한 ASP.NET Core 사이트를 WSL 2 인스턴스에서 https로 접속하는 방법
13441정성태11/12/20232652닷넷: 2159. C# - ASP.NET Core 프로젝트에서 서버 Socket을 직접 생성하는 방법파일 다운로드1
13440정성태11/11/20232352Windows: 253. 소켓 Listen 시 방화벽의 Public/Private 제어 기능이 비활성화된 경우
13439정성태11/10/20232844닷넷: 2158. C# - 소켓 포트를 미리 시스템에 등록/예약해 사용하는 방법(Port Exclusion Ranges)파일 다운로드1
13438정성태11/9/20232462닷넷: 2157. C# - WinRT 기능을 이용해 윈도우에서 실행 중인 Media App 제어
13437정성태11/8/20232656닷넷: 2156. .NET 7 이상의 콘솔 프로그램을 (dockerfile 없이) 로컬 docker에 배포하는 방법
13436정성태11/7/20232893닷넷: 2155. C# - .NET 8 런타임부터 (Reflection 없이) 특성을 이용해 public이 아닌 멤버 호출 가능
13435정성태11/6/20232829닷넷: 2154. C# - 네이티브 자원을 포함한 관리 개체(예: 스레드)의 GC 정리
13434정성태11/1/20232631스크립트: 62. 파이썬 - class의 정적 함수를 동적으로 교체
13433정성태11/1/20232357스크립트: 61. 파이썬 - 함수 오버로딩 미지원
13432정성태10/31/20232406오류 유형: 878. 탐색기의 WSL 디렉터리 접근 시 "Attempt to access invalid address." 오류 발생
13431정성태10/31/20232720스크립트: 60. 파이썬 - 비동기 FastAPI 앱을 gunicorn으로 호스팅
13430정성태10/30/20232612닷넷: 2153. C# - 사용자가 빌드한 ICU dll 파일을 사용하는 방법
13429정성태10/27/20232871닷넷: 2152. Win32 Interop - C/C++ DLL로부터 이중 포인터 버퍼를 C#으로 받는 예제파일 다운로드1
13428정성태10/25/20232923닷넷: 2151. C# 12 - ref readonly 매개변수
13427정성태10/18/20233101닷넷: 2150. C# 12 - 정적 문맥에서 인스턴스 멤버에 대한 nameof 접근 허용(Allow nameof to always access instance members from static context)
13426정성태10/13/20233283스크립트: 59. 파이썬 - 비동기 호출 함수(run_until_complete, run_in_executor, create_task, run_in_threadpool)
13425정성태10/11/20233099닷넷: 2149. C# - PLinq의 Partitioner<T>를 이용한 사용자 정의 분할파일 다운로드1
13423정성태10/6/20233078스크립트: 58. 파이썬 - async/await 기본 사용법
1  2  3  4  5  6  [7]  8  9  10  11  12  13  14  15  ...