Function 1: Initialization 
//Function: Initialization 
//prototype of Procedures 
NextHopSelection; 
CalculatePheromone; 
//initialize the global variable 
S = Source ID; 
//initialize probability distribution table 
= Number of nodes in network; 
= the set of neighboring nodes of node ; 
; 
dp = distribution probability; 
[][dp] = Source probability distribution table; 
; // is the probability of jumping from node to node 
//Initiate the routing table 
For (; ; ){ 
[dp]·; 

D = Destination ID (sink ID); 
FA [S, M, D] = forward ant [source ID, memory of forward ant, Destination ID]; 
Ph = amount of Pheromone; 
= initial energy; 
BA [S, M, Ph, D] = Backward Ant [Source ID, Memory of backward ant, 
Pheromone value, Destination ID]; 
= visibility array; 
= Intermediate node ID; 
Function 2: Decision making 
//If the intermediate node is equal to the destination node, 
then calculate the pheromone and construct the backward ant 
L1: If () 
CalculatePheromone; 
Construct the BA [S, M, Ph, ]; 
L2: NextHopSelection; 
If () 
Eliminate BA [, M, Ph, ]; 
//update the routing table 


= number of visited nodes by the backward ant 

Goto L3; 
Else 
Goto L2; 
Else 
NextHopSelection; 
Goto L1; 
L3: End 
Function 3: Next hop selection 
//procedure NextHopSelection 
Proc NextHopSelection { 
= next Intermediate node 
= actual energy; 
= Number of nodes; 
= visibility of ; 
= ; 
; 
= pheromone routing table; 
= probability of jump to s as a next hop; 


= ; 
= number of neighbors which are located in the destination direction; 
= array for storing probability amount of neighbors; 
; 
= 0; 
For (; ; ++){ 
If () 
; 
} 
; 
If (·FA) 
Loop happens then eliminate FA; 
Else 
{LastV= Count the member of M; 
If (LastV = 2) 
Delete M[i]; 
; 
; 
} 
} 
Function 4: Update of source probability distribution table 
//update the source probability distribution table 
For (; ; ++){ 
Check the RoutingTable · S; 
Find nodes which could be simultaneously Then 
= ; 
Update [dp]·; 
For other neighbor 
= ; 
Update [dp]·; 
//check the link failure 
If ([dp]·) //it means the link is lost 
{ 
; 
); 
Update [dp]·; 
} 
} 
Function 5: Pheromone calculation 
// procedure CalculatePheromone 
Proc CalculatePheromone{ 
Min.; 
Avg.; 
= number of visited nodes by forward ant 
; 
BA·Ph 
} 