## 4 Detailed Design
### Selfishness Assessment System  
Before taking the forwarding decision, FSF assesses the selfishness of the message relay candidate. To detect selfishness, this system takes into account the nodes' behaviour when they were selected as a relay node in the past. In such situations, a node can behave in three different ways:  
* **individually selfish--**according to the selfishness classification made in [7], individual selfishness can be defined as \"the unwillingness of a single node to relay the messages of all other nodes to conserve its limited resources\". These nodes do not accept to relay messages. * **socially selfish--**it can be defined as a type of selfishness in which a node belongs to a community, and it is willing to relay messages to the nodes within the same community, but it refuses to relay messages to the nodes outside its community [7]. Thus, these nodes will only relay messages for nodes with whom they have some social tie (friends or acquaintances). * **non-selfish--**those nodes accepting to relay messages to any other node. The selfishness assessment system is composed of two mechanisms: the detection scheme and the reputation system. Figure 4 shows the interaction between these components in the selfishness system. The detection scheme is implemented as a watchdog system. According to [43], watchdog systems are components installed in every network node, and that are responsible for overhearing data communication between nodes to decide about the neighbours' selfishness. In this work, we have used a collaborative watchdog system based on [37]. When a neighbour node has exhibited a selfish behaviour in the past, it tends to return a positive detection. On the contrary, it assesses the node as being non-selfish. However, despite a watchdog system has been proved as an interesting technique to detect the nodes' selfish behaviour, its decisions can be impacted by the problem known as outliers' detection. According to [44], outliers are normally defined as data points that have a significant difference from the rest of the data according to a certain measure. In this way, to decrease the impact of outliers, we have used a reputation system based on [45]. In this reputation system, upon each contact, one assessment is performed, even when the nodes are not selfish. Node A can get information from a neighbour B in the following two situations:  
**(i) Selfish Contact:**:  
Node A, using its monitoring mechanism during a contact, detects that a neighbour node B is selfish. **(ii) Non-Selfish Contact:**:  
Both nodes A and B are non-selfish. Thus, they may share with each other information about the selfishness of their neighbours. It is worth mentioning that, if the detection scheme collects an update about a neighbour, the reputation system is updated. The node reputation is defined taking into account the probability of being more cooperative than other nodes. This probability is based on logistic functions, as shown in Equation (8) [45]:  
\[P_{cooperation}(A,B)=\frac{1}{1+10^{\frac{R_{B}-R_{A}}{I_{d}}}}, \tag{8}\]  
where \(P_{cooperation}(A,B)\) describes the probability of node \(A\) to be more cooperative than node \(B\). \(R_{A}\) and \(R_{B}\) represent the reputations of both nodes \(A\) and \(B\), respectively, and \(F_{d}\) is a significant factor to stress the difference between the reputations of the nodes \((A,B)\). The node reputation update process is defined as a two-step process for each pair of contacts \((A,B)\): (i) check node \(B\) behaviour, and (ii) update node \(B\) reputation.