ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
IPv6 ??? ?? ?????



    ???? ?????? ???
        ?? ?????
             ???
      MS Visual C++ MVP
      Twitter : @jacking75
??
? IPv6 ?? ??

? IPv6 ?? ?????
IPv6 ?? ??
IPv6 ???

? IPv6 ?? ¡®Internet Protocol Version 6¡¯? ?? ?.

? ?? ???? ?? ?? IPv4 ??.

? ?? ?? ?? ?? ???? IPv6 ??? ?? ??.

? ??? ??? ?? ??? ???? IPv6 ???(??)? ???? ??.
OSI 7 Layer? TCP/IP??? IPv6? ??




          ??: http://isecure-public.blogspot.com/2009/07/osi-7-layer-tcpip-suite.html
? IPv6? ???? ???

? ??
 - IPv4? ??? ? ?? IP? ???.
  - IPv4?? 42? ?? IP? ??? ? ??
  - ??? ???? ?? NAT? ????? ?
 - 2011? 2?3?? ?? ?? ?? ??.
? IPv6? ???? ???

? ??
 - ???? ?? ????? IP? ??? ? ??
 - 128bit ?? ??
 - 340282366920938463463374607431768211456?
 ?? ??? ? ??
? IPv6? ???? ???

? ??
    IPv4? ??? ?? ?? ?? ???? ?? ??? ?? ?? ???
    ? ??.

?   ??
    - IPv6? ?? ??? 40byte? IPv4? ? ?? ???? ????? ?
    ?? ???

? IP ?? ?? ??. DHCP ???

? ???? ???? QoS ??
IPv4? IPv6? ?? ??




    ?? : Joinc http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Intro
IPv6? ???? ?? ??? ?


? OS
 - Windows XP, Windows Server 2003 ?? ??
   - ??? ??? Windows Vista, Windows Server 2008 ??

 - Mac OS? 10.2(Jaguar)?? ??

 - Linux? FreeBSD? USAGI? THAI ?????? IPv6 ?? ???? ??
 ? ??????? ??? ???? ??.
IPv6? ???? ?? ??? ?

? ????
 - ??? ??? ?? ???2?? ???? ??? IPv6? ?? ??.
 - ???, ??? 3 ???? ???? ????? IPv6? ???? ??.




   I-O Data WN-GDN/RS Wi-Fi g/n Router   Cisco Catalyst 3750-E Series Switch
IPv6? ???? ?? ??? ?

? ?? ???? ??
 - ??? ??? IPv4? ?? ???? ??? IPv4? IPv6 ? ? ??? ?
 ?? Dual Stack?? ???? ??.
 - Windows Vista??? IPv6 ??? ?? ???? ???? IPv4? ???
 ?.




   ?? : http://www.dbguide.net/knowledge.db?cmd=view&boardUid=126274&boardConfigUid=19&boardStep=0
Dual Stack???

? IPv4? IPv6 ?? ??? ???? ?? ???.
  - ??? ?? IPv4?? IPv6 ???? ? ??
  - ???? OS?? ???? ??
??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6? ?? ?? ?

? IPv6 ?? ??? ???? ?? ???? ???? 1996?? ?? ???
  ? 6Bone ??.

? 1998? 10??? 6REN(IPv6 Research and Education Networks Initiative)
  ??.

? ??(ÃÀÜŠ)??? GIG(Global Information Grid)?? ?? ?? ??? ??
  ???? ?? ???? ??? 2003? 6?? IPv6?? ??? ??. 2008
  ??? ????? IPv6 ???? ??.

? 2003? ?? ??? ???? ???? ??? ?? IPv6 ??? ????.

? ??? ?? ?? ?? ???? ???? IPv6 ???? ???? ??.
IPv6 Address(??)

? IPv4? ?? ??? 32??, IPv6? ?? ??? 128??


? IPv4? ??? 10??? 0~255 ??? ??? ??
  IPv6? ??? 16??? ???? ?? ?? 8?.
  ?? ??? ¡®:¡¯ ??
  fe80:1234:5678:9abc:def0:1234
  ??? ???? ??? ? ?? ?? ??? 0000¡«ffff
IPv6 ?? ?? ?? ? ¨C ?? 1

- 0 ??
- ??? ? ??? 0 ?? ???? ??? ??? ? ??.




      f0f0:0100:0020:0003:1000:0100:0020:0003



            f0f0:100:20:3:1000:100:20:3
IPv6 ?? ?? ?? ? ¨C ?? 2

- 0 ??. ?? 0?? ?? ??? ????.

           1234:5678:0000:9abc:def0:1234:5678:9abc

              1234:5678::9abc:def0:1234:5678:9abc

- ???? ??? ???? :? ???? ?? ::

           1234:0000:0000:0000:5678:9abc:def0:1234

                     1234::5678:9abc:def0:1234

- ??? ??? ???? ??? ??
 1234:0000:0000:5678:9abc:0000:0000:def0 -> 1234::5678:9abc::def0
                                         -> 1234::5678:9abc:0:0:def0
IPv6 ?? ?? ?? ? ¨C ?? 2

? ¡®0¡¯ ?? ??
  - ??? ¡®::¡¯ ??? ¡®0000¡¯?? ?? ???? ?? ??? ??? ? ??.

 - ??
   - (8 - ?? ?? IPv6 ?? ?? ?)¡Á16
   - ¡®ff02::2¡¯ -> (8-2)¡Á16 = 96. (16X6=96)??? 6 ??? ¡®0000¡¯? ??


                            ff02::2


         ff02:0000:0000:0000:0000:0000:0000:0002
?? : http://blog.daum.net/ipv6/30
LINKLOCAL ??

? IPv4??? APIPA? ???? DHCP ???? IP ??? ?? ? ?? ? ?
  ??? LINKLOCAL ??? ????.
  - 169.254.*.*/16 ???? IP ??? ???? ?? ??

? IPV6??? ?? ???? ???? ??.
  - fe80::/64 ??? ????.
??(?? ??) ??

? LINKLOCAL ?? ???? ?? ??? ??? ??
  MAC ??? LAN ???? ??? ?? ? ??? ???? IPv6 ??? ?
  ???? ID? ????? ?? ?? ? ???? ?? ??? ? ?? ??




           ??: http://journal.mycom.co.jp/photo/series/ipv6/006/images/001l.jpg
IPv6? ??? ??

? 0:0:0:0:0:0:0:0
  - ? ?? ??. ??? ¡®0::0¡¯?? ¡®::¡¯?? ??
  - ??? ??? ???? ?? ??, ?? ? ?? ??? ???

? 0:0:0:0:0:0:0:1
  - ??? ??. IPv4? 127.0.0.1? ??
  - IPv4??? 12.0.0.0/8 ??? ??? ??? ? ??? IPv6??? ?
  ??? ??? ? ??
  - ??? ¡®0::1¡¯ ?? ¡®::1¡¯

? 2001:db8::/32
  - ?? ??? ?? ??

? 2001: ? ???? ?(sTLA ??)
  - ?? ???? ???? ?? ??

? 2002:: ? ???? ?(6to4 ??)
  - IPv6 over IPv4 ???? 6to4?? ???? ??. 2002: ? ????
  32?? ??? IPv4 ??? ??? ???. IPv6? ???? ?? ISP?
  ?? ?? ????
IPv6? ??? ??

? 3ffe: ? ???? ?(pTLA ??)
  - ? ?? ?? ?????? ?? ?? ?? ??

? ff00::/8 ???? ??
  - ?????

? fe80::/10
  - ?? ?????(??)
  - ?? ???? ???? ?? ??? ??
IPv6? IPv4 ?? ??(Dual Stack ???? ?? ??)




        IPv4(??)                     IPv6(?????)




        IPv6(??)                      IPv4(?????)


IPv4? Ipv6? ??? ? ?? ??? IPv4? 32???? ?? IPv6? 128?
?? ?rh 16?? ??? 16?? ??? ¡®:¡¯? ??? ??? ?? ??. ??
? ??? ?? ??? ??? ?? 32??? IPv4? ??? ?? ? ??.
? ??? IPv4? ???? ??? IPv4?? ??? ? ??.
?) ffff::10.1.2.3
IPv6/IPv4 ????? -> IPv4? ?? IPv4 ??




    ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6/IPv4 ????? -> IPv6? ?? IPv6 ??




    ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6/IPv4 ????? -> Dual Stack IPv4 ??




     ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6/IPv4 ????? -> Dual Stack IPv6 ??




     ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6/IPv4 ????? -> Separated Stack IPv6-only,
IPv4-only ??




     ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6/IPv4 ????? -> IPv4? ?? IPv4 ??




    ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
IPv6? IPv4 ?? ??

? ?? ??
  - ????, ?? ?????? IPv4? IPv6? ?? ??? ? ?? ??
  - IPv6 ?? ? ?? ???? ??

? ???
  - ? ??? ??? ?? ?? ???? IPv4 ?? ?? ??




? ??
  - IPv6 to IPv4 ?? IPv4 to IPv6?? ??? ??? ?? ??




                      ??: http://blog.daum.net/ipv6/24
IPv5? ????

? 1970?? ? ???/??? ???? ??? ?? Streaming Protocol(ST)

? ST? IP ??? ?? ??? ¡®5¡¯? ???? IPv5 ?? ???? ???

? 1990?? ? ST? ???? ST-II? ??. IPv5? ?? ??? ??? ??
  IP ?? ?? ?? ??? ??? ?? ?

? ?? ST-II ??? ??? ???/??? ???? ?? ??? ?????
  ST-II? ??. ??? IPv5? ?? ?
IPv6? Windows OS

? MSR(Microsoft Research)? 1996??? 2002??? IETF? IPv6 ??? ??
  ? ??

? MSR? Windows NT/2000 ??? 1998?? ?????? MSRIPv6 1.0? ?
  ??? ??

? 2001? 10? Windows XP? IPv6? ???? ??. ???? ?? ??

? Windows Server 2003? ?? ??? IPv6 ??? ??

? Windows Visata?? IPv4/IPv6? ??? ??? ????? ???? ??.
  ??? IPv6? ???? ??

? IE??? ?? 4?? ?? IPv6? ????
IP ?? ?? ??


                          ICANN
                       (?? ??? ?? ?? ??)




?? ? ?? ?? ??


  APNIC      ARIN       LACNIC RIPE-NCC AfrNIC
   (?? ??)   (?? ??)      (?? ??)          (?? ??)   (???? ??)
2?3? ?? ????? IPv4 ?? ??? ??

? ICANN? 2? 3? ?? ??? ?? IPv4 ??? ?? ???? ??

? ? ?? ??? ??? ICANN?? ? ?? ? ?? ?? ??? ?? ???
  ???? ??? ?? IPv4 ??? ? ?? ??? ?? ???

? ICANN? ?? ? ?? ?? ??? ??? ??? ? ? ? ??? ????
  ??? ? ???? ??? ? 1700?? ??? ??? ????.

? 2?3?? ??? ??? ?? ???? ??? ? ?? ? ?? ?? ???
  ? ???? ???.

? ??? APNIC? ?? ??? ?? ???? ? 4~6?? ??? ? ???,
  ??? ???? ?? ?? AfrNIC? ?? ?? ?? ??? ? ?? ???
  ???? ??.
IPv6? NAT

? IPv4?? ?? ?? ??? ???? ??? NAT(Network Address
  Translation) ??? ??

? NAT? ?? ?? ??? ??? ??? P2P ??? ??? ??

? UPnP? NAT Traversal ??? ? ??? ????? ???? ??

? ? ??? ? NAT? ??? ?? ????? ???? ?? ????? ??
  ? ??? ??

? ?? ??? CGN, LSN ?? 3? NAT? ??? ??, ?? ??, NAT
  Traversal ??? ? ?? ??

? NAT? ????? ?? ??? ?? ?? ? ????? ??? ??? ??
  ? P2P ??, ??? ????, ??, ???, VPn, VoIP?? ?? ??? ??
  ?? ??? ?? ??? ??

? IPv6? ????? ????? NAT?? IPv6?? ???? ?? ??
IPv6? ??

? IPv4? ????? ??? ???? ?? ????? ?? ?? ??? ??
  ???? ???

? IPv6? ?? ?? ??? ??? ???? ??

? IPv6? IPv4 ?? ??? ? ????? ?? ??? ??? ??? IPv4? ?
  ? ?? ?? ??? ???

? IPv6 ??? ???? ??? ???? IPv4? IPv6? ?? ???? ???
  ?? ??? 2?? ????? ? ? ??
World IPv6 Day

? 2011? 6? 8?? Internet Sociey(ISOC) ??? ¡®World IPv6 Day¡¯ ?? ??

? ? ??? ??? 24?? ?? IPv6 ? ???? ??? ? ???? ???
  ???? ??? ? ??, ? IPv4 ??? ????? ?? ??? IPv6 ??
  ? ?? ??? ?????

? ??? ???? ??, ????, Bing ? ?? ?? ??? ??? comcast?
  Time Warner cable? ???? ?? ???? ????? ?
IPv6 ?? ?? ?? ??? ??

? http://test-ipv6.com/ ? ???? ? ? ??
Big Game? IPv6 ??

? MMORPG? WOW? PTR ???? ?? ???? IPv6? ??(2011.03.17)
  http://www.fix6.net/archives/2011/03/17/latest-world-of-warcraft-ptr-patch-
  brings-ipv6-support/
?????
API - IPv6 ?? ???

#include <netinet/in.h>
struct sockaddr_in
{


                                                                                   IPv4
   in_port_t sin_port; // Port ?? struct
   in_addr sin_addr; // ??? ?? ???
}

struct in_addr {
   in_addr_t s_addr; // 32bit ??? ?????
}




#include <netinet/in.h>
struct sockaddr_in6



                                                                                   IPv6
{
  u_int16m_t sin6_family;    // AF_INET6
  u_int16m_t sin6_port;      // Port ??
  u_int32m_t sin6_flowinfo; // IPv6 flow information
  struct in6_addr sin6_addr;// IPv6 ??
  u_long sin6_scope_id;     // ????? ??? ???
}


           ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
API - socket



         IPv4                                                                       IPv6
s = socket(PF_INET, SOCK_STREAM, 0);                            s = socket(PF_INET6, SOCK_STREAM, 0);
s = socket(PF_INET, SOCK_DGRAM, 0);                             s = socket(PF_INET6, SOCK_DGRAM, 0);




         ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
API ¨C bind (IPv6)



        struct sockaddr_in6 sin6;
        ....
        sin6.sin6_family = AF_INET6;
        sin6.sin6_flowinfo = 0;
        sin6_sin6_port = htons(23);
        sin6.sin6_addr = in6addr_any;
        sin6.sin6_addr = in6addr_any;
        sin6.sin6_scope_id = if_nametoindex("eth0");
        ....
        if (bind(s, (struct sockaddr *)&sin6, sizeof(sin6)) == -1)
        {
             // ????
        }
        ....



      ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
API ¨C listen, accept (IPv6)



         listen
         ?? ??




         accept
         struct sockaddr_in6 clisin6;
         clisockfd = accept(sockfd, (struct sockaddr *)&clisin6,
                               (socklen_t *)&clilen);




       ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
API ¨C inet_addr, inet_ntoa




       inet_addr                    inet_pton

       inet_ntoa                    inet_ntop

        WSAAddressToString
            inet_addr? 32??, inet_pton? 128??
            ??? C++??? ?? ??? ??? 64?? !!!

            inet_pton, inet_ntop? Windows Vista?? ??
??- IPv6 ?? ?? (Win32 API)
#include ?winsock2.h?
#include ?ws2tcpip.h?
#include ?stdio.h?

int main(int argc, char *argv[])
{
   char *nodename;
   WSADATA wsaData;
   ADDRINFO hints;
   LPADDRINFO ai, ai0;
   int e;

    if (argc != 2) {
       fprintf(stderr, "syntax: getv6addr HOSTNAMEn");
       exit(1);
    }
    nodename = argv[1];

    WSAStartup(MAKEWORD(2, 2), &wsaData);

    /* resolving "www.ipv6style.jp" */
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET6;
    if (e = getaddrinfo(nodename, NULL, &hints, &ai0)) {
       fprintf(stderr, "%s: %sn", nodename, gai_strerror(e));
       WSACleanup(); exit(1);
    }

    for (ai = ai0; ai; ai = ai->ai_next) {
       char v6addrstr[NI_MAXHOST];
       getnameinfo(ai->ai_addr, ai->ai_addrlen, v6addrstr, sizeof(v6addrstr), NULL, 0, NI_NUMERICHOST);
       printf("%s IPv6 address: %sn", nodename, v6addrstr);
     }

    freeaddrinfo(ai0);
    WSACleanup();
}                                        ??: http://www.ipv6style.jp/jp/apps/20051024/index.shtml
??- IPv6 ?? ?? (Win32 API)
#include ?winsock2.h?
#include ?ws2tcpip.h?
#include ?stdio.h?

int main(int argc, char *argv[])
{
    PHOSTENT pHostInfo = NULL;
    char szHostName[255] = {0, };
    if (gethostname(szHostName, 255) == 0)
    {
        /// Windows XP1 ??
        DWORD        dwSize;
        LPADDRINFO lpAddrInfo;
        ADDRINFO addrHints;
        ZeroMemory(&addrHints, sizeof(addrinfo));

        if( bUseIPv6Address ) {
                  addrHints.ai_family = AF_INET6;
        } else {
                  addrHints.ai_family = AF_INET;
        }

        if (getaddrinfo(szHostName, NULL, &addrHints, &lpAddrInfo) != 0) {
                 return false;
        }

        dwSize = MAX_IP_STRING_LENGTH;
        if( 0 != WSAAddressToString(lpAddrInfo->ai_addr, (DWORD)lpAddrInfo->ai_addrlen, NULL, szIP, &dwSize) ) {
                  return false;
        }
    }
}




                                        ??: http://www.ipv6style.jp/jp/apps/20051024/index.shtml
??? ?? IPv6 ??? ??? ??? ? ? ????

? ?? ?? ??? ??? ?? FQDN(Fully Qualified Domain Name.??
  ? ??? ??? ???? ?? ??)? ??? ?? DNS ??? ??
  ??. ?? ??? ?? ??? ????.

? IPv4? ???? ?? ?? IPv4 ??? ??? A ???? DNS ???
  ??. ?? ??? ?? ??? IPv6 ??? ??? AAAA ???? ??.

? IPv4? IPv6 ? ? ???? ?????
  - AAAA ???? ??? IPv6 ?? ??? ??
  - AAAA ??? ??? ???? A ??? ??? ??

? IPv4, IPv6, ? ?? ????? ? ???? ??? ?????? ???
  ? gethostbyname ?? getaddrinfo, getnameinfo? ???? ??.
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int sock,err;
struct addrinfo hints, *res0, *res;

memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

/* getaddrinfo? AAAA ? A ??? ??*/
err = getaddrinfo("www.linux-ipv6.org", "http", &hints, &res0);

if (err) {
   fprintf(stderr, "error : %s", gai_strerror(err));
   freeaddrinfo(res0);
   exit(1);
}

/* getaddrinfo? ??? ???? ??? ??? ??? ???? */
for (res = res0; res; res = res->ai_next) {
   sock = socket (res->ai_family, res->ai_socktype, res->ai_protocol);
   if (sock < 0)
      continue;

  if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
     close (sock);
     continue;
  }
  break;
}
freeaddrinfo(res0);
???
                          ??: http://www.ipv6style.jp/jp/apps/20030617/index.shtml
??- IPv6 ?? (Win32 API)
#include   ?winsock2.h?
#include   ?ws2tcpip.h?
#include   ?stdio.h?
#include   ?process.h?

void tcp_echo_io(void *arg);

int main(int argc, char *argv[])
{
   WSADATA wsaData;
   int i;
   char *servname = "echo";
   ADDRINFO hints;
   LPADDRINFO ai, ai0;
   int e;
   SOCKET s[64];
   int nsocks;
   fd_set rfd0;

  if (WSAStartup(MAKEWORD(2, 2), &wsaData)) {
     fprintf(stderr, "can not initilize WinSockn");
     exit(1);
  }

  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  if (e = getaddrinfo(NULL, servname, &hints, &ai0)) {
     fprintf(stderr, "%sn", gai_strerror(e));
     exit(1);
  }
for (nsocks = 0, ai = ai0; ai; ai = ai->ai_next)
{
  s[nsocks] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  if (s[nsocks] == INVALID_SOCKET)
     continue;

    if (bind(s[nsocks], ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) {
       closesocket(s[nsocks]);
       s[nsocks] = INVALID_SOCKET;
       continue;
    }

    if (listen(s[nsocks], 5) == SOCKET_ERROR) {
       closesocket(s[nsocks]);
       s[nsocks] = INVALID_SOCKET;
       continue;
     }

    nsocks++;

    printf("create %s listen socketn",
           (ai->ai_family == AF_INET) ? "IPv4" :
           (ai->ai_family == AF_INET6) ? "IPv6" : "Unknown");
}


if (nsocks == 0) {
   fprintf(stderr, "can not create listen socket with any protocoln");
   exit(1);
}
FD_ZERO(&rfd0);
for (i = 0; i < nsocks; ++i)
  FD_SET(s[i], &rfd0);

while (1) {
  fd_set rfd;
  SOCKET iosock;
  SOCKADDR_STORAGE ss;
  int sslen;

    rfd = rfd0;
    if (select(FD_SETSIZE, &rfd, NULL, NULL, NULL) == SOCKET_ERROR) {
       fprintf(stderr, "select errorn");
       exit(1);
    }

    for (i = 0; i < nsocks; ++i) {
      if (FD_ISSET(s[i], &rfd)) {
          sslen = sizeof(ss);
          iosock = accept(s[i], (LPSOCKADDR)&ss, &sslen);
          if(iosock == INVALID_SOCKET) {
              fprintf(stderr, "accept errorn");
              exit(1);
          }

            if (_beginthread(tcp_echo_io, 0, &iosock) == -1) {
                fprintf(stderr, "can not create threadn");
                exit(1);
            }
        }
    }
}
void tcp_echo_io(void *arg)
{
  SOCKET s;
  char buf[BUFSIZ];
  int bufsiz;

    printf("start threadn");

    s = *(SOCKET *)arg;

    while ((bufsiz = recv(s, buf, sizeof(buf) - 1, 0)) != 0) {
      if (bufsiz == SOCKET_ERROR )
          break;

        buf[bufsiz] = '0';
        printf("recv string: %sn", buf);

        if (send(s, buf, bufsiz, 0) == SOCKET_ERROR)
            break;

        printf("send string: %sn", buf);
    }

    printf("end threadn");

    closesocket(s);
    _endthread();
}



                                   ??: http://www.ipv6style.jp/jp/apps/20051128/index.shtml
??- IPv6 ????? (Win32 API)

#include ?winsock2.h?
#include ?ws2tcpip.h?
#include ?stdio.h?

int main(int argc, char *argv[])
{
   WSADATA wsaData;
   char *nodename;
   char *servname = "echo";
   ADDRINFO hints;
   LPADDRINFO ai, ai0;
   int e;
   SOCKET s;
   char linebuf[BUFSIZ];

  if (argc != 2) {
     fprintf(stderr, "syntax: tcp-echo-client servername£¤n");
     exit(1);
  }
  nodename = argv[1];


  if (WSAStartup(MAKEWORD(2, 2), &wsaData)) {
     fprintf(stderr, "can not initilize WinSock£¤n");
     exit(1);
  }
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

if (e = getaddrinfo(nodename, servname, &hints, &ai0)) {
   fprintf(stderr, "%s£¤n", gai_strerror(e));
   exit(1);
}


for (ai = ai0; ai; ai = ai->ai_next) {
  s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  if (s == INVALID_SOCKET)
      continue;

    if (connect(s, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) {
       closesocket(s);
       s = INVALID_SOCKET;
       continue;
    }

    printf("connected£¤n");
    break;
}

if (s == INVALID_SOCKET) {
   freeaddrinfo(ai0);
   WSACleanup();
   fprintf(stderr, "can not connect server(%s)£¤n", nodename);
   exit(1);
}
while (fgets(linebuf, sizeof(linebuf), stdin) != NULL) {
      if (send(s, linebuf, strlen(linebuf), 0) == SOCKET_ERROR) {
         fprintf(stderr, "send error£¤n");
         exit(1);
      }

        if (recv(s, linebuf, sizeof(linebuf), 0) == SOCKET_ERROR) {
             fprintf(stderr, "recv error£¤n");
             exit(1);
        }
        printf(linebuf);
    }

    freeaddrinfo(ai0);
    WSACleanup();
}




                              ??: http://www.ipv6style.jp/jp/apps/20051114/index.shtml
GunZ2? ??? ????? IPv6 ?? ?? ??

1. IPv6? ?? ?? ??

2. ?? ??
 - IP ??? ???
 - IPv4? IPv6 ? ? ??? ? ??? ??? ???? ??
   - IPv6 ?? Socket API ??
   - IP ?? ???? ??? ???? ???? ? ?? ??

3. ???
 - ???? PC? ??? ??? IPv6?? ??
??
IPv6 ?? (???)
http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Intro

IPv6 ????? (??)
http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog

5??? ???? IPv6 ????? (???)
http://www.ipv6style.jp/jp/apps/20030617/index.shtml

IPv6 ?? ????? (???)
http://www.nslabs.jp/socket.rhtml

Windows??? IPv6 ?? ????? ?? (???)
http://www.admintech.jp/wiki.cgi?page=Windows%A4%C7%A4%CEIPv6%A5%
D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0%B9%D6%BA%C2

??? ???? IPv4? IPv6 (???)
http://www.ie.u-ryukyu.ac.jp/~e055723/info2/ipv6/main.html
Introduction to IPv6 Programming (??)
http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_progr
amming.pdf

IPv6?? ???? ???? (???)
http://journal.mycom.co.jp/series/ipv6/001/index.html

IPv6 ????? (???)
http://ja.wikipedia.org/wiki/IPv6#cite_note-5

Windows 7?? IPv6 ?? ?? (???)
https://ybb.softbank.jp/support/connect/step2/ipv6/win7_net_set.html

IPv6_Vasily (??. ???)
http://blog.daum.net/ipv6

MS TechNet ¨C IPv6
http://technet.microsoft.com/ko-kr/library/cc755011%28WS.10%29.aspx

More Related Content

IPv6 ??? ?? ?????

  • 1. IPv6 ??? ?? ????? ???? ?????? ??? ?? ????? ??? MS Visual C++ MVP Twitter : @jacking75
  • 2. ?? ? IPv6 ?? ?? ? IPv6 ?? ?????
  • 4. IPv6 ??? ? IPv6 ?? ¡®Internet Protocol Version 6¡¯? ?? ?. ? ?? ???? ?? ?? IPv4 ??. ? ?? ?? ?? ?? ???? IPv6 ??? ?? ??. ? ??? ??? ?? ??? ???? IPv6 ???(??)? ???? ??.
  • 5. OSI 7 Layer? TCP/IP??? IPv6? ?? ??: http://isecure-public.blogspot.com/2009/07/osi-7-layer-tcpip-suite.html
  • 6. ? IPv6? ???? ??? ? ?? - IPv4? ??? ? ?? IP? ???. - IPv4?? 42? ?? IP? ??? ? ?? - ??? ???? ?? NAT? ????? ? - 2011? 2?3?? ?? ?? ?? ??.
  • 7. ? IPv6? ???? ??? ? ?? - ???? ?? ????? IP? ??? ? ?? - 128bit ?? ?? - 340282366920938463463374607431768211456? ?? ??? ? ??
  • 8. ? IPv6? ???? ??? ? ?? IPv4? ??? ?? ?? ?? ???? ?? ??? ?? ?? ??? ? ??. ? ?? - IPv6? ?? ??? 40byte? IPv4? ? ?? ???? ????? ? ?? ??? ? IP ?? ?? ??. DHCP ??? ? ???? ???? QoS ??
  • 9. IPv4? IPv6? ?? ?? ?? : Joinc http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Intro
  • 10. IPv6? ???? ?? ??? ? ? OS - Windows XP, Windows Server 2003 ?? ?? - ??? ??? Windows Vista, Windows Server 2008 ?? - Mac OS? 10.2(Jaguar)?? ?? - Linux? FreeBSD? USAGI? THAI ?????? IPv6 ?? ???? ?? ? ??????? ??? ???? ??.
  • 11. IPv6? ???? ?? ??? ? ? ???? - ??? ??? ?? ???2?? ???? ??? IPv6? ?? ??. - ???, ??? 3 ???? ???? ????? IPv6? ???? ??. I-O Data WN-GDN/RS Wi-Fi g/n Router Cisco Catalyst 3750-E Series Switch
  • 12. IPv6? ???? ?? ??? ? ? ?? ???? ?? - ??? ??? IPv4? ?? ???? ??? IPv4? IPv6 ? ? ??? ? ?? Dual Stack?? ???? ??. - Windows Vista??? IPv6 ??? ?? ???? ???? IPv4? ??? ?. ?? : http://www.dbguide.net/knowledge.db?cmd=view&boardUid=126274&boardConfigUid=19&boardStep=0
  • 13. Dual Stack??? ? IPv4? IPv6 ?? ??? ???? ?? ???. - ??? ?? IPv4?? IPv6 ???? ? ?? - ???? OS?? ???? ??
  • 16. IPv6? ?? ?? ? ? IPv6 ?? ??? ???? ?? ???? ???? 1996?? ?? ??? ? 6Bone ??. ? 1998? 10??? 6REN(IPv6 Research and Education Networks Initiative) ??. ? ??(ÃÀÜŠ)??? GIG(Global Information Grid)?? ?? ?? ??? ?? ???? ?? ???? ??? 2003? 6?? IPv6?? ??? ??. 2008 ??? ????? IPv6 ???? ??. ? 2003? ?? ??? ???? ???? ??? ?? IPv6 ??? ????. ? ??? ?? ?? ?? ???? ???? IPv6 ???? ???? ??.
  • 17. IPv6 Address(??) ? IPv4? ?? ??? 32??, IPv6? ?? ??? 128?? ? IPv4? ??? 10??? 0~255 ??? ??? ?? IPv6? ??? 16??? ???? ?? ?? 8?. ?? ??? ¡®:¡¯ ?? fe80:1234:5678:9abc:def0:1234 ??? ???? ??? ? ?? ?? ??? 0000¡«ffff
  • 18. IPv6 ?? ?? ?? ? ¨C ?? 1 - 0 ?? - ??? ? ??? 0 ?? ???? ??? ??? ? ??. f0f0:0100:0020:0003:1000:0100:0020:0003 f0f0:100:20:3:1000:100:20:3
  • 19. IPv6 ?? ?? ?? ? ¨C ?? 2 - 0 ??. ?? 0?? ?? ??? ????. 1234:5678:0000:9abc:def0:1234:5678:9abc 1234:5678::9abc:def0:1234:5678:9abc - ???? ??? ???? :? ???? ?? :: 1234:0000:0000:0000:5678:9abc:def0:1234 1234::5678:9abc:def0:1234 - ??? ??? ???? ??? ?? 1234:0000:0000:5678:9abc:0000:0000:def0 -> 1234::5678:9abc::def0 -> 1234::5678:9abc:0:0:def0
  • 20. IPv6 ?? ?? ?? ? ¨C ?? 2 ? ¡®0¡¯ ?? ?? - ??? ¡®::¡¯ ??? ¡®0000¡¯?? ?? ???? ?? ??? ??? ? ??. - ?? - (8 - ?? ?? IPv6 ?? ?? ?)¡Á16 - ¡®ff02::2¡¯ -> (8-2)¡Á16 = 96. (16X6=96)??? 6 ??? ¡®0000¡¯? ?? ff02::2 ff02:0000:0000:0000:0000:0000:0000:0002
  • 22. LINKLOCAL ?? ? IPv4??? APIPA? ???? DHCP ???? IP ??? ?? ? ?? ? ? ??? LINKLOCAL ??? ????. - 169.254.*.*/16 ???? IP ??? ???? ?? ?? ? IPV6??? ?? ???? ???? ??. - fe80::/64 ??? ????.
  • 23. ??(?? ??) ?? ? LINKLOCAL ?? ???? ?? ??? ??? ?? MAC ??? LAN ???? ??? ?? ? ??? ???? IPv6 ??? ? ???? ID? ????? ?? ?? ? ???? ?? ??? ? ?? ?? ??: http://journal.mycom.co.jp/photo/series/ipv6/006/images/001l.jpg
  • 24. IPv6? ??? ?? ? 0:0:0:0:0:0:0:0 - ? ?? ??. ??? ¡®0::0¡¯?? ¡®::¡¯?? ?? - ??? ??? ???? ?? ??, ?? ? ?? ??? ??? ? 0:0:0:0:0:0:0:1 - ??? ??. IPv4? 127.0.0.1? ?? - IPv4??? 12.0.0.0/8 ??? ??? ??? ? ??? IPv6??? ? ??? ??? ? ?? - ??? ¡®0::1¡¯ ?? ¡®::1¡¯ ? 2001:db8::/32 - ?? ??? ?? ?? ? 2001: ? ???? ?(sTLA ??) - ?? ???? ???? ?? ?? ? 2002:: ? ???? ?(6to4 ??) - IPv6 over IPv4 ???? 6to4?? ???? ??. 2002: ? ???? 32?? ??? IPv4 ??? ??? ???. IPv6? ???? ?? ISP? ?? ?? ????
  • 25. IPv6? ??? ?? ? 3ffe: ? ???? ?(pTLA ??) - ? ?? ?? ?????? ?? ?? ?? ?? ? ff00::/8 ???? ?? - ????? ? fe80::/10 - ?? ?????(??) - ?? ???? ???? ?? ??? ??
  • 26. IPv6? IPv4 ?? ??(Dual Stack ???? ?? ??) IPv4(??) IPv6(?????) IPv6(??) IPv4(?????) IPv4? Ipv6? ??? ? ?? ??? IPv4? 32???? ?? IPv6? 128? ?? ?rh 16?? ??? 16?? ??? ¡®:¡¯? ??? ??? ?? ??. ?? ? ??? ?? ??? ??? ?? 32??? IPv4? ??? ?? ? ??. ? ??? IPv4? ???? ??? IPv4?? ??? ? ??. ?) ffff::10.1.2.3
  • 27. IPv6/IPv4 ????? -> IPv4? ?? IPv4 ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 28. IPv6/IPv4 ????? -> IPv6? ?? IPv6 ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 29. IPv6/IPv4 ????? -> Dual Stack IPv4 ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 30. IPv6/IPv4 ????? -> Dual Stack IPv6 ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 31. IPv6/IPv4 ????? -> Separated Stack IPv6-only, IPv4-only ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 32. IPv6/IPv4 ????? -> IPv4? ?? IPv4 ?? ??: http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_programming.pdf
  • 34. IPv6? IPv4 ?? ?? ? ?? ?? - ????, ?? ?????? IPv4? IPv6? ?? ??? ? ?? ?? - IPv6 ?? ? ?? ???? ?? ? ??? - ? ??? ??? ?? ?? ???? IPv4 ?? ?? ?? ? ?? - IPv6 to IPv4 ?? IPv4 to IPv6?? ??? ??? ?? ?? ??: http://blog.daum.net/ipv6/24
  • 35. IPv5? ???? ? 1970?? ? ???/??? ???? ??? ?? Streaming Protocol(ST) ? ST? IP ??? ?? ??? ¡®5¡¯? ???? IPv5 ?? ???? ??? ? 1990?? ? ST? ???? ST-II? ??. IPv5? ?? ??? ??? ?? IP ?? ?? ?? ??? ??? ?? ? ? ?? ST-II ??? ??? ???/??? ???? ?? ??? ????? ST-II? ??. ??? IPv5? ?? ?
  • 36. IPv6? Windows OS ? MSR(Microsoft Research)? 1996??? 2002??? IETF? IPv6 ??? ?? ? ?? ? MSR? Windows NT/2000 ??? 1998?? ?????? MSRIPv6 1.0? ? ??? ?? ? 2001? 10? Windows XP? IPv6? ???? ??. ???? ?? ?? ? Windows Server 2003? ?? ??? IPv6 ??? ?? ? Windows Visata?? IPv4/IPv6? ??? ??? ????? ???? ??. ??? IPv6? ???? ?? ? IE??? ?? 4?? ?? IPv6? ????
  • 37. IP ?? ?? ?? ICANN (?? ??? ?? ?? ??) ?? ? ?? ?? ?? APNIC ARIN LACNIC RIPE-NCC AfrNIC (?? ??) (?? ??) (?? ??) (?? ??) (???? ??)
  • 38. 2?3? ?? ????? IPv4 ?? ??? ?? ? ICANN? 2? 3? ?? ??? ?? IPv4 ??? ?? ???? ?? ? ? ?? ??? ??? ICANN?? ? ?? ? ?? ?? ??? ?? ??? ???? ??? ?? IPv4 ??? ? ?? ??? ?? ??? ? ICANN? ?? ? ?? ?? ??? ??? ??? ? ? ? ??? ???? ??? ? ???? ??? ? 1700?? ??? ??? ????. ? 2?3?? ??? ??? ?? ???? ??? ? ?? ? ?? ?? ??? ? ???? ???. ? ??? APNIC? ?? ??? ?? ???? ? 4~6?? ??? ? ???, ??? ???? ?? ?? AfrNIC? ?? ?? ?? ??? ? ?? ??? ???? ??.
  • 39. IPv6? NAT ? IPv4?? ?? ?? ??? ???? ??? NAT(Network Address Translation) ??? ?? ? NAT? ?? ?? ??? ??? ??? P2P ??? ??? ?? ? UPnP? NAT Traversal ??? ? ??? ????? ???? ?? ? ? ??? ? NAT? ??? ?? ????? ???? ?? ????? ?? ? ??? ?? ? ?? ??? CGN, LSN ?? 3? NAT? ??? ??, ?? ??, NAT Traversal ??? ? ?? ?? ? NAT? ????? ?? ??? ?? ?? ? ????? ??? ??? ?? ? P2P ??, ??? ????, ??, ???, VPn, VoIP?? ?? ??? ?? ?? ??? ?? ??? ?? ? IPv6? ????? ????? NAT?? IPv6?? ???? ?? ??
  • 40. IPv6? ?? ? IPv4? ????? ??? ???? ?? ????? ?? ?? ??? ?? ???? ??? ? IPv6? ?? ?? ??? ??? ???? ?? ? IPv6? IPv4 ?? ??? ? ????? ?? ??? ??? ??? IPv4? ? ? ?? ?? ??? ??? ? IPv6 ??? ???? ??? ???? IPv4? IPv6? ?? ???? ??? ?? ??? 2?? ????? ? ? ??
  • 41. World IPv6 Day ? 2011? 6? 8?? Internet Sociey(ISOC) ??? ¡®World IPv6 Day¡¯ ?? ?? ? ? ??? ??? 24?? ?? IPv6 ? ???? ??? ? ???? ??? ???? ??? ? ??, ? IPv4 ??? ????? ?? ??? IPv6 ?? ? ?? ??? ????? ? ??? ???? ??, ????, Bing ? ?? ?? ??? ??? comcast? Time Warner cable? ???? ?? ???? ????? ?
  • 42. IPv6 ?? ?? ?? ??? ?? ? http://test-ipv6.com/ ? ???? ? ? ??
  • 43. Big Game? IPv6 ?? ? MMORPG? WOW? PTR ???? ?? ???? IPv6? ??(2011.03.17) http://www.fix6.net/archives/2011/03/17/latest-world-of-warcraft-ptr-patch- brings-ipv6-support/
  • 44. ?????
  • 45. API - IPv6 ?? ??? #include <netinet/in.h> struct sockaddr_in { IPv4 in_port_t sin_port; // Port ?? struct in_addr sin_addr; // ??? ?? ??? } struct in_addr { in_addr_t s_addr; // 32bit ??? ????? } #include <netinet/in.h> struct sockaddr_in6 IPv6 { u_int16m_t sin6_family; // AF_INET6 u_int16m_t sin6_port; // Port ?? u_int32m_t sin6_flowinfo; // IPv6 flow information struct in6_addr sin6_addr;// IPv6 ?? u_long sin6_scope_id; // ????? ??? ??? } ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
  • 46. API - socket IPv4 IPv6 s = socket(PF_INET, SOCK_STREAM, 0); s = socket(PF_INET6, SOCK_STREAM, 0); s = socket(PF_INET, SOCK_DGRAM, 0); s = socket(PF_INET6, SOCK_DGRAM, 0); ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
  • 47. API ¨C bind (IPv6) struct sockaddr_in6 sin6; .... sin6.sin6_family = AF_INET6; sin6.sin6_flowinfo = 0; sin6_sin6_port = htons(23); sin6.sin6_addr = in6addr_any; sin6.sin6_addr = in6addr_any; sin6.sin6_scope_id = if_nametoindex("eth0"); .... if (bind(s, (struct sockaddr *)&sin6, sizeof(sin6)) == -1) { // ???? } .... ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
  • 48. API ¨C listen, accept (IPv6) listen ?? ?? accept struct sockaddr_in6 clisin6; clisockfd = accept(sockfd, (struct sockaddr *)&clisin6, (socklen_t *)&clilen); ?? : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog
  • 49. API ¨C inet_addr, inet_ntoa inet_addr inet_pton inet_ntoa inet_ntop WSAAddressToString inet_addr? 32??, inet_pton? 128?? ??? C++??? ?? ??? ??? 64?? !!! inet_pton, inet_ntop? Windows Vista?? ??
  • 50. ??- IPv6 ?? ?? (Win32 API) #include ?winsock2.h? #include ?ws2tcpip.h? #include ?stdio.h? int main(int argc, char *argv[]) { char *nodename; WSADATA wsaData; ADDRINFO hints; LPADDRINFO ai, ai0; int e; if (argc != 2) { fprintf(stderr, "syntax: getv6addr HOSTNAMEn"); exit(1); } nodename = argv[1]; WSAStartup(MAKEWORD(2, 2), &wsaData); /* resolving "www.ipv6style.jp" */ memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; if (e = getaddrinfo(nodename, NULL, &hints, &ai0)) { fprintf(stderr, "%s: %sn", nodename, gai_strerror(e)); WSACleanup(); exit(1); } for (ai = ai0; ai; ai = ai->ai_next) { char v6addrstr[NI_MAXHOST]; getnameinfo(ai->ai_addr, ai->ai_addrlen, v6addrstr, sizeof(v6addrstr), NULL, 0, NI_NUMERICHOST); printf("%s IPv6 address: %sn", nodename, v6addrstr); } freeaddrinfo(ai0); WSACleanup(); } ??: http://www.ipv6style.jp/jp/apps/20051024/index.shtml
  • 51. ??- IPv6 ?? ?? (Win32 API) #include ?winsock2.h? #include ?ws2tcpip.h? #include ?stdio.h? int main(int argc, char *argv[]) { PHOSTENT pHostInfo = NULL; char szHostName[255] = {0, }; if (gethostname(szHostName, 255) == 0) { /// Windows XP1 ?? DWORD dwSize; LPADDRINFO lpAddrInfo; ADDRINFO addrHints; ZeroMemory(&addrHints, sizeof(addrinfo)); if( bUseIPv6Address ) { addrHints.ai_family = AF_INET6; } else { addrHints.ai_family = AF_INET; } if (getaddrinfo(szHostName, NULL, &addrHints, &lpAddrInfo) != 0) { return false; } dwSize = MAX_IP_STRING_LENGTH; if( 0 != WSAAddressToString(lpAddrInfo->ai_addr, (DWORD)lpAddrInfo->ai_addrlen, NULL, szIP, &dwSize) ) { return false; } } } ??: http://www.ipv6style.jp/jp/apps/20051024/index.shtml
  • 52. ??? ?? IPv6 ??? ??? ??? ? ? ???? ? ?? ?? ??? ??? ?? FQDN(Fully Qualified Domain Name.?? ? ??? ??? ???? ?? ??)? ??? ?? DNS ??? ?? ??. ?? ??? ?? ??? ????. ? IPv4? ???? ?? ?? IPv4 ??? ??? A ???? DNS ??? ??. ?? ??? ?? ??? IPv6 ??? ??? AAAA ???? ??. ? IPv4? IPv6 ? ? ???? ????? - AAAA ???? ??? IPv6 ?? ??? ?? - AAAA ??? ??? ???? A ??? ??? ?? ? IPv4, IPv6, ? ?? ????? ? ???? ??? ?????? ??? ? gethostbyname ?? getaddrinfo, getnameinfo? ???? ??.
  • 53. #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> int sock,err; struct addrinfo hints, *res0, *res; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; /* getaddrinfo? AAAA ? A ??? ??*/ err = getaddrinfo("www.linux-ipv6.org", "http", &hints, &res0); if (err) { fprintf(stderr, "error : %s", gai_strerror(err)); freeaddrinfo(res0); exit(1); } /* getaddrinfo? ??? ???? ??? ??? ??? ???? */ for (res = res0; res; res = res->ai_next) { sock = socket (res->ai_family, res->ai_socktype, res->ai_protocol); if (sock < 0) continue; if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { close (sock); continue; } break; } freeaddrinfo(res0); ??? ??: http://www.ipv6style.jp/jp/apps/20030617/index.shtml
  • 54. ??- IPv6 ?? (Win32 API) #include ?winsock2.h? #include ?ws2tcpip.h? #include ?stdio.h? #include ?process.h? void tcp_echo_io(void *arg); int main(int argc, char *argv[]) { WSADATA wsaData; int i; char *servname = "echo"; ADDRINFO hints; LPADDRINFO ai, ai0; int e; SOCKET s[64]; int nsocks; fd_set rfd0; if (WSAStartup(MAKEWORD(2, 2), &wsaData)) { fprintf(stderr, "can not initilize WinSockn"); exit(1); } memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; if (e = getaddrinfo(NULL, servname, &hints, &ai0)) { fprintf(stderr, "%sn", gai_strerror(e)); exit(1); }
  • 55. for (nsocks = 0, ai = ai0; ai; ai = ai->ai_next) { s[nsocks] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (s[nsocks] == INVALID_SOCKET) continue; if (bind(s[nsocks], ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) { closesocket(s[nsocks]); s[nsocks] = INVALID_SOCKET; continue; } if (listen(s[nsocks], 5) == SOCKET_ERROR) { closesocket(s[nsocks]); s[nsocks] = INVALID_SOCKET; continue; } nsocks++; printf("create %s listen socketn", (ai->ai_family == AF_INET) ? "IPv4" : (ai->ai_family == AF_INET6) ? "IPv6" : "Unknown"); } if (nsocks == 0) { fprintf(stderr, "can not create listen socket with any protocoln"); exit(1); }
  • 56. FD_ZERO(&rfd0); for (i = 0; i < nsocks; ++i) FD_SET(s[i], &rfd0); while (1) { fd_set rfd; SOCKET iosock; SOCKADDR_STORAGE ss; int sslen; rfd = rfd0; if (select(FD_SETSIZE, &rfd, NULL, NULL, NULL) == SOCKET_ERROR) { fprintf(stderr, "select errorn"); exit(1); } for (i = 0; i < nsocks; ++i) { if (FD_ISSET(s[i], &rfd)) { sslen = sizeof(ss); iosock = accept(s[i], (LPSOCKADDR)&ss, &sslen); if(iosock == INVALID_SOCKET) { fprintf(stderr, "accept errorn"); exit(1); } if (_beginthread(tcp_echo_io, 0, &iosock) == -1) { fprintf(stderr, "can not create threadn"); exit(1); } } } }
  • 57. void tcp_echo_io(void *arg) { SOCKET s; char buf[BUFSIZ]; int bufsiz; printf("start threadn"); s = *(SOCKET *)arg; while ((bufsiz = recv(s, buf, sizeof(buf) - 1, 0)) != 0) { if (bufsiz == SOCKET_ERROR ) break; buf[bufsiz] = '0'; printf("recv string: %sn", buf); if (send(s, buf, bufsiz, 0) == SOCKET_ERROR) break; printf("send string: %sn", buf); } printf("end threadn"); closesocket(s); _endthread(); } ??: http://www.ipv6style.jp/jp/apps/20051128/index.shtml
  • 58. ??- IPv6 ????? (Win32 API) #include ?winsock2.h? #include ?ws2tcpip.h? #include ?stdio.h? int main(int argc, char *argv[]) { WSADATA wsaData; char *nodename; char *servname = "echo"; ADDRINFO hints; LPADDRINFO ai, ai0; int e; SOCKET s; char linebuf[BUFSIZ]; if (argc != 2) { fprintf(stderr, "syntax: tcp-echo-client servername£¤n"); exit(1); } nodename = argv[1]; if (WSAStartup(MAKEWORD(2, 2), &wsaData)) { fprintf(stderr, "can not initilize WinSock£¤n"); exit(1); }
  • 59. memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if (e = getaddrinfo(nodename, servname, &hints, &ai0)) { fprintf(stderr, "%s£¤n", gai_strerror(e)); exit(1); } for (ai = ai0; ai; ai = ai->ai_next) { s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (s == INVALID_SOCKET) continue; if (connect(s, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) { closesocket(s); s = INVALID_SOCKET; continue; } printf("connected£¤n"); break; } if (s == INVALID_SOCKET) { freeaddrinfo(ai0); WSACleanup(); fprintf(stderr, "can not connect server(%s)£¤n", nodename); exit(1); }
  • 60. while (fgets(linebuf, sizeof(linebuf), stdin) != NULL) { if (send(s, linebuf, strlen(linebuf), 0) == SOCKET_ERROR) { fprintf(stderr, "send error£¤n"); exit(1); } if (recv(s, linebuf, sizeof(linebuf), 0) == SOCKET_ERROR) { fprintf(stderr, "recv error£¤n"); exit(1); } printf(linebuf); } freeaddrinfo(ai0); WSACleanup(); } ??: http://www.ipv6style.jp/jp/apps/20051114/index.shtml
  • 61. GunZ2? ??? ????? IPv6 ?? ?? ?? 1. IPv6? ?? ?? ?? 2. ?? ?? - IP ??? ??? - IPv4? IPv6 ? ? ??? ? ??? ??? ???? ?? - IPv6 ?? Socket API ?? - IP ?? ???? ??? ???? ???? ? ?? ?? 3. ??? - ???? PC? ??? ??? IPv6?? ??
  • 62. ?? IPv6 ?? (???) http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Intro IPv6 ????? (??) http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/TCP_IP/IPv6/IPv6Prog 5??? ???? IPv6 ????? (???) http://www.ipv6style.jp/jp/apps/20030617/index.shtml IPv6 ?? ????? (???) http://www.nslabs.jp/socket.rhtml Windows??? IPv6 ?? ????? ?? (???) http://www.admintech.jp/wiki.cgi?page=Windows%A4%C7%A4%CEIPv6%A5% D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0%B9%D6%BA%C2 ??? ???? IPv4? IPv6 (???) http://www.ie.u-ryukyu.ac.jp/~e055723/info2/ipv6/main.html
  • 63. Introduction to IPv6 Programming (??) http://www.euchinagrid.org/IPv6/IPv6_presentation/Introduction_to_IPv6_progr amming.pdf IPv6?? ???? ???? (???) http://journal.mycom.co.jp/series/ipv6/001/index.html IPv6 ????? (???) http://ja.wikipedia.org/wiki/IPv6#cite_note-5 Windows 7?? IPv6 ?? ?? (???) https://ybb.softbank.jp/support/connect/step2/ipv6/win7_net_set.html IPv6_Vasily (??. ???) http://blog.daum.net/ipv6 MS TechNet ¨C IPv6 http://technet.microsoft.com/ko-kr/library/cc755011%28WS.10%29.aspx