nodeCount = 31;
data_length = 23;
totalPRR = 0;
controlpackets = 0;
for(i = 0; i <= nodeCount; i++) {
packetsReceived[i] = 0;
packetsSent[i] = 0;
}
while(1) {
YIELD();
msgArray = msg.split(‘ ‘);
if(msgArray[0].equals(“DATA”)) {
if(msgArray.length == 9) {
// Received packet
senderID = parseInt(msgArray[8]);
packetsReceived[senderID]++;
log.log(“SenderID ” + senderID + ” PRR ” + packetsReceived[senderID] / packetsSent[senderID] + “\n”);
totalReceived = totalSent = 0;
for(i = serverID + 1; i <= nodeCount; i++) {
totalReceived += packetsReceived[i];
totalSent += packetsSent[i];
}
totalPRR = totalReceived / totalSent;
throughput = (totalReceived * data_length * 8) / total_simulation_time;
log.log(“Total PRR ” + totalPRR + ” recv ” + totalReceived + ” sent ” + totalSent + ” Throughput ” + throughput + “\n”);
} else if(msgArray.length == 6) {
// Sent packet
packetsSent[id]++;
log.log(” IIIID ” + id + ” packetsSent[id] ” + packetsSent[id] + “\n”);
}
}
}</script>