# PIM-SM IPv6 using Embedded RP

Load **multicast.init.cfg**

```
#IOS-XE
config replace flash:multicast.init.cfg
 
#IOS-XR
configure
load bootflash:multicast.init.cfg
commit replace
y
```



Configure R9 and XR4 with addresses 2001:db8:1:1::X/128 where X is the router number.



Using embedded RP, join R2 to two groups, one per RP. R4 should be able to send traffic to these groups and get a response from R2.













































## Answer <a href="#id-9ad80a48-6a7e-4955-aa21-f4a5d4329af6" id="id-9ad80a48-6a7e-4955-aa21-f4a5d4329af6"></a>

```
#R9
int lo100
 ipv6 add 2001:db8:1:1::9/128
 ospfv3 1 ipv6 area 0
!
ipv6 pim rp-address 2001:db8:1:1::9

#XR4
int lo100
 ipv6 add 2001:db8:1:1::E/128
!
multicast-routing
 add ipv6
  int lo100 enable
!
router ospfv3 1 area 0
 int lo100
!
ipv6 access-list EMBEDED_RP
 permit ipv6 any ff75:E40:2001:db8:1:1::/96
!
router pim add ipv6
 embedded-rp 2001:db8:1:1::e EMBEDED_RP
```



## Explanation <a href="#id-42bd8df2-36cf-4209-b94b-152914a14ef1" id="id-42bd8df2-36cf-4209-b94b-152914a14ef1"></a>

IPv6 multicast addresses are so large that we can easily embed information into the group address itself.



One way that information is embedded is by setting the scope in the multicast address. The scope is set as the fourth hex character. The following scopes are defined:

| **Prefix** | **Scope**          |
| ---------- | ------------------ |
| FF01       | Interface Local    |
| FF02       | Link Local         |
| FF04       | Admin Local        |
| FF05       | Site Local         |
| FF08       | Organization Local |
| FF0E       | Global             |



Additionally, the thrid hex character is made up of four flags:

```
|   8    |  4 |  4 |  4 |  4 |    8   |       64       |    32    |
+--------+----+----+----+----+--------+----------------+----------+
|11111111|flgs|scop|rsvd|RIID|  plen  | network prefix | group ID |
+--------+----+----+----+----+--------+----------------+----------+
           |
           |
           |
        0 R P T
```



The flags are composed as follows:

* Reserved
  * Always set to 0
* R (RP embedded)
  * When set to 1, indicates that RP information is embedded. The P and T bits must also be set to 1.
* P (Prefix embedded)
  * When set to 1, indicates that address prefix information is embeddd in the multicast group address. When set to 1, the T bit must also be set.
* T (Transient/Temporary)
  * When set to 1, it indicates a transient/temp address. When set to 0, it indicates a well-known/IANA-allocated address.



Embedding prefix information is done for two puroses - one is embedding the RP, and the other is to produce organizationally-unique address blocks.



For IPv4, we had the GLOP space, in which the organization’s 16bit AS could be embedded into the group address to produce a unique group address block. However, this was problematic because many organizations have 32 bit ASNs, not 16 bit.



The IPv6 equivalent of this is using a unicast-prefix embedded group block. The P and T bits are set to 1, and the prefix length and network prefix are embedded into the group address itself. This produces a unique group address block that cannot overlap with any other organization’s group addresses. For example, if an organization owns 2001:db8:1::/48, this maps to FF3X:0030:2001:db8:1::/96. The X is the scope, the next 00 is because the RIID is not used. The 30 is the prefix length in hex (48), then the actual prefix follows. The organization is left with 32 bits for group IDs to use in this block.



This embedding technique is also used by the embedded RP feature. Instead of encoding a global unicast prefix block however, we embed the RP’s loopback address by encoding the prefix and then encoding the RIID (RP’s Interface ID). We only have 4 bits for the RIID (one hex character), and it cannot be 0, so it must be in the range 1-F. The maximum prefix length is 64.



For example, the addres FF75:0140:2001:db8:100:200::1234 means the following:

* FF7 means that this is a multicast address and the R, P and T flag are all set. This means that this is an embedded RP address.
* The next 5 means that the scope is site local.
* The next 0 is reserved
* The next 1 means that the RP’s Interface ID is 1.
* The next 40 means the following prefix is 64 bits long (0x40 in hex)
* Next is the prefix itself - 2001:db8:100:200::/64
* Finally, we have the group ID which is 0:1234



So the RP address for the multicast group above is 2001:db8:100:200::1.



Note that you can also use prefix lengths less than 64, for example a /32. The prefix length just tells the router where the RP’s prefix ends and the multicast group begins.



By using this technique, senders and receivers can signal the RP within the data plane itself (the multicast address) and we don’t need to statically or dynamically (BSR) define the RP in the network. Note that this can only support RP redundancy by using an Anycast IP as the embedded RP address. Also note that embedded RP is not supported for PIM Bidir (I believe because there is no way to signal that the RP is bidir-capable by using this method).



As an aside, the SSM range also uses the P and T bits set to one. SSM ranges begin with FF3X, where X is the scope. However, SSM always sets the prefix length and prefix to all zeros. So you can think of the SSM ranges as using this embedded address format but with all zeros as the “host/prefix.” (This works because the host is signaled as a separate field in MLDv2 - it never needs to be signaled within the embedded group address. So SSM can use this same range but always with zeros as the host/prefix).



Let’s now test the embedded RP feature. To start, all routers simply support basic IPv6 PIM and form IPv6 PIM adjancencies. All we need to do is define the loopbacks on the RPs, advertise them into the IGP, and then send/receive traffic to the correctly-calculated group addresses.

```
#R9
int lo100
 ipv6 add 2001:db8:1:1::9/128
 ospfv3 1 ipv6 area 0

#XR4
int lo100
 ipv6 add 2001:db8:1:1::E/128
!
router ospfv3 1 area 0
 int lo100
!
multicast-routing
 add ipv6
  int lo100 enable
```



Additionally, we also need to tell the RPs that they are acting as RP at those addresses. Otherwise, these routers will reject Registers destined to them and reject PIM Joins destined for them as RP. When you define the RP as a local address, the router automatically creates the PIM tunnels which are used for decapsulating PIM Registers.



Without doing this step, the router rejects PIM Registers. For example:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FnVBawiQL1UUYR3NU5T1g%2Fimage.png?alt=media&#x26;token=ee703a08-8e78-4972-a4f2-5d7b160b02ba" alt=""><figcaption></figcaption></figure></div>



So we must define the local loopback address as an RP address. On IOS-XE this is done by simply defining the router as an RP. On IOS-XR, this is accomplished by defining the router to act as an embedded RP for a given group range. On IOS-XR, defining the router as an RP does not work, because IOS-XR has a default ff70::/12 range for embedded RP which points to a null RP. Even if you define the router as an RP statically, the group ranges in ff70::/12 will always be rejected because the RP is null (::) for that range. You must manually populate the IOS-XR IPv6 group mappings with embedded ranges.

```
#R9
ipv6 pim rp-address 2001:db8:1:1::9

#XR4
ipv6 access-list EMBEDED_RP
 permit ipv6 any ff75:E40:2001:db8:1:1::/96
!
router pim add ipv6
 embedded-rp 2001:db8:1:1::e EMBEDED_RP
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F2OBPh9TeUC43cqnoiy8p%2Fimage.png?alt=media&#x26;token=f2748acb-5592-4e9b-b992-316e11930c05" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F4uyquzPiFiYGXWpCy2Vk%2Fimage.png?alt=media&#x26;token=b583711e-a805-465a-9a72-2fbc89a79e60" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FXW9QE6S85O8RAMvRj5Zo%2Fimage.png?alt=media&#x26;token=47a35fb3-cc77-4207-8927-28f504f22369" alt=""><figcaption></figcaption></figure></div>



On R2, we’ll enable IPv6 multicast and join two groups:

* FF75:940:2001:db8:1:1::1234
  * The RIID is 9 and the prefix is 2001:db8:1:1::/64
* FF75:e40:2001:db8:1:1::1234
  * The RIID is E and the prefix is 2001:db8:1:1::/64

```
#R2
ipv6 multicast-routing
!
int gi2.525
 ipv6 mld join-group FF75:940:2001:db8:1:1::1234
 ipv6 mld join-group FF75:e40:2001:db8:1:1::1234
```



On R5, we see two (\*, G) entries are created, and the RP address has been extracted from the group address:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FKDqEfN2EjEucRRt7rCwy%2Fimage.png?alt=media&#x26;token=ffd91f86-6ab5-45da-8a50-08d9b534332d" alt=""><figcaption></figcaption></figure></div>



This can also be seen in **show ipv6 pim group-map**

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FaHKDYOoFNqAyALD4qr60%2Fimage.png?alt=media&#x26;token=01c8df0b-5402-4071-9d4f-61de4ebc85be" alt=""><figcaption></figcaption></figure></div>



The (\*, G) joins make their way to both RPs:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FQeqTEIgZrd4s7RGY6mWU%2Fimage.png?alt=media&#x26;token=31701e3a-c133-4d5b-9f12-baf2cc20d0d4" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FrD82WVC2eBOdiGEaJcco%2Fimage.png?alt=media&#x26;token=a58a7b9a-4a27-4c49-9a18-a9ebd5d356c2" alt=""><figcaption></figcaption></figure></div>



If we send traffic from R4, we should see a reply from R2.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FtcWjrPQ6OJDsGUzmi30b%2Fimage.png?alt=media&#x26;token=c0289178-84aa-4740-9305-f0eb8218d307" alt=""><figcaption></figcaption></figure></div>



XR3, acting as FHR, finds the RP information embedded in the group address, and registers the traffic with the RP. This is normal PIM-SM behavior except the RP is learned via the group address itself. Note that this is buggy on the CSR1000v - it will successfully decode the RP address but will not register the packets. For this reason we can only use XRv as the FHR.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FXXlGBogcJTuwq9OFFE0d%2Fimage.png?alt=media&#x26;token=a141e497-d2ba-4ed3-9ce7-1f78914a5e2b" alt=""><figcaption></figcaption></figure></div>



## Summary <a href="#id-0e440320-8d9d-403c-8550-cd0eb8a7cb00" id="id-0e440320-8d9d-403c-8550-cd0eb8a7cb00"></a>

Embedded RP is a neat feature for IPv6 PIM which allows you to embed the RP address directly in the IPv6 group address. The RP’s interface ID, prefix, and prefix length are encoded in the address. Routers will extract this from the group addresses in the ff70::/12 range automatically. This means that you do not need to set the RP anywhere. All you need to do is define the local RP as an RP so that it creates the decap Register tunnels and accepts PIM Joins. On IOS-XE this is defined simply by setting **ipv6 pim rp-address \<loopback>**. On IOS-XR this is defined by setting **embedded-rp \<loopback> \<ACL referencing ::/96 range>**.



The slight problem with this is that the application must have a way to learn the RP address to be able to encode the address into the group address anyways. In my opinion, it seems to be a similar level of difficulty for the application to learn the source address instead, and SSM could be used instead of SM. However, for applications in which there are many sources, this could be a good use case.



Also note that embedded RP could be considered a security risk, as the hosts are the ones who dictate which router is the RP. If you don’t want to allow hosts to be able to do this, you can disable the embedded RP feature on a router using **no ipv6 pim rp embedded** on IOS-XE and **router pim add ipv6 embedded-rp disable** on IOS-XR.
