簡體   English   中英

如何使用腳本編輯器 cooja 模擬器從 collect-view 訪問 motes 信息?

[英]How to access motes info from collect-view using script editor cooja simulator?

我正在嘗試編寫一個腳本(Javascript)來記錄來自收集視圖工具的 mote 信息,我沒有找到任何教程或文檔來顯示如何使用腳本編輯器訪問 mote 信息,我將非常感謝任何幫助.

謝謝!

TIMEOUT(900000, log.log("Total PRR " + totalPRR + "\n"));

 packetsReceived= new Array();

packetsSent = new Array();

serverID = 1;

nodeCount = 6;

totalPRR = 0;

t_total = 0;

throughput = 0;

PDR=0;

data_length = 100;

Average_delay = 0;

timeReceived= new Array();

timeSent = new Array();

delay = new Array();

for(i = 0; i < ( nodeCount-1); i++) {

packetsReceived[i] = 0;

packetsSent[i] = 0;

timeReceived[i] = 0.0;

timeSent[i] = 0.0;

delay[i] = 0.0;

}

while(1) {

YIELD();

msgArray = msg.split(' ');

// log.log("string: "+msgArray+"\n");



if(msgArray[0].equals("receiver")) {

// Received packet

senderID = parseInt(msgArray[1]);

packetsReceived[senderID]++;

timeReceived[senderID] = time;

log.log("\n" + " SenderID " + senderID + " PRR " + packetsReceived[senderID] / packetsSent[senderID] + "timeReceived[senderID]" +  timeReceived[senderID] + " timeSent[senderID] " + timeSent[senderID] + "\n");

totalReceived = totalSent = 0;

totaldelay = 0;

count1 = 0;

for(i = 0; i < ( nodeCount-1); i++) 
{

    totalReceived += packetsReceived[i];

    totalSent += packetsSent[i];

    if (timeReceived[i] > 0) {

        delay[i] = timeReceived[i] - timeSent[i];

        delay[i] = delay[i] / 10000000 ;


        if (delay[i] > 0) 
        {

         

            totaldelay = totaldelay + delay[i];

            count1++;

        }

}

}

totalPRR = totalReceived / totalSent;

total_simulation_time=time;
log.log("\n"+"Total simulation time"+total_simulation_time+"\n");

throughput = (totalReceived * data_length * 8 *1000) / total_simulation_time;

log.log("\n"+"Total Received " + totalReceived + "totalSent" + totalSent + "\n");
PDR=(totalReceived / totalSent) * 100;

t_total = totalPRR * 100 ;

 

log.log("\n" + "Total Packet reception rate " + totalPRR + " Total_delay " + totaldelay + "Packet Delivery Ratio" + PDR + "\n");

log.log("\n"+ "Throughput "+throughput+"\n");

} 

else if(msgArray[0].equals("sender")) {

// Sent packet
receiverID = parseInt(msgArray[1]);


packetsSent[receiverID]++;

timeSent[receiverID] = time;

log.log( "\n" + " packetsSent[id]"  + packetsSent[receiverID]  + " timeSent[id] " + timeSent[receiverID] +  " id " + receiverID + "\n");

}



}

我已經在我的項目中使用了這個腳本。 這是不言自明的。 但是,如果您有任何疑問,請問我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM