logo

Simulation Analysis of Packet Delivery Probability

Write a program in C++ to determine the paths with minimum and maximum energy costs for routing a packet from node S to node D in a sensor network topology.

7 Pages764 Words10 Views
   

Added on  2022-08-18

Simulation Analysis of Packet Delivery Probability

Write a program in C++ to determine the paths with minimum and maximum energy costs for routing a packet from node S to node D in a sensor network topology.

   Added on 2022-08-18

ShareRelated Documents
Running head: NETWORKING AND PACKET DELIVERY SIMULATION
Networking and packet Delivery simulation
Name of the Student
Name of the University
Authors note
Simulation Analysis of Packet Delivery Probability_1
NETWORKING AND PACKET DELIVERY SIMULATION
1
For the given problem of delivering the packets from the vertex S to Vertex D. The
branches or the edges outwards to the other edges helps to grow the number of connected
components. While adding the edges from one node to another the smallest weight is considered
to the next node. The process continues until the final destination node is reached and connected.
With every iteration in order to add to the path the edge with the lowest cost is fast
considered. Initially the process starts with lowest cost edge as an example for this case 2 that
connects to A node from the source. After this the next edge is added with the lowest weighted
edge with the weight 2. Here it can be mentioned that, the selected two edges are completely
disjoint. Now, in the consecutive iterations next edges are added according the lowest weighted
edges. Here it can be stated that the edges that creates cycles needs to be ignored.
In the program it is tried to maintain two distinct disjoint sets of nodes. One set contains
the nodes that are added to the path and another one includes the nodes that are remaining and
needs to be added to the path.
After every iteration a check is done in order to detect the cycles that are formed with the
redundant edges to the same node. In order to do that, the simplest method is about scanning the
previously edges with increasing order of the costs. While computing the time complexity is
found to be O (n log n). After the scan, the cost for the delivering the packets is calculated by
avoiding the cycles as well as avoiding the two already connected nodes from the path.
Code
Simulation Analysis of Packet Delivery Probability_2
NETWORKING AND PACKET DELIVERY SIMULATION
2
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int netnd(int p, int kval[], bool nets[]) {
int mincst = numeric_limits<int>::max();
int mincst_index;
for (int i = 0; i < p; i++) {
if (nets[i] == false && kval[i] < mincst) {
mincst = kval[i], mincst_index = i;
//mincst = kval[i+1], mincst_index = i+1;
}
Simulation Analysis of Packet Delivery Probability_3

End of preview

Want to access all the pages? Upload your documents or become a member.