Programming of IPV6 Network in C + +

Source: Internet
Author: User

IPV4 was originally developed by the U.S. Department of Defense for Internet Interconnection (IP) protocol, and later it developed not only TCP but also IPV4 (IP Protocol version 4.0). IPV4 is now widely used in Internet networks and also in most computer systems, LANs, and WANs. However, as the number of computers in the Internet soars, the limitations of IPv4 are becoming more pronounced:

The number of 1.ipv4 address is exhausted, the daily tense;

2.ipv4 addressing is not completely hierarchical, which makes Internet hub routers have to maintain a large number of routing tables and are overburdened.

The address of the 3.ipv4 must be statically assigned or distributed through a configuration protocol such as: DHCP. One of the development goals of IPV6 is to provide a simpler configuration scenario.

So IPV6 (6.0 version) was born. Windows XP provides a developer-release version of IPV6 in the window System, and Windows 2000 can also download the IPV6 protocol preview in Http://www.microsoft.com/ipv6. The following figure is a successful sample diagram installed on my computer:

Figure-1 IPV6 Installation Example

A IPV4 address and its addressing

1. IPV4 Address

The IPV4 address (often called an IP address) is represented by a 32-digit number, usually representing a decimal format, where each 8-bit byte of the address is represented as a decimal value and separated by a period, such as: The 192.168.0.1;ipv4 address is usually divided into a, B, C, D, E five categories.

2. IPV4 addressing

In Winsock, the address and service fracture information of the IPV4 is specified through the SOCKADDR_IN structure:

struct SOCKADDR_IN {

Short sin_family//must be af_inet, indicating the use of IPV4 address cluster

U_short Sin_port; TCP/UDP Port

struct IN_ADDR sin_addr;//IP address (in network byte order, 4 bytes)

Char sin_zero[8];//padding Item

}

Two IPV6 address and its addressing

1. IPV6 Address

The notable difference between the IPv6 address and the IPV4 address is 128-bit, which is 4 times times the length of the IPv4 address. The IPV6 address is represented by a 16-byte fragment and is displayed as a colon-delimited 16-in:

21da:00d3:0000:2f3a:b234:ed12:9c5a:dac3

Allocation of IPV6 addresses

Distribution

Address prefix

Reserved address 0000 0000

reserved for NSAP 0000 0001

Converged Global Unicast Address 001

Link-local unicast address 1111 1110 10

Site-Local unicast address 1111 1110 11

Multicast address 1111 1111

Addressing of 2.ipv6

In Winsock, addressing uses the structure:

struct  sockaddr_in6{
short sin6_family;// 地址簇:AF_INET6
u_short sin6_port;//端口号
u_long sin6_flowinfo;//连接标记通信量
struct in6_addr sin6_addr;//16字节结构的IPv6 地址
u_long sin6_scope_id;//地址所有的接口索引

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.