ip ping test for sky platform (telnet server).

This commit is contained in:
fros4943 2008-12-16 09:51:36 +00:00
parent c36aae56bb
commit 558244b488
3 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<simulation>
<title>My simulation</title>
<delaytime>0</delaytime>
<ticktime>1</ticktime>
<randomseed>123456</randomseed>
<motedelay>1000</motedelay>
<radiomedium>
se.sics.cooja.radiomediums.UDGM
<transmitting_range>50.0</transmitting_range>
<interference_range>100.0</interference_range>
<success_ratio_tx>1.0</success_ratio_tx>
<success_ratio_rx>1.0</success_ratio_rx>
</radiomedium>
<motetype>
se.sics.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #1</description>
<source>../../../examples/sky-ip/sky-telnet-server.c</source>
<command>make sky-telnet-server.sky TARGET=sky</command>
</motetype>
<mote>
se.sics.cooja.mspmote.SkyMote
<motetype_identifier>sky1</motetype_identifier>
<interface_config>
se.sics.cooja.interfaces.Position
<x>86.60672552430381</x>
<y>5.401254433278691</y>
<z>0.0</z>
</interface_config>
<interface_config>
se.sics.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
</mote>
</simulation>
<plugin>
se.sics.cooja.radiomediums.UDGM$VisUDGM
<width>127</width>
<z>3</z>
<height>184</height>
<location_x>265</location_x>
<location_y>13</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.plugins.SimControl
<width>248</width>
<z>1</z>
<height>200</height>
<location_x>1</location_x>
<location_y>1</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.plugins.LogListener
<plugin_config>
<filter />
<history>256</history>
</plugin_config>
<width>1024</width>
<z>2</z>
<height>172</height>
<location_x>0</location_x>
<location_y>547</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.plugins.NativeIPGateway
<mote_arg>0</mote_arg>
<plugin_config>
<network_interface>\Device\NPF_{53CBA059-40AA-4822-BB53-7A5B9AFE77D6}</network_interface>
<register_routes>true</register_routes>
</plugin_config>
<width>388</width>
<z>4</z>
<height>331</height>
<location_x>3</location_x>
<location_y>205</location_y>
<minimized>false</minimized>
</plugin>
</simconf>

View File

@ -0,0 +1 @@
1xSky node: examples/sky-ip/sky-telnet-server.c. Sends 10 pings to 172.16.1.0 via the native IP stack. Test succeeds if more than 5 ping replies are received.

View File

@ -0,0 +1,45 @@
if (!msg.contains('Sky telnet process')) {
return;
}
ipAddress = "172.16.1.0";
osName = java.lang.System.getProperty("os.name").toLowerCase();
if (osName.startsWith("win")) {
pingCmd = "ping -n 10 " + ipAddress;
} else {
pingCmd = "ping -c 10 " + ipAddress;
}
replyMsg = "from " + ipAddress;
ok = global.get('started_ping');
if (ok == true) {
//log.log("ping already started\n");
return;
}
global.put('started_ping', true);
global.put('replies', "");
var runnableObj = new Object();
runnableObj.run = function() {
pingProcess = new java.lang.Runtime.getRuntime().exec(pingCmd);
log.log("cmd> " + pingCmd + "\n");
stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(pingProcess.getInputStream()));
while ((line = stdIn.readLine()) != null) {
log.log("> " + line + "\n");
if (line.contains(replyMsg)) {
global.put('replies', global.get('replies') + "1");
//log.log("reply #" + global.get('replies').length() + "\n");
}
}
pingProcess.destroy();
if (global.get('replies').length() > 5) {
log.testOK(); /* Report test success and quit */
} else {
log.log("Only " + global.get('replies').length() + "/10 ping replies was received\n");
log.testFailed();
}
}
var thread = new java.lang.Thread(new java.lang.Runnable(runnableObj));
thread.start();