is ipv6 backward compatible with ipv4?

此生再无相见时 提交于 2019-12-20 04:09:54

问题


I've got a little udp example program written using ipv4. If I alter the code to ipv6 would I still be able to communicate with anyone using the listener with an ipv4 address? I was looking at porting examples at

http://ou800doc.caldera.com/en/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.


回答1:


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.

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). You can also embed IPv4 addresses within IPv6 packets.




回答2:


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. The traditional advice for programmers facing decisions like this is to recommend supporting both IPv4 and IPv6 at the same time.




回答3:


IPv4 and IPv6 are inherently incompatible with each other.
A few basic reasons:

  • the address space is completely different (IPv6 has 128 bit addresses, IPv4 has 32 bit addresses)
  • the protocol header of IPv6 looks nothing like the protocol header of IPv4. if you try to parse an IPv6 packet as IPv4 you'll get nonsense.

The obvious result of these is that if you open an IPv6 socket you can't listen to it using an IPv4 socket.



来源:https://stackoverflow.com/questions/915914/is-ipv6-backward-compatible-with-ipv4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!