## 5 Intrusion Detection Scheme Based on Relaxed Flow Conservation Constraints
### One-Dimensional One-Class Classifier: Relaxed Flow Conservation Constraint
\(f^{t^{\prime}}(u,v)\) is composed of two terms: \(self^{t^{\prime}}_{u}\) and \(\sum_{w\in Child_{u}}g^{t^{\prime}}(w,u,v)\). When \(u\) is acting maliciously, \(self^{t^{\prime}}_{u}<self^{t}_{u}\) and/or \(\sum_{\omega\in Child_{u}}g^{t^{\prime}}(\omega,u,v)<\sum_{\omega\in Child_{u} }g^{t}(\omega,u,v)\), and hence \(d^{t^{\prime}}_{u}>d^{t}_{u}\). Node \(v\) is behaving normally at time \(t\) and \(t^{\prime}\). Thus, \(d^{t}_{v}=\left(\sum_{\omega\in Child_{v}}f^{t}(\omega,v)+\frac{\Delta}{\Delta t }\right)-f^{t}(v,Parent_{v})<\delta_{v}\), and \(d^{t^{\prime}}_{v}=\left(\sum_{\omega\in Child_{v}}f^{t^{\prime}}(\omega,v)+ \frac{\Delta}{\Delta t}\right)-f^{t^{\prime}}(v,Parent_{v})<\delta_{v}\). As \(f^{t^{\prime}}(u,v)<f^{t}(u,v)\), \(\sum_{w\in Child_{v}}f^{t^{\prime}}(w,v)<\sum_{\omega\in Child_{u}}f^{t}(\omega,v)\). In addition, node \(v\) will send at time \(t^{\prime}\) less packets compared to time \(t\). Formally, \(f^{t^{\prime}}(v,Parent_{v})<f^{t}(v,Parent_{v})\) as: \(\sum_{\omega\in Child_{v}}^{sel^{t^{\prime}}_{u}=sel^{t}_{u}\), and  
\[\sum_{w\in Child_{u}}g^{t^{\prime}}(\omega,v,Parent_{v})<\sum_{w\in Child_{u} }g^{t}(w,v,Parent_{v})\]  
At time \(t^{\prime}\), there will be less traffic flow in the neighborhood of node \(v\) when compared to time \(t\), and we will obviously observe less channel contentions and less packet collisions, which decreases the flow drop. Formally, \(d^{t^{\prime}}_{v}<d^{t}_{v}\). As a result, an increase in \(d_{u}\) has not made \(v\) increase its \(d_{v}\) and, hence, \(d_{v}\) is a path-free feature. Based on the above constraint, we derive the three following monitoring detection constraints (or path-free features) C1, C2, and C3 used by the monitoring node \(m\) to monitor its downstream node \(v\) and its upstream node \(u\) (as shown in Figure 2). Figure 2: Flow conservation constraint. \[C1: f(m,v)-g(m,v,Parent_{v})=d_{v}^{1}\leq\varphi_{m}^{v}\] \[\bigg{(}\sum_{\omega\in Child_{\omega}}f(\omega,v)+\frac{\Delta}{\Delta t} \bigg{)}-f(v,Parent_{v})=0\]0 \[\bigg{(}\sum_{\omega\in Child_{\omega}}f(\omega,v)+\frac{\Delta}{\Delta t} \bigg{)}-f(v,Parent_{v})=0\]1  
\(\varphi_{i}^{j}\), \(\varphi_{i}^{j}\), and \(\psi_{i}^{j}\) denote the thresholds used by the monitoring node \(m\) to check constraint (C1), constraint (C2), and constraint (C3) satisfaction with respect to the monitored downstream node \(v\) and upstream node \(u\). \(\varphi_{m}^{v}\), \(\phi_{m}^{u}\), and \(\psi_{m}^{u}\) are the highest values of \(d_{v}^{1}\), \(d_{u}^{2}\), and \(d_{u}^{3}\), respectively, observed by the monitoring node \(m\) during the training phase. C1 (or one-hop downstream monitoring and detection process) can be applied by each sensor node except for the sink node. Node \(m\), using the watchdog technique, checks if the data packets that it has sent to its parent node \(v\) are forwarded by the latter. If the difference between the two elements, \(f(m,v)\) and \(g(m,v,Parent_{v})\), exceeds the threshold \(\varphi_{m}^{v}\), node \(v\) will be considered malicious. Otherwise, it is normal. C2 (or one-hop upstream monitoring and detection process) can be applied by each sensor node, except for the leaf nodes in the tree-based network topology. As each node \(u\) (except the sink node) has to generate \(\frac{\Delta}{\Delta t}\) packets during each monitoring period and send them to its parent node. Node \(m\) checks if the number of packets \(self_{u}\) received from its upstream node \(u\) is less than \((\frac{\Delta}{\Delta t}-\varphi_{m}^{u})\). If so, node \(u\) is considered to be malicious. If node \(u\) is a leaf node, this judgment is sufficient for node \(m\). Otherwise, node \(m\) still cannot judge node \(u\) and it needs to check constraint (C3). C3 (or two-hop upstream monitoring and detection process) can be applied by each sensor node except for the leaf nodes as well as their parents in the tree-based network topology.