51学通信技术论坛

 找回密码
 立即注册
搜索
查看: 13164|回复: 1
打印 上一主题 下一主题

请教关于UE的IPv6前缀分配问题   [复制链接]

Rank: 9Rank: 9

楼主
发表于 2013-6-6 19:51:05 |显示全部楼层
小张 发表于 2013-6-6 12:33
能否请爱总帮忙解释一下CPI的这段描述:

The allowed netmask range for IPv6 APNs is from /44 to /62. ...

我的理解是这样的,IPV6的地址128位分成两段,一段是network prefix,相当于IPV4网络当中的IP Subnet即网络位,是64位。这64位当中又有一部分是IANA分配的,剩下的才是运营商可以自行分配的,比如本例中的44到62位。还有一段是主机部分,也是64位。通常是终端自己生成的,例如根据48位的MAC地址通过EUI-64扩展的方式自动生成。所以,下面这句话还是好理解:

:“number of available IPv6 address prefixes = 2^(64-x)”。

注意,这里提到的不是可以的IPV6 address,而是可用的IPV6 address prefix。两者不一样。后者实际上是指运营商可以在标准掩码64位的基础上可以再划分多少个子网,还是网段不是IP地址。就像运营商从IANA申请到一段200.1.1.0/24的网段一样,可以拆分成2个25位的网段一样。但IPV4的话,还是这个例子,那24~32位都可以用运营商来分配。所以200.1.1.0/24最多你也可以拆分成2^8个32位地址。

但IPV6就不一样了,第二部分的64位是主机ID,是由终端自己生成的。不受运营商控制。所以不能由运营商规划,所以CPI说的没错的。/50可用的并不是2^78,而是2^14。

51学通信(www.51xuetongxin.com):致力打造最好的通信技术在线学习平台 。

使用道具 举报

Rank: 9Rank: 9

沙发
发表于 2013-6-7 16:42:21 |显示全部楼层
小张 发表于 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还是没有问题的。供参考。

51学通信(www.51xuetongxin.com):致力打造最好的通信技术在线学习平台 。

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

站长邮箱|Archiver|51学通信 ( 粤ICP备11025688 )

GMT+8, 2024-5-3 00:44 , Processed in 0.023050 second(s), 9 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部