forked from RIOT-OS/Release-Specs
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task06: provide test scripts #5
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import argparse | ||
|
||
from testutils import Board | ||
from mixins import GNRC, GNRC_UDP,PktBuf | ||
from time import sleep | ||
|
||
|
||
#Declare node | ||
class SixLoWPANNode(Board, GNRC, GNRC_UDP, PktBuf): | ||
pass | ||
|
||
|
||
def print_results(results): | ||
packet_losses = [results[i][0] for i in range(len(results))] | ||
print("Summary of {packet losses, source pktbuf sanity, dest pktbuf sanity}:") | ||
for i in range(len(results)): | ||
print("Run {}: {} {} {}".format(i+1, packet_losses[i], results[i][1], results[i][2])) | ||
print("") | ||
print("Average packet losses: {}".format(sum(packet_losses)/len(packet_losses))) | ||
|
||
|
||
def udp_send(source, dest, ip_dest, port, count, payload_size, delay): | ||
source.reboot() | ||
dest.reboot() | ||
|
||
dest.udp_server_start(port) | ||
source.udp_send(ip_dest, port, payload_size, count, delay) | ||
packet_loss = dest.udp_server_check_output(count, delay) | ||
dest.udp_server_stop() | ||
|
||
return packet_loss, source.is_empty(), dest.is_empty() | ||
|
||
|
||
argparser = argparse.ArgumentParser() | ||
argparser.add_argument("--runs", "-n", help="Number of runs", type=int, | ||
default=1) | ||
argparser.add_argument("riotbase", help="Location of RIOT directory") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /usr/bin/env python3 | ||
# Copyright (C) 2018 Freie Universität Berlin | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
|
||
import sys | ||
import os | ||
|
||
PORT = 1337 | ||
COUNT = 1000 | ||
PAYLOAD_SIZE = 1024 | ||
DELAY = 1000 # ms | ||
ERROR_TOLERANCE = 5 # % | ||
|
||
|
||
def task01(riotbase, runs=1): | ||
os.chdir(os.path.join(riotbase, "tests/gnrc_udp")) | ||
try: | ||
exp = IoTLABExperiment("RIOT-release-test-06-01", | ||
[IoTLABNode(site="lille", | ||
extra_modules=["gnrc_pktbuf_cmd"]), | ||
IoTLABNode(site="lille", | ||
extra_modules=["gnrc_pktbuf_cmd"])]) | ||
except Exception as e: | ||
print(str(e)) | ||
print("Can't start experiment") | ||
return | ||
|
||
try: | ||
addrs = exp.nodes_addresses | ||
iotlab_cmd = "make IOTLAB_NODE={} BOARD=iotlab-m3 term" | ||
source = SixLoWPANNode(iotlab_cmd.format(addrs[0])) | ||
dest = SixLoWPANNode(iotlab_cmd.format(addrs[1])) | ||
results = [] | ||
|
||
for run in range(runs): | ||
print("Run {}/{}: ".format(run + 1, runs), end="") | ||
packet_loss, buf_source, buf_dest = udp_send(source, dest, | ||
dest.get_ip_addr(), | ||
PORT, COUNT, | ||
PAYLOAD_SIZE, DELAY) | ||
results.append([packet_loss, buf_source, buf_dest]) | ||
|
||
assert(packet_loss < ERROR_TOLERANCE) | ||
assert(buf_source) | ||
assert(buf_dest) | ||
print("OK") | ||
print_results(results) | ||
except Exception as e: | ||
print("FAILED") | ||
print(str(e)) | ||
finally: | ||
exp.stop() | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), | ||
"../", "testutils")) | ||
from iotlab import IoTLABNode, IoTLABExperiment | ||
from common import argparser, SixLoWPANNode, udp_send, print_results | ||
|
||
args = argparser.parse_args() | ||
task01(**vars(args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /usr/bin/env python3 | ||
# Copyright (C) 2018 Freie Universität Berlin | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
|
||
import sys | ||
import os | ||
|
||
PORT = 61616 | ||
COUNT = 1000 | ||
PAYLOAD_SIZE = 1024 | ||
DELAY = 1000 # ms | ||
ERROR_TOLERANCE = 5 # % | ||
|
||
|
||
def task02(riotbase, runs=1): | ||
os.chdir(os.path.join(riotbase, "tests/gnrc_udp")) | ||
try: | ||
exp = IoTLABExperiment("RIOT-release-test-06-01", | ||
[IoTLABNode(site="lille", | ||
extra_modules=["gnrc_pktbuf_cmd"]), | ||
IoTLABNode(site="lille", | ||
extra_modules=["gnrc_pktbuf_cmd"])]) | ||
except Exception as e: | ||
print(str(e)) | ||
print("Can't start experiment") | ||
return | ||
|
||
try: | ||
addrs = exp.nodes_addresses | ||
iotlab_cmd = "make IOTLAB_NODE={} BOARD=iotlab-m3 term" | ||
source = SixLoWPANNode(iotlab_cmd.format(addrs[0])) | ||
dest = SixLoWPANNode(iotlab_cmd.format(addrs[1])) | ||
results = [] | ||
|
||
for run in range(runs): | ||
print("Run {}/{}: ".format(run + 1, runs), end="") | ||
packet_loss, buf_source, buf_dest = udp_send(source, dest, | ||
dest.get_ip_addr(), | ||
PORT, COUNT, | ||
PAYLOAD_SIZE, DELAY) | ||
results.append([packet_loss, buf_source, buf_dest]) | ||
|
||
assert(packet_loss < ERROR_TOLERANCE) | ||
assert(buf_source) | ||
assert(buf_dest) | ||
print("OK") | ||
print_results(results) | ||
except Exception as e: | ||
print("FAILED") | ||
print(str(e)) | ||
finally: | ||
exp.stop() | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), | ||
"../", "testutils")) | ||
from iotlab import IoTLABNode, IoTLABExperiment | ||
from common import argparser, SixLoWPANNode, udp_send, print_results | ||
|
||
args = argparser.parse_args() | ||
task02(**vars(args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked Lille for both experiments, because Grenoble is most often too noisy to get 1000 packets of >10 fragments through at such a low error tolerance (see RIOT-OS#53).