ipv4 and ipv6 Inet4Address classes and class Inet6Address

In setting the local IP addresses, some people wonder what is the difference between IPv4 and IPv6? Here it by a small series to share learning ipv4 and ipv6 differentiated content for you, I want to help.

The difference between ipv4 and ipv6

In the above system windows 7, when setting the local IP address when often see colleagues contain IPV4 and IPV6 Agreement Agreement, and different from the previous windows xp system, only TCP / IP protocol items, many of my friends feel more strange, editor asked the difference between IPv4 and IPv6, the following edit it for IPv4 and IPv6 everyone authoritative introduction to what is the difference.

The current global Internet protocol suite used by the TCP / IP protocol suite. IP is the protocol TCP / IP protocol suite is the network layer, the TCP / IP protocol suite core protocol. The current IP protocol version number is 4 (referred to as IPv4), the development has been used for over 30 years. IPv4 address bits is 32, that is, up to 2 ^ 32 computers can be linked to the Internet, over the past decade due to the vigorous development of the Internet, the demand for IP addresses is getting bigger, so that the IP address issuing ever stricter, the data show that global IPv4 addresses may all be finished between 2005 and 2008.

What is IPv6 What is IPv6? IPv6 is the next version of the Internet Protocol, also can be said that the next generation Internet protocol, which was originally proposed because with the rapid development of the Internet, IPv4 address space is limited definition will be depleted, lack of address space will hinder further development of the Internet.

In order to expand the address space, to be re-defined address space IPv6. IPv6 uses 128-bit address length, almost unlimited address may be provided. Estimate the actual IPv6 address assigned by a conservative approach, 1000 can still be assigned a plurality of addresses per square meter area of ​​the entire Earth. In addition to IPv6 design process once and for all solve the address shortage, it also takes into account the poor to solve other problems in IPv4, there are end to end IP connectivity, quality of service (QoS), security, multicast, mobile sex, plug and play. IPv6 compared with IPv4 What are the characteristics and advantages? Larger address space. IP address in IPv4 predetermined length 32, i.e., there are 2 ^ 32-1 addresses; IPv6 IP address and a length of 128, i.e., there are 2 ^ 128-1 addresses. Smaller routing tables. IPv6 address allocation follows the clustering principle start (Aggregation), which makes the routers in the routing table with a record (the Entry) indicates a subnet, greatly reduces the length of the routing table in the router, the router forwards improved speed data packet. Enhanced multicast (Multicast) support and the support of convection (Flow-control).

This makes multimedia applications on the network has made great development opportunities, quality of service (QoS) provides a good platform for network control. Added support for automatic configuration (Auto-configuration) of. This is the DHCP protocol to improve and expand, making the management network (especially local area network) is more convenient and faster. Higher security. Users can encrypt data at the network layer using the IPv6 network and IP packets calibration, which greatly enhances network security. by reading the above, I believe we distinguish between IPv4 and IPv6, have a more profound understanding, in fact, only a windows xp system TCP / IP protocol is windows 7 items the IPV4 protocol, but windows 7 system, a clearer distinction only.

IPv6 / IPv4 network access system conversion

It is an IPv6-based tunneling technology, combined with multiple network communication technology development of integrated hardware and software systems. The system uses "The cloud integration" product system architecture design and deployment, including the client, configure the tunnel, the tunnel agent technology, the tunnel server, 6TO4,4TO6, GRE tunnel between ISATAP site automatic tunnel addressing other technical modules, We can solve the problem of access to end-user access speed IPv4 and more mainstream Internet applications to IPv6 transition. After the one hundred thousand users access the test pressure, it can easily help users to achieve IPv6 network for Internet access. In the next generation IPv6 network test applications, the system can not only take full advantage of IPv6 network infrastructure IPv6 university campus network, better able to effectively help universities and other IPv6 LAN bypass IPv4 public network egress traffic pressure, improve and optimize local area network resources management, greatly reducing the cost of leasing the bandwidth IPv4 industrial customers.

Introduction of IPv4

IPv4, is the fourth edition of the Internet Protocol (Internet Protocol, IP), is the first to be widely used to form the basis of today's Internet technology protocol. 1981 Jon Postel defined in the RFC791 IP, Ipv4 can run on a variety of underlying network, such as end-to-serial data link (PPP and SLIP protocols Protocol), satellite links, etc. The most common local area network is Ethernet.

The current global Internet protocol suite used by the TCP / IP protocol suite. IP is the protocol TCP / IP protocol suite is the network layer, the TCP / IP protocol suite core protocol. The current IP protocol version number is 4 (referred to as IPv4, v, version version), which is the next version of IPv6. IPv6 is in the process of continuous development and improvement in the near future it will replace the current IPv4 is widely used. According to foreign media reports, the European Commission hopes by 2010 to convert a quarter of the territory of the commercial and government sectors in Europe and its member states to IPv6 home networking standard. The United States has begun to give conditional incentives for government departments have signed the IPv6 protocol and network service providers. The EU hopes to follow the pace of the United States, prompting the government of its member states play a leading role in this transformation process.

Inet4Address class and class Inet6Address

To distinguish between IPv4 and IPv6 address, the Java provides two classes: Inet4Address and Inet6Address in the exact, which is a subclass of InetAddress, these two classes are defined as follows:

public final class Inet4Address extends InetAddress
public final class Inet6Address extends InetAddress

 These classes pressing IPv4 and IPv6 rules achieved InetAddress class public methods. Except that they Inet6Address analogy Inet4Address one more class method: isIPv4CompatibleAddress, this method is used to determine whether a compatible IPv6 and IPv4 addresses. And IPv4-compatible IPv6 address except for the last four-byte value name, the other bytes are 0, such as 0: 0: 0: 0: 0: 0.192.168.18.10, :: ABCD: FAFA both IPv4 and compatible IPv6 address.

    When the object is created using four static method InetAddress InetAddress-byte array can be judged by the IP address returned getAddress IPv4 or IPv6 address (byte array of length 4 is an IPv4 address, byte length of the array 16 is an IPv6 address) , may be InetAddress instanceof determine which objects are instances of its subclasses. The following code demonstrates how to determine an IP address is an IPv4 or IPv6 address:

Package MyNet; 

Import the java.net *. ; 

public  class the MyIP 
{ 
    public  static  void main (String [] args) throws Exception 
    { 
        IF (args.length == 0 )
             return ; 
        InetAddress address = InetAddress.getByName (args [0 ]) ; 
        System.out.println ( "IP:" + address.getHostAddress ());
         Switch (. address.getAddress () length) 
        { 
            Case . 4 : 
                System.out.println ( "the IP address is determined according to the length of the array is byte IPv4 address!");
                 BREAK ;
             Case 16 : 
                System.out.println ( "! IP address is determined according to the length of the array is byte IPv6 address" );
                 BREAK ; 
        } 
        IF (address instanceof Inet4Address) 
            System.out.println ( "instanceof determined using this IP address is the IPv4 address! " );
         the else  IF (address instanceof Inet6Address in the exact) 
            System.out.println ( " use instanceof determines the IP address is an IPv6 address! " ); 
    } 
}

 Test 1

    Execute the following command:

java mynet.myıp www.csdn.net

  operation result:

IP: 211.100.26.122
is determined according to the IP address of the length of the array is byte IPv4 address!
Use instanceof determines the IP address is an IPv4 address!

Guess you like

Origin www.cnblogs.com/lukelook/p/11235716.html