## 1 Introduction  
A Wireless Sensor Network (WSN) [1] is a set of tiny sensor nodes, which are resource-constrained in terms of energy, bandwidth, processing, and storage capacities. The main task of a WSN is to collect/aggregate data from the sensor nodes to a base station (or sink) using a hop-by-hop communication. The data collection can be either event-driven or periodic-based. In the event-driven class, data are delivered to the sink after the occurrence of events. In the periodic-based class, each sensor node periodically sends its measurement towards the sink. Sensor nodes could be compromised and controlled by an attacker. For example, an adversary can perform node capture attack by physically accessing the sensor node and uploading a malicious code to launch different types of attacks [2, 3]. To avoid this situation, some preventive security mechanisms such as authentication, cryptography, and key management could be implemented [4, 5]. However, it is necessary to deploy intrusion detection systems (IDSes) [6, 7, 8, 9] to deal with other non-preventiveattacks, such as selective routing/forwarding attack, where a malicious node refuses to forward some/all data packets that it receives. Some of the intrusion detection schemes that are proposed to deal with this attack use the watchdog principle, in which a node \(u\) that sent a packet to node \(v\) can overhear whether \(v\) has forwarded the packet to its downstream neighbor (or next hop) along the path towards the sink or not. This attack has been tackled in many research studies [10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23]. The simplest way to detect a selective routing attack is to use the watchdog technique. This istechnique not sufficient for detecting the selective routing attack as the leaf nodes, for example, in the tree-based topology are not monitored. Hence, it is important to increase the coverage of monitoring by including the upstream neighbors (previous hop). In addition, in some routing schemes [24; 25; 26], a node that is at \(l\)-hop away from the sink can choose its next hop from \(l\)-hop, \((l+1)\)-hop, and \((l-1)\)-hop away from the sink node. Thus, it is important for each node to monitor all its neighbors to make a correct routing choice. The role of an IDS is to identify the malicious nodes. The detection effectiveness of the IDS depends on the features that are used to describe the node's normal behavior. If the feature with respect to the monitored node exceeds a defined threshold, then the node is considered as malicious. However, adopting some features might mislead the detection system, and make it falsely accuse a legitimate node as malicious. Figure 1 clearly explains this situation. In the figure, each node monitors the packet receiving rate of its upstream neighbor along the path toward the sink \(B\). The value above each link \((a,b)\) indicates the sending rate (resp., receiving rate) to \(b\) (resp., from \(a\)). Figure 1 shows the normal traffic rates of the network. Figure 1 shows the state of the network when nodes \(D\), \(H\), and \(K\) become compromised and start behaving maliciously by dropping some packets. As \(D\), \(H\), and \(K\) reduce their sending rates, their respective downstream neighbors \(I\) and \(L\) also have to reduce their sending rates accordingly. As a result, node \(B\) will falsely accuse nodes \(I\) and \(L\) of being malicious and, hence, a false positive is recorded. This attack is called upstream-node effect, i.e., node is falsely accused as malicious because its upstream node is behaving maliciously. In this paper, we propose an intrusion detection system, which aims to detect the selective routing attack, prevents the upstream-node effect, and ensures that each node can monitor all its neighbors. The main contributions of the paper are the following:  
* We propose a one-dimensional one-class classifier, named relaxed flow conservation constraint, as an intrusion detection scheme to counter the upstream node effect.