# A Credit-Based Congestion-Aware Incentive Scheme for DTNs
## 4 A Credit-Based Congestion-Aware Incentive Scheme
### Message Acceptance Selection Mechanism  
As above, we know that a node is prevented from discarding messages before the messages are delivered to the destination node. Therefore, if a node accepts too many messages quickly, it may lose the chance to buffer other messages that can potentially bring more benefits. Thus, a node should assess the buffer congestion degree and then adjust the message acceptance threshold according to the self congestion degree. When congested, a node should increase the message acceptance threshold to accept those messages that bring more benefits. Otherwise, the node should decrease the acceptance threshold to store as many messages as possible. Figure 5: Encounter ticket. Figure 6: Dropping a message deliberately. In order to assess the node congestion degree, the time is divided into many periods of time \(T\), and a node calculates the _messages changing number_ in a period \(T\). **Definition 1**. : _(incoming message): When nodes \(N_{i}\) and \(N_{j}\) meet, the incoming message of node \(N_{i}\) is the message from node \(N_{j}\), whose delivery delay satisfies the condition that \(Time_{N_{j}}^{delivery}-Time_{N_{i}}^{delivery}\geq Threshold\), where Threshold denotes a delay threshold._  
It is noticed that node \(N_{i}\) may not accept an _incoming message_ if congested. **Definition 2**. : _(outgoing message): When nodes \(N_{i}\) and \(N_{j}\) meet, the outgoing message of node \(N_{i}\) is the message that has been transferred from the buffer to node \(N_{j}\)._  
**Definition 3**. : _(messages changing number): The messages changing number is the difference between the number of incoming messages and outgoing messages in a period \(T\), as shown in Equation (5):_  
\[\mathit{MessagesChangeT}=\mathit{MessagesInT}-\mathit{MessagesOutT}, \tag{5}\]  
where \(\mathit{MessagesInT}\) denotes the number of _incoming message_ in a period \(T\), \(\mathit{MessagesOutT}\) denotes the number of _outgoing message_ in a period \(T\), and \(\mathit{MessagesChangeT}\) denotes _messages changing number_. To restrain the effect of temporary burst, when the current period \(T\) is time out, the new _message changing number_ is predicted by the Exponentially Weighted Moving Average (EWMA) method in Equation (6):  
\[\mathit{MessagesChangeTnew}=\alpha\times\mathit{MessagesChangeTcur}+(1-\alpha) \mathit{MessagesChangeTold},\ 0\leq\alpha\leq 1, \tag{6}\]  
where \(\mathit{MessagesChangeTnew}\) is the new _message changing number_, \(\mathit{MessagesChangeTcur}\) is the _message changing number_ of current period, \(\mathit{MessagesChangeTold}\) is the history value, and \(\alpha\) is the weight of \(\mathit{MessagesChangeTcur}\). When the _messages changing number_ is larger than a node's current free buffer size, it means that the node will be congested; then the message acceptance selection mechanism adopts the _additive increase_ method to slowly increase the acceptance threshold value to accept those messages that can bring more credits. When _messages changing number_ is smaller than node's current free buffer size, the node will adopt the _multiplicative decrease_ method to quickly decrease the acceptance threshold value to store as many messages as possible. The pseudocode of message acceptance selection mechanism is shown in Algorithm 1. ```
1:if a period \(T\) is time out then
2: Calculate the new _messages changing number_ by EWMA
3:if the _messages changing number_ is larger than the current free buffer size then
4:\(\mathit{Threshold}=\mathit{Threshold}+\mathit{Ad}\)
5:else
6:\(\mathit{Threshold}=\mathit{Threshold}\times\mathit{Mul}\)
7:endif
8:endif
```  
**Algorithm 1**Message acceptance selection mechanism. In Algorithm 1, _Threshold_ is the message acceptance threshold in definition 1, \(\mathit{Ad}\) is the message acceptance threshold increment, and \(\mathit{Mul}\) (\(0<\mathit{Mul}<1\)) is a multiplicative factor.