# An Enhanced Message Distribution Mechanism for
## 4 Message Distribution Mechanism
### Network Invariants Checker  
When the app plane lacks global information, it is prone to competition and conflict. This is an obvious problem in the SDN architecture. Mutual perception between apps will bring great development difficulties, and mutual transparency will bring conflicts between apps [25]. For the network, in addition to degrading network performance, conflicts between apps can paralyze the entire network. Routing loops and black holes are the most common serious problems. Take Figure 5 as an example to briefly introduce the causes of routing loops and black holes. The host under the \(A\) switch sends the data packet to the host under the \(F\) switch. The pre-routing is \(A\to B\to D\to F\). Because of the \(X\) app's strategy, which plans to use the link \(D\to C\to E\to F\), so it sends the flow-mod message to switch \(D\) and adds the flow table of routing strategy, leading to overwrites the previous policy (may not be issued to the \(C/E/F\) switch at the same time). When the data packet arrives at \(C\), the \(Y\) app considers the path \(C\to B\to D\to F\) to be reasonable and continues to send the flow table to switch \(C\) to cover the policy. At this time, the data packet will be routed to switch \(B\). This is an example of a routing loop because of the inter-app conflict. The black holes generally occur when some links fail down, or a node is dormant due to the energy-saving or the placed app, and the data packets that are routed to that node by other apps will cause a black hole phenomenon. Figure 4: Distribution Mechanism by Protocol-irrelevant Way. The location of our EMD enhancement has a natural advantage and it can guarantee the basic functions of the network, because it can receive all of the apps' response messages and get the global view of the data plane. We set two network invariants, namely no-loop and no-blackhole. When these two functions are enabled, our module will follow Algorithm 2 to check the control messages that are issued by each app to ensure that there are no routing loops and black holes in the network. ```
0:\(pkt\_out,flow\_mod\)
0: none
1:initialization:
2: set the dictionary strut \(FLAG=\{xid:\{\prime\textit{mutil\_app}^{\prime}:\textit{ bool, }^{\prime}\textit{dealt}^{\prime}:\textit{ list}\}\}\), \(FT=[\ ]\). 3:end initialization
4:for each \(pkt\_out\) in the NBI do
5:if\(FLAG[pkt\_out.xid][\prime\textit{mutil\_app}^{\prime}]\) is not \(TRUE\)then
6: pass the \(pkt\_out\) to the core module
7:elseif\(pkt\_out.dpid\) or \(pkt\_out.output.dpid\) is in \(FLAG[pkt\_out.xid][\prime\textit{dealt}^{\prime}]\)then
8: drop the \(pkt\_out\)
9:else
10:if\(check\_alive(pkt\_out.output.dpid)\) is \(TRUE\)then
11: pass the \(pkt\_out\) to the core module
12: put the \(pkt\_out.dpid\) into \(FLAG[pkt\_out.xid][\prime\textit{dealt}^{\prime}]\)
13:else
14: update the network topo to apps
15:endif
16:endif
17:endfor
18:for each\(flow\_mod\) in the NBI do
19:\(depcopy(exp\_ft,FT[flow\_mod.dst])\)
20: change \(exp\_ft\) according to \(flow\_mod\_actions\)
21:if\(check\_loop(exp\_ft)\) is \(TRUE\)then
22: drop the \(flow\_mod\)
23:else
24: pass the \(flow\_mod\) to the core module
25: update the \(FT[flow\_mod.dst]\) using \(exp\_ft\)
26:endif
27:endfor
```  
**Algorithm 2** Network Invariants Checker. The \(FT\) in Algorithm 2 is a forwarding tree that takes the destination node as the root node, then \(check\_alive()\) and \(check\_loop()\) are functions to check whether the node is alive and check whether there is a loop in the forwarding tree, respectively. Taking Figure 5 as an example, the forwarding tree of node \(F\) that is based on the shortest-path-first is Figure 6a. \(X\) app modifies the forwarding tree by changing \(flow\_mod\) at node \(D\), shown as Figure 6b, and there is no routing loop at this time. After \(Y\) app modifies the \(flow\_mod\) at point \(C\)  
Figure 5: An Example of Routing Loop. the forwarding tree is modified to Figure 6c. At this time, a loop has been formed, so we delete this \(flow\_mod\) to prevent routing loops.