Network Node Simulator
This network node simulator was designed to test how changes in processing and transit time influence the traffic of data through a simulated network. The program is written as a console application which uses eight threads. One for each of the seven nodes, and one for the main program loop.
Loading & Setup
Various parameters are collected from the user at launch. The program first requests a node processing time range in milliseconds. Seven nodes are created with randomly assigned time ranges which fall between the time range specified. Each node starts a thread and runs a loop until the simulation is concluded. Following the creation of threads, the program requests a transmission time range in milliseconds. It links the nodes with connections in a predetermined pattern and randomly assigns a transmission time from within the specified range to the connections. Finally, the program asks how many packets to run through the simulation as well as the average frequency which they should arrive.
Structure of Network Objects
The following list details all variables that make up each network object modeled by this simulator.
- connectedNode stores a pointer to the destination node of the connection.
- isBusy Is a boolean variable used to signify when the connection is transmitting data between nodes.
- packetInTransit holds the packet being transmitted while it is moving between two nodes.
- transmissionTime stores the amount of delay to use while transmitting a packet.
- linkedNodes is a vector containing all outbound connections to other nodes.
- packetQueue is a queue which holds all packets that have arrived at the node and are in line to be sent to another node.
- max/minServiceTime are two variables which store the range of time the node should take to delay while processing.
- start/endTime are two variables which log the time when the packet enters or exits the network.
- destination stores a pointer to the target ending node
Main Thread Loop
After all input parameters have been specified, the program begins the simulation by sending packets to one of the starting nodes created earlier. The thread is told to sleep for a randomly determined time between 75% and 125% of the specified arrival rate at the edge of the network. This process loops until all packets have been sent to the network.
Node Thread Loop
While the main thread loop is sending packets to the network, each node is running a thread in an attempt to get a packet routed to its destination as quickly as possible. Each node is completely autonomous and capable of processing packets without any instruction from another thread. If the node finds a packet in the queue, it will look at all possible paths from the current node to the target node using a recursive search algorithm similar to a preorder tree traversal. It computes the cost of these paths and sends the packet to the next node in the best path. The cost is evaluated by taking into account the overall distance, transmission time, and queue length of each node.
This simulation is run in real time, so the completion time depends on the number of packets and variables specified at the start. Whenever a packet enters the network, its number is printed to the console. Whenever a packet enters a new node, a hyphen is printed to the console. There is also a more detailed output that lists the address and time of every node and connection a packet visits. This can be helpful for tracking the route a packet takes, but doesn’t give as clear of an overview as the simplified output does.
A Results Manager class was implemented to track the overall speed and efficiency of the network. The packet queue wait times, total packet time in network, and simulation duration were monitored by the result manager class. When a packet reaches an ending node, its data is sent to the result manager class. At the end of the simulation, data is calculated based on the information obtained throughout the simulation. It is capable of reporting the actual arrival rate at the edge of the network, departure rate at the ending nodes, average queue waiting time, as well as the average, minimum, and maximum transit time between nodes.
When low delay and transmission times are set, packets move through the network at a fairly consistant rate. As a much longer delay is introduced into the simulation, packets cannot keep up and begin to back up at the nodes. In this case, traversal time is much longer. This can be seen with the calculated values, or by looking at the visual output. All of the packets are introduced into the network very quickly, but take a significant amount of time to reach the end.
These results are consistent to tests with higher volumes of packets as seen below.