Research Article

A Probabilistic Spray-and-Wait Routing Algorithm Based on Node Interest Preference in Delay Tolerant Networks

Algorithm 2

Pseudocode for NIP-PSW’s Spray phase.
Input:
, set of nodes in the network
, the threshold of node interest preference ()
, the number of connections of
, set of messages carried by
, set of messages carried by
1: if encounters then
2: , update and
3: delete messages in and according to their own
4: if then
5:  for each message in do
6:    directly forwards to
7:  end for
8: end if
9: for each message in do
10:  ifthen
11:   calculate according to formulas (16) and (17)
12:   forward copies of to
13:  end if
14:  else ifthen
15:  calculate according to formulas (16) and (17)
16:  forward copies of to
17:  end if
18:  else if&&
     then
19:   calculate according to formulas (16) and (17)
20:   forward copies of to
21:  end
22: end for
23: end if