# M-Emu: A Platform for Multicast Emulation
## 4 Validation
### Case Study  
We take the emulation of PIM-SM as an example to explain in detail how the various parts of M-Emu cooperate to complete the multicast emulation. We emulate PIM-SM in a fat tree topology, which is shown in Figure 4.  
PIM-SM is the most popular IP multicast at present. The multicast tree of PIM-SM is a Shared Tree. Each source DR selects a node from the cRPs set as the RP. Each receiver-side DR then selects this RP as GP. First, we need to deploy the DRs. M-Emu provides the DR deployment interface, which is  
void SetDR( std::map<std::string,Ptr>nodeMap, constNodeContainernodes, NodeContainer*senderDR, NodeContainer*receiverDR)  
Among the parameters of this interface, _std::map<std::string,Ptr>nodeMap_ maintains the mapping between the node ID in the topology file and the node ID in the emulated network. A topology file is a file provided by users that describes the topology. The emulators or simulators can build a topology based on this file. The _nodeMap_ is adopted because these two IDs are often inconsistent. _const NodeContainer nodes_ contains all nodes in the topology. _NodeContainer*senderDR_ and _NodeContainer*receiverDR_, respectively, store the pointers of the source-side DRs and receiver-side DRs. In this example, we add A1 to _senderDR_ and A2 to _receiverDR_. The simplest way to do this is to find the IDs of A1 and A2 from the topology file, then use the _nodeMap_ to find the node pointers of A1 and A2, and finally add them to the corresponding _nodeContainer_. Second, we deploy the cRPs. M-Emu provides the RP deployment interface on the control plane, which is  
Figure 4: PIM-SM Emulation. void SetRP( std::Map<std::string,Ptr>nodeMap, constNodeContainerNodes, NodeContainer*cRPs)  NodeContainer*RP contains pointers to all cRPs. In this example, we add R1, R2, R3 and R4 to this nodeContainer. When A1 receives data from U1 or U2, A1 runs the RP-selection method to select a node from the cRP set as the RP. M-Emu provides the RP-selection method interface on both the control plane and data plane, which is  
uint32_t GetRootNode( constNodeContainer cRPs, uint8_t*buffer,void*info) ```
The return value of this interface is the ID of the RP we selected. _uint8_t*buffer_ holds the multicast data. _void* info_ contains external information on which the algorithm depends. The control plane can add some global information to _info_, while the data plane can add only local information to _info_. We approximate that PIM-SM selects the RP using the hash of the multicast ID, which is provided in _uint8_t*buffer_. In this example, we assume that A1 selects R1 as RP for the current multicast group. After receiving the multicast data, R1 will register the mapping between its NA and multicast ID with NRS, as described in the previous section. At some point, A2 will receive a data request from U3. A2 runs the GP-selection method to select a node from the multicast tree as GP. M-Emu provides a GP-selection algorithm interface on both the control plane and data plane, which is  
uint32_t GetGraftNode( uint8_t*buffer,void*info)
```

The return value of this interface is the ID of GP. The difference between the control plane and the data plane of the interface is still reflected in the content of the _info_. In this example, the DR on the receiver side selects the root node as GP each time. To find the address of the root node, the DR queries the address list of nodes in the multicast tree from the NRS based on the multicast ID in _uint8_t*buffer_. The first node in the list is the root node, because in every multicast tree, the first node to register with the NRS must be the root node. When R1 receives a joining request from A2, it sends multicast data back to A2. When the multicast data passes through C1, C1 determines whether to create the MFT entry based on the State Reduction method. M-Emu provides the interface on both the control plane and data plane, which is

```
boolStateReduction( uint8_t*buffer,void*info)
```

If the return value of this interface is 0, the node should not register MFT entries.