## 6 Implementation and Evaluation
### Theoretical Calculation  
When using multicast group communication, the number of packets that are sent depends on the topology of the network. In our star topology, all nodes that are one hop away can be reached with just one multicast packet. After the first hop, the paths are not shared by any node and the packets have to travel similar to unicasts along them. When the requests reach their destinations, replies are generated and are sent back using non-confirmable unicast messages. Thus, in the case of a successful communication, the number of transmitted packets can be obtained as follows:  
\[pkts_{N_{success}}=1+G(2N-1) \tag{7}\]  
Figure 19: The reliability of the complete group is less than the reliability of individual members (Figure 18). Again, the reliability of the complete group is a lot better when using entity based group communication.  
Taking into account the probabilities of failure at each link-transmission (see Section 6.2.3), the average number of transmitted packets when using multicast group communication can be obtained as:  
\[pkts_{N_{mcast}}=(\sum_{l=0}^{2N-1}l(1-l)^{i}\times(iG+1))+(1-l)^{2N-1}\times(1+ G(2N-1)) \tag{8}\]  
This formula takes into account the fact that the request or reply can get lost at any intermediate hop (total of \(i=0,\ldots,2N-1\) possibilities with the probability \(l(1-l)^{i}\)), resulting in a different number of packets being transmitted (\(iG+1\)).  
When using our group communication solution, all transmissions are unicast and thus in the case of a successful communication, the number of transmitted packets can be obtained as follows:  
\[pkts_{N_{success}}=2 NG \tag{9}\]  
And the average number of packets in case of failure (_i.e._, packet loss somewhere on the path) as:  
\[pkts_{N_{failure}}=\left\{\begin{aligned} &\frac{G\sum_{i=0}^{2N-1}l(1-l)^{i} \times(i+1)}{\sum_{i=0}^{2N-1}l(1-l)^{i}},&\quad l>0\\ & 0,&\quad l\leq 0\end{aligned}\right. \tag{10}\]  
The formula is normalized as the sum of all probabilities in the nominator is not 1 since it does not include the probability of success over all links \(P_{N}\). To avoid division by zero we set \(pkts_{N_{failure}}=0\) when \(l\leq 0\).  
And the average number of transmitted packets in these cases of retransmissions can be calculated as:  
\[pkts_{N_{r}}=r\times pkts_{N_{failure}}+\ pkts_{N_{success}} \tag{11}\]  
If the last retransmission attempt fails, the sender is notified about the failed transmission. Thus the probability for failure for an N-hop communication:  
\[R_{N_{failure}}=(1-P_{N})^{5} \tag{12}\]  
And the average number of transmitted packets in this case can be calculated as:  
\[pkts_{N_{5}}=5\times pkts_{N_{failure}} \tag{13}\]  
Thus the average number of transmitted packets for N-hop confirmable CoAP unicast communication can be calculated as follows:  
\[pkts_{N_{entity}}=\left[\sum_{r=0}^{4}R_{N_{l}}\times pkts_{N_{r}}\right]+R_{ N_{failure}}\times pkts_{N_{5}} \tag{14}\]  
Experimental Evaluation  
When multicasts are used, one request is sent to multiple destinations, and one reply is sent by each member. For our five nodes that are 1-hop away, assuming there is no packet loss in the network, the number of transmitted packets is thus six packets (an average of 1.2 packets/member). When the network is lossy the number of packets can only become less, as packets are being dropped. This can be clearly seen in Figure 20 for 1-, 2- and 3-hop networks. On the other hand, when using unicasts the number of packets increases as the loss increases. This is a logical result of packets being retransmitted by CoAP to compensate for the packet loss. The dashed and dotted lines in Figure 20 are the theoretically expected values, while the points are the actual obtained results from the experiments. It is clear that there is a good match between both.