简体   繁体   English

ipv6向后兼容ipv4吗?

[英]is ipv6 backward compatible with ipv4?

I've got a little udp example program written using ipv4. 我有一个使用ipv4编写的udp示例程序。 If I alter the code to ipv6 would I still be able to communicate with anyone using the listener with an ipv4 address? 如果我将代码更改为ipv6,我是否仍可以使用具有ipv4地址的侦听器与任何人通信? I was looking at porting examples at 我正在看的移植示例

http://ou800doc.caldera.com/en/SDK_netapi/sockC.PortIPv4appIPv6.html http://ou800doc.caldera.com/cn/SDK_netapi/sockC.PortIPv4appIPv6.html

I'm not sure if simply altering the code would ensure that it worked or if I'd have to write it in duel-stack mode. 我不确定是否只是更改代码就能确保它能正常工作,或者我是否必须以决斗堆栈模式编写它。

Yes and no... IPv6 does contain completely different addressing, so you'll have to recode your app to use the alternative headers and structure sizes. 是和否... IPv6确实包含完全不同的寻址,因此您必须重新编码应用程序才能使用备用标头和结构大小。

However, the IPv4 address range is available within IPv6, the syntax is to add two colons before the standard address (eg ::10.11.12.13). 但是,IPv4地址范围在IPv6中可用,语法是在标准地址之前添加两个冒号(例如:: 10.11.12.13)。 You can also embed IPv4 addresses within IPv6 packets . 您还可以在IPv6数据包中嵌入IPv4地址

Not without the assistance of an IPv4/IPv6 gateway in the network, and even then communication will be limited by the typical problems introduced by network address translating gateways. 并非没有网络中的IPv4 / IPv6网关的帮助,即使那样,通信也将受到网络地址转换网关引入的典型问题的限制。 The traditional advice for programmers facing decisions like this is to recommend supporting both IPv4 and IPv6 at the same time. 对于面临此类决策的程序员,传统的建议是建议同时支持IPv4和IPv6。

IPv4 and IPv6 are inherently incompatible with each other. IPv4和IPv6本质上是彼此不兼容的。
A few basic reasons: 一些基本原因:

  • the address space is completely different (IPv6 has 128 bit addresses, IPv4 has 32 bit addresses) 地址空间完全不同(IPv6具有128位地址,IPv4具有32位地址)
  • the protocol header of IPv6 looks nothing like the protocol header of IPv4. IPv6的协议标头看起来与IPv4的协议标头完全不同。 if you try to parse an IPv6 packet as IPv4 you'll get nonsense. 如果您尝试将IPv6数据包解析为IPv4,则会毫无意义。

The obvious result of these is that if you open an IPv6 socket you can't listen to it using an IPv4 socket. 这些的明显结果是,如果打开IPv6套接字,则无法使用IPv4套接字监听它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM