6 月 1 日起所有提交的 app 都需要支持 IPv6 网络

根据苹果开发者网站的声明,大部分现有应用程序已经通过NSURLSession和CFNetwork APIs兼容该协议。依然使用IPv4 APIs的或者硬件编码IP地址的开发者将需要手工调整应用代码来适应苹果的最新策略。

IPv6比IPv4更有效:

  • 避免了网络地址转换的需要(NAT: Network Address Translation)
  • 通过使用简单的Headers,通过网络提供更快的路由
    • 防止网络碎片
    • Avoids broadcasting for neighbor address resolution (避免广播 ….,请自行翻译好了)

DNS64/NAT64 过渡工作流程

为了帮助减缓IPv4地址耗尽,NAT在许多IPv4网络实现。虽然这个解决方案暂时工作,它证明了昂贵和脆弱。今天,随着越来越多的客户使用IPv6,供应商现在必须同时支持IPv4和IPv6。这是一个代价高昂的努力。 图1-1蜂窝网络提供独立的IPv4和IPv6连接 IPv4和IPv6连接

理想的情况下,供应商要降为IPv4网络支持。然而,这样做可以防止客户端访问IPv4的服务器,这是互联网的一个重要部分。为了解决这个问题,最主要的网络供应商实施 DNS64/NAT64 过渡工作。这是一个纯IPv6网络,继续提供访问IPv4内容通过翻译。 图1-2蜂窝网络的部署与 DNS64 和 NAT64 的IPv6网络 DNS64 和 NAT64 的IPv6网络

在这种类型的工作流中,客户端发送DNS查询到DNS64服务器,它要求从DNS服务器获取 IPv6 地址。当一个IPv6地址被发现,它会立即传回到客户端。然而,当没有找到IPv6地址时,DNS64服务器请求一个IPv4地址代替。然后DNS64服务器通过为IPv4添加地址前缀合成一个IPv6地址,并传递回客户端。在这方面,客户端总是收到一个IPv6-ready地址(In this regard, the client always receives an IPv6-ready address.最后一句原文 By 老陶2016-05-22 12:29:56)。

1-3处理IPv4向IPv6的转换过程 IPv4向IPv6的转换过程

当客户端像服务器发送一个请求,任何IPv6数据包

When the client sends a request to a server, any IPv6 packets destined for synthesized addresses are automatically routed by the network through a NAT64 gateway. The gateway performs the IPv6-to-IPv4 address and protocol translation for the request. It also performs the IPv4 to IPv6 translation for the response from the server. See Figure 1-4.

1-4 DNS64/NAT64过渡方案工作流程 DNS64/NAT64过渡方案工作流程

IPv6 和 App Store 的要求

IPv6 DNS64/NAT64的网络兼容性处理将成为 App Store 的一个提交要求,所以应用程序兼容性不可少的。好消息是大部分软件都兼容IPv6.对于这些应用,定期回归测试你的应用程序仍然是有必要的。不兼容IPv6的应用在操作DNS64/NAT64网络时可能会遇到问题。幸运的是,解决这些问题通常很简单,就像是本章节所讨论的。

支持IPv6的常见问题

几种阻止一个应用支持IPv6的情况。下面的章节描述如何解决这些问题。

  • 协议中包含IP地址的文字。
  • 在配置文件中包含IP地址。
  • 网络检测。
  • 使用地级别的网络API.
  • Using small address family storage containers.(请自行翻译 add By 老陶 2016-05-22 15:15:36)

此部分原文:

		Several situations can prevent an app from supporting IPv6. The sections that follow describe how to resolve these problems.
	
	IP address literals embedded in protocols. Many communications protocols, such as Session Initiation Protocol (SIP), File Transfer Protocol (FTP), WebSockets, and Peer-to-Peer Protocol (P2PP), include IP address literals in protocol messages. For example, the FTP parameter commands DATA PORT and PASSIVE exchange information that includes IP address literals. Similarly, IP address literals may appear in the values of SIP header fields, such as To, From, Contact, Record-Route, and Via. See Use High-Level Networking Frameworks and Don’t Use IP Address Literals.
	IP address literals embedded in configuration files. Configuration files often include IP address literals. See Don’t Use IP Address Literals.
	Network preflighting. Many apps attempt to proactively check for an Internet connection or an active Wi-Fi connection by passing IP address literals to network reachability APIs. See Connect Without Preflight.
	Using low-level networking APIs. Some apps work directly with sockets and other raw network APIs such as gethostbyname, gethostbyname2, and inet_aton. These APIs are prone to misuse or they only support IPv4—for example, resolving hostnames for the AF_INET address family, rather than the AF_UNSPEC address family. See Use High-Level Networking Frameworks.
	Using small address family storage containers. Some apps and networking libraries use address storage containers—such as uint32_t, in_addr, and sockaddr_in—that are 32 bits or smaller. See Use Appropriately Sized Storage Containers.

确保IPv6 DNS64/NAT64兼容性

遵循以下的知道以确保IPv6 DNS64/NAT64在你的应用程序的兼容性。

使用高级的网络框架

应用需要可以建立在`高级网络框架` 或 `低级POSIX socket API网络框架`。在大多数情况下,高层次框架是足够的。它们有能力,易于使用,相比低级API拥有更少的缺陷。

1-5 网络框架和API图 网络框架和API图

  • WebKit. This framework provides a set of classes for displaying web content in windows, and implements browser features such as following links, managing a back-forward list, and managing a history of pages recently visited. WebKit simplifies the complicated process of loading webpages—that is, asynchronously requesting web content from an HTTP server where the response may arrive incrementally, in random order, or partially due to network errors. For more information, see WebKit Framework Reference.

  • Cocoa URL loading system. This system is the easiest way to send and receive data over the network without providing an explicit IP address. Data is sent and received using one of several classes—such as NSURLSession, NSURLRequest, and NSURLConnection—that work with NSURL objects. NSURL objects let your app manipulate URLs and the resources they reference. Create an NSURL object by calling the initWithString: method and passing it a URL specifier. Call the checkResourceIsReachableAndReturnError: method of the NSURL class to check the reachability of a host. For more information, see URL Session Programming Guide.

  • CFNetwork. This Core Services framework provides a library of abstractions for network protocols, which makes it easy to perform a variety of network tasks such as working with BSD sockets, resolving DNS hosts, and working with HTTP/HTTPS. To target a host without an explicit IP address, call the CFHostCreateWithName method. To open a pair of TCP sockets to the host, call the CFStreamCreatePairWithSocketToCFHost method. For more information, see [CFNetwork Concepts](CFNetwork Concepts) in CFNetwork Programming Guide. If you do require the low-level socket APIs, follow the guidelines in RFC4038: Application Aspects of IPv6 Transition.

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy