| 검색 | ?

1.1. Windows에서 IPv4IPv6를 하나의 Socket으로 처리하기 위한 방법에 대한 내용

Linux에서는 예전부터 IPV6_V6ONLY socket option을 제공해왔었고 이 속성의 기본값이 0으로 되어 있었기에 별로 신경쓰지 않고도 IPv4IPv6를 동시지원하는 프로그램을 작성할수 있었다.

간혹 xinetd 의 경우는 accept후에 IPv6로 강제하는 경우가 있기는 한데 성능상 얼마나 좋을지는 의문이 간다.

그런데 이것을 Windows에서 사용하려면 몇가지 역사와 Microsoft의 의도를 파악해야 할것 같다.

우선 MSDN online 에서 IPV6_V6ONLY에 대한 언급을 잠깐 인용해보자.
Indicates if a socket created for the AF_INET6 address family is restricted to IPv6 communications only.
Sockets created for the AF_INET6 address family may be used for both IPv6 and IPv4 communications.
Some applications may want to restrict their use of a socket created for the AF_INET6 address family to IPv6 communications only.
When this value is non-zero (the default on Windows), a socket created for the AF_INET6 address family can be used to send and receive IPv6 packets only.

When this value is zero, a socket created for the AF_INET6 address family can be used to send and receive packets to and from an IPv6 address or an IPv4 address.
Note that the ability to interact with an IPv4 address requires the use of IPv4 mapped addresses.

This socket option is supported on Windows Vista or later.


위에서 중요한 부분은 파란색으로 표시한 부분인데 기본값이 0이 아닌 값이라는 점이다. 즉, 0이 아니라는 이야기는 AF_INET6로 생성한 소켓은 IPv4를 처리할수 없도록 강제한다는 점이다.

나는 여기까지 보고서 별 문제 없다고 생각했다. 그냥 그것을 0으로 설정하면 되는줄로만 알았다.

헉! 근데 왠걸! VisualStudio C++ 2003 에서는 IPV6_V6ONLY define이 아예 없다.

그래서 다시 위의 MSDN online문서를 보니 밑줄친 부분에 명시된것처럼 IPV6_V6ONLY옵션은 Windows Vista 이상에서만 지원된다고 한다.

어떤이는 "그냥 Windows Vista 쓰면 되지!" 라고 하는이도 있을것이다.

하지만 그건 돈이 많거나 암흑의 경로로 윈도우를 쓰는 경우에 해당하는 분들일것이다.

틀린말은 아니다. 그냥 Windows Vista 나 Windows Server 2008 구입해서 사용하면 되기는 한다.

하지만 고객은 최소한의 비용으로 최대의 효과를 원하는게 당연하고 프로그래머도 불가능하다고 결론된것이 아니면 더 찾아봐야 하는게 도리라고 생각한다.

더 찾아보자......
Dual-Stack Sockets
In order to support both IPv4 and IPv6 on Windows XP Service Pack 1 (SP1) and on Windows Server 2003, an application has to create two sockets, one socket for use with IPv4 and one socket for use with IPv6.
These two sockets must be handled separately by the application.

Windows Vista and later offer the ability to create a single IPv6 socket which can handle both IPv6 and IPv4 traffic.
For example, a TCP listening socket for IPv6 is created, put into dual stack mode, and bound to port 5001.
This dual-stack socket can accept connections from IPv6 TCP clients connecting to port 5001 and from IPv4 TCP clients connecting to port 5001.
This feature allows for greatly simplified application design and reduces the resource overhead required of posting operations on two separate sockets.


MSDN online에서 위와 같은 구문을 쉽게 찾을수 있었다.

간략히 요약한다면 IPv6를 지원하는것은 Windows XP Service Pack 1과 Windows Server 2003 부터라는 예기다.

하지만 Windows Vista이후에서만 하나의 단일 소켓으로 IPv4IPv6를 처리할수 있도록 하는 옵션인 IPV6_V6ONLY가 존재하며 그 이전의 운영체제 버젼에서는 IPv6를 지원한다고만 했지 단일 소켓에서 IPv4IPv6를 지원하는것은 아니라고 한다.

결국 WindowsXPSP1과 WindowsServer2003에서는 단일소켓으로 처리할수 없기 때문에 IPv4용과 IPv6용 소켓을 따로 생성하며 응용프로그램에서 잘 설계해서 구현하는 방법을 제시했다.

그리고 성능상 그것이 유리할수도 있다는 식의 억양이 느껴진다.

말이 쉽지 단일소켓으로 이미 오래전에 구현되었던 것을 그렇게 구현하려면 골치좀 아플거란것은 겪어볼 사람이라면 스트레스 지수에서 나타난다. 어쩄건 불가능한것은 아니다.

고객들은 아직 Windows Server 2008, Windows Vista를 단순히 IPv6지원하려고 구매하기에는 설득되지 않는다.

그리고 strcpy함수도 그냥 쓰게 냅두지 strcpy_s 로 강제하는것도 맘에 안드는 Microsoft다운 처사다.

개발자로서 Microsoft의 개발 Framework이 은근히 짜증나는것은 나만 그럴까?


Copyright ⓒ MINZKN.COM
All Rights Reserved.