小张 发表于 2013-6-7 10:39
感谢版主答复。
按照这个帖子上面的讨论结果,IPv6地址的后64位即if id是由PGW分配的,而我也确实看到 ...
我查了下规范。PGW确实会直接分配一个IPV6的地址。如下:“ PDN Address and Prefix (octet 6 to n+4) If PDN type value indicates IPv4, an IPv4 address is present in the PDN Address and Prefix from octet 6 to octet 9. Bit 8 of octet 6 represents the most significant bit of the IPv4 address and bit 1 of octet 9 the least significant bit. If PDN type value indicates IPv6, octet 6 contains the IPv6 Prefix Length. Octets 7 through 22 contain an IPv6 Prefix and Interface Identifier. Bit 8 of octet 7 represents the most significant bit of the IPv6 Prefix and Interface Identifier and bit 1 of octet 22 the least significant bit.”(7到22字节就是16个字节,就是一个完整的IPV6地址了)。 同样,在23401里也提到了:“For external PDN addressing for IPv6, the PDN GW obtains the IPv6 prefix from the external PDN using either RADIUS or Diameter client function. In the PDN Address field of the Create Session Response, the PDN GW includes the Interface Identifier and IPv6 prefix. The PDN GW sends Router Advertisement to the UE after default bearer establishment with the IPv6 prefix information for all cases.”。 这也是你在抓包文件中看到PGW给UE分配了64位interface ID的原因。 但需要注意的是,这里你看到的PGW给UE分配的64位interface ID以及完整的network prefix,看似是一个完整的IPV6地址,是可以用来上网了。但其实不然。UE得到这个所谓的IPV6地址后,还不能直接上网,根据规范的信令过程,在完成default bearer的创建后,UE还需要发送RS消息给PGW,PGW发送RA消息给UE重新分配一个可用于在internet网上路由的公网network prefix。UE需要再根据PGW通过RA消息分配的这个公网network prefix,本地根据规则再重新生成一个64位的interface id(和create session response消息里的interface iD不是同一个)加上PGW分配的network prefix构成一个可以在internet中路由的公网IPV6地址然后才可以上网。PGW在create session response消息中分配的64位interface id是为了帮助UE生成一个唯一的link local地址(比ipv4网络中的私网地址有效范围还要小,不能跨网段转发,可用于获取一个public ipv6地址)。 所以,信令流程是这样的: 1 PGW给SGW发送的create session reponse消息,在pCO字段中包含64位的network prefix,并且在PCO的第6个字节指明了一下network prefix的长度,例如50。并且PCO字段还携带了一个64位的interface ID,假设是ID-A。 2 完成default bearer和attach过程。UE得到了该IPV6地址的network prefix和ID-A。 3 UE根据步骤2得到的network prefix和ID-A生成一个唯一的ipv6 link local地址,并以该地址作为ip层的源地址向PGW发送RS消息,申请一个公网的IPV6地址。 4 PGW收到后,响应一个RA消息。包含公网IPV6地址的network prefix部分(64位)。 5 UE收到后,本地生成一个新的64位的interface OD,假设是ID-B。这个ID-B和ID-A可以是不一样的。再加上第4步PGW下发的公网ipv6地址的network prefix部分,就构成了一个完整的128位public IPV6地址。 6 UE使用第5步生成的public IPV6地址访问internet。 规范的原文如下:“ 5.3.1.2.2 IPv6 prefix allocation, renewal and release via IPv6 stateless address autoconfiguration When the PLMN allocates an IPv6 prefix, it is the PDN GW responsibility to allocate and release the IPv6 prefix. The PDN GW may use an internal IPv6 prefix pool in this case. The PDN GW allocates a globally unique /64 IPv6 prefix via Router Advertisement to a given UE. The procedure of stateless IPv6 address autoconfiguration is the following: After default bearer establishment the UE may send a Router Solicitation message to the PDN GW to solicit a Router Advertisement message. The PDN GW sends a Router Advertisement message (solicited or unsolicited) to the UE. The Router Advertisement messages shall contain the same IPv6 prefix as the one provided during default bearer establishment. If the UE receives an IPv6 prefix from a SGSN during the PDP Context activation procedure, it shall ignore it. After the UE has received the Router Advertisement message, it constructs a full IPv6 address via IPv6 Stateless Address autoconfiguration in accordance with RFC 4862 [18]. To ensure that the link-local address generated by the UE does not collide with the link-local address of the PDN GW, the PDN GW shall provide an interface identifier (see RFC 4862 [18]) to the UE and the UE shall use this interface identifier to configure its link-local address. For stateless address autoconfiguration however, the UE can choose any interface identifier to generate IPv6 addresses, other than link-local, without involving the network. For privacy, RFC 3041 [39], the UE may change the interface identifier used to generate full IPv6 addresses, without involving the network. Any prefix that the PDN GW advertises to the UE is globally unique. The PDN GW shall also record the relationship between the UE's identity (IMSI) and the allocated IPv6 prefix. Because any prefix that the PDN GW advertises to the UE is globally unique, there is no need for the UE to perform Duplicate Address Detection for any IPv6 address configured from the allocated IPv6 prefix. Even if the UE does not need to use Neighbor Solicitation messages for Duplicate Address Detection, the UE may, for example, use them to perform Neighbor Unreachability Detection towards the PDN GW, as defined in RFC 4861 [32]. Therefore, the PDN GW shall respond with a Neighbor Advertisement upon receiving a Neighbor Solicitation message from the UE. 从上述规范里蓝色字体还看到,从PGW分配给UE的prefix必须要是全局唯一的。所以我个人认为这也是CPI上为什么这么说的原因:“Each IPv6 UE is allocated a /64 prefix. IPv6 addresses are allocated as a prefix per primary PDP context or default EPS bearer. ” 这段话翻译成中文应该是:每个IPV6的UE都会被分配一个/64 prefix(CPI并没有说明该prefix是否是唯一的,但参照规范,应该是需要全局唯一的)。然后是IPV6的地址是针对每个primary pdp上下文呢或default EPS bearer作为一个prefix来进行分配的。也就是隐含的说明一个primary pdp context对应的IPV6 prefix是唯一的。所以,按此说法。后面的计算,针对UE的IPV6地址就是2^(64-50)=16384。而不是2^(64-50+64)了。 所以,个人认为CPI还是没有问题的。供参考。 |