## 3 Proposed Model
### Model Phases
```
1.DeleteAcknowledgedMessages(buffer, ackedMessagesTable):
2.For each message in buffer:
3.If message.ID is in ackedMessagesTable:
4.Remove message from buffer
5.UpdateMetingTime(node):
6.IfotherNode is in node.hostsTable:
7.UpdateMeetingTime(node, otherNode)
8.Else:
9.AddNodeToHostsTable(node, otherNode)
10.ExchangeAckedMessagesTables(connection):
11.For each node in connection:
12.AddDeliveredMessagesToTable(node)
13.SendAckedMessagesTable(node, connection)
14.UpdateHostsTable(connection):
15.For each node in connection:
16.If node is not in model.hostsTable:
17.AddNodeToHostsTable(node1, node)
18.AddDeliveredMessagesToTable(node):
19.For each message in node.receivedAckedMessagesTable:
20.If message.ID is not in node.ackedMessagesTable:
21.Add message.ID to node.ackedMessagesTable
```  
**Algorithm 1**Initialization Phase  
```
1.PriorizeDeliverableMessagesPhase():
2.AccumulateDeliverableMessages()
3.ExchangeDeliverableMessages()
4.UpdateAckedMessagesTable()
5.IfEnergyExceedMreshedM():
6.MoveToNextPhase()
7.Else:
8.CloseConnectionToPreserveEnergy()
9.AccumulateDeliverableMessages():
10.For each message in buffer:
11.Ifmessage.Destination is connected node:
12.Add message to deliverableMessagesList
13.ExchangeDeliverableMessages():
14.Send deliverableMessagesList to connected node
15.Receive deliverableMessagesList from connected node
16.UpdateAckedMessagesTable():
17.For each message in receivedMessagesList:
18.If message not in ackedMessagesTable:
19.Add message to ackedMessagesTable
20.EnergyExceedMreshold():
21.Ifnode.energy>thresholdEnergy:
22.Return true
23.Else:
24.Return false
25.MoveToNextPhase():
26.Proceed to next phase of routing protocol
27.CloseConnectionToPreserveEnergy():
28.Close connection with connected node
29.Operate as direct delivery node * **Phase 3: Procedures for Non-Deliverable Messages** This phase represents a fundamental aspect of the newly devised routing protocol. At this stage, the message buffer exclusively contains non-deliverable messages, identified as messages with final destinations other than the connected node. The primary objective is to collect messages designated for transmission to the other node in a temporary output buffer. The selection of messages for the output buffer relies on specific criteria outlined in Algorithm 3. The initial step, \"for each message in the buffer\", indicates the potential implementation of this phase where all messages are processed concurrently. However, due to the absence of multithreading in the simulator's implementation, messages are evaluated sequentially. The processing sequence begins by addressing scenarios where at least one node fails to reach the destination. In this context, x represents the time elapsed since the current node encountered the destination node, while y denotes the duration since the other node met the destination node. If the current node has not encountered the message's intended destination while the other node has, the message is duplicated into the output buffer. Conversely, if the current node has reached the destination while the other node has not, the message is excluded from the output buffer. However, in situations where both nodes have reached the destination, if the current node's meeting time with the destination precedes that of the other node, the message is omitted from the output buffer. Conversely, if the current node's meeting time is later than that of the other node, the message is copied into the output buffer. This decision-making process is depicted in the flowchart, particularly when testing the condition x < y.