...
 
Commits (10)
......@@ -482,7 +482,7 @@ uint8_t storage_flash_save_bundle(struct mmem * bundlemem, uint32_t ** bundle_nu
}
// Find the next empty page
while( storage_flash_page_in_use(page) ) {
while( storage_flash_page_in_use(page) && page < FLASH_PAGES_IN_USE) {
// TODO: This loop fails if all pages are used
// This should not happen, since there must be space at this point
page ++;
......
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
override CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = uDTN-sender
all: $(CONTIKI_PROJECT)
......
This diff is collapsed.
......@@ -125,8 +125,10 @@ PROCESS_THREAD(udtn_sender_process, ev, data)
#ifndef WAITING_TIME
/* Wait until a neighbour has been discovered */
destination = convert_eid_to_rime(CONF_SEND_TO_NODE);
#ifndef REDUCE_JITTER
printf("Waiting for neighbour %u (or %u.%u) to appear...\n", CONF_SEND_TO_NODE, destination.u8[0], destination.u8[1]);
while( !DISCOVERY.is_neighbour(&destination) ) {
#endif
while( !DISCOVERY.is_neighbour(&destination) ) {
PROCESS_PAUSE();
}
#endif
......@@ -135,9 +137,14 @@ PROCESS_THREAD(udtn_sender_process, ev, data)
etimer_set(&timer, CLOCK_SECOND);
PROCESS_WAIT_UNTIL(etimer_expired(&timer));
#ifndef REDUCE_JITTER
printf("Init done, starting test\n");
#endif
profiling_init();
/* format storage for a clean start*/
BUNDLE_STORAGE.format();
profiling_init();
profiling_start();
/* Send ourselves the initial event */
......@@ -215,19 +222,25 @@ PROCESS_THREAD(udtn_sender_process, ev, data)
/* Stop profiling if we've sent BUNDLES bundles. We still need to send
* more since some might have been lost on the way */
if (bundles_sent == BUNDLES) {
#ifndef REDUCE_JITTER
printf("Stopping profiling and taking time...\n");
profiling_stop();
#endif
profiling_stop();
/* Note down the time of the last bundle */
time_stop = test_precise_timestamp();
#ifndef REDUCE_JITTER
printf("\tdone\n");
}
#endif
}
/* Allocate memory for the outgoing bundle */
bundle_outgoing = bundle_create_bundle();
if( bundle_outgoing == NULL ) {
#ifndef REDUCE_JITTER
printf("create_bundle failed\n");
continue;
#endif
continue;
}
/* Source, destination, custody and report-to nodes and services*/
......@@ -254,8 +267,10 @@ PROCESS_THREAD(udtn_sender_process, ev, data)
n = bundle_add_block(bundle_outgoing, BUNDLE_BLOCK_TYPE_PAYLOAD, BUNDLE_BLOCK_FLAG_NULL, userdata, BUNDLE_SIZE);
if( n == -1 ) {
#ifndef REDUCE_JITTER
printf("not enough room for block\n");
bundle_decrement(bundle_outgoing);
#endif
bundle_decrement(bundle_outgoing);
continue;
}
......@@ -264,9 +279,11 @@ PROCESS_THREAD(udtn_sender_process, ev, data)
bundles_sent++;
/* Show progress every REPORTING_INTERVAL bundles */
if (bundles_sent % REPORTING_INTERVAL == 0)
#ifndef REDUCE_JITTER
if (bundles_sent % REPORTING_INTERVAL == 0)
printf("%i\n", bundles_sent);
}
#endif
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
......@@ -106,8 +106,13 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
unsigned long start = clock_seconds();
while( (clock_seconds() - start) < WAITING_TIME );
watchdog_start();
#ifndef REDUCE_JITTER
printf("Starting Test\n");
#endif
#endif
/* format storage for a clean start*/
BUNDLE_STORAGE.format();
profiling_init();
profiling_start();
......@@ -126,9 +131,11 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
watchdog_stop();
profiling_report("init", 0);
watchdog_start();
#ifndef REDUCE_JITTER
printf("Init done, starting test\n");
#endif
profiling_init();
profiling_init();
profiling_start();
while (1) {
......@@ -164,18 +171,24 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
int error = 0;
if( block == NULL ) {
#ifndef REDUCE_JITTER
printf("Payload: no block\n");
error = 1;
#endif
error = 1;
} else {
if( block->block_size != BUNDLE_SIZE ) {
#ifndef REDUCE_JITTER
printf("Payload: length is %d, should be %d\n", block->block_size, BUNDLE_SIZE);
error = 1;
#endif
error = 1;
}
for(i=0; i<BUNDLE_SIZE; i++) {
if( block->payload[i] != (i % 255) ) {
#ifndef REDUCE_JITTER
printf("Payload: byte %d mismatch. Should be %02X, is %02X\n", i, i, block->payload[i]);
error = 1;
#endif
error = 1;
}
}
}
......@@ -193,9 +206,11 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
bundle_get_attr(bundle_incoming, SRC_NODE, &tmp);
if( seqno == old_seqno ) {
#ifndef REDUCE_JITTER
printf("Duplicate bundle, ignoring\n");
#endif
/* Tell the agent, that we have processed the bundle */
/* Tell the agent, that we have processed the bundle */
process_post(&agent_process, dtn_processing_finished, bundle_incoming);
continue;
......@@ -213,10 +228,12 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
time_start = test_precise_timestamp();
}
if (bundles_recv % REPORTING_INTERVAL == 0)
#ifndef REDUCE_JITTER
if (bundles_recv % REPORTING_INTERVAL == 0)
printf("%u\n", bundles_recv);
#endif
/* Report profiling data after receiving BUNDLES bundles
/* Report profiling data after receiving BUNDLES bundles
Ideally seq. no 0-999 */
if (bundles_recv==BUNDLES) {
leds_off(1);
......@@ -241,9 +258,11 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
bundle_outgoing = bundle_create_bundle();
if( bundle_outgoing == NULL ) {
printf("create_bundle failed\n");
continue;
}
#ifndef REDUCE_JITTER
printf("create_bundle failed\n");
#endif
continue;
}
/* tmp already holds the src address of the sender */
bundle_set_attr(bundle_outgoing, DEST_NODE, &tmp);
......@@ -266,9 +285,11 @@ PROCESS_THREAD(udtn_sink_process, ev, data)
/* Send out the bundle */
process_post(&agent_process, dtn_send_bundle_event, (void *) bundle_outgoing);
#ifndef REDUCE_JITTER
printf("bundle sent, waiting for event...\n");
#endif
/* Wait for the agent to process our outgoing bundle */
/* Wait for the agent to process our outgoing bundle */
PROCESS_WAIT_UNTIL(ev == dtn_bundle_stored || ev == dtn_bundle_store_failed);
if( ev == dtn_bundle_stored ) {
......
#!/usr/bin/env python3
import os
import re
import numpy
class Result:
def __init__(self,memtype,payload,bps,busp,loss):
self.memtype = memtype
self.payload = payload
self.bps = bps
self.busp = busp
self.loss = loss
def __lt__(self, o):
if isinstance(o, Result):
if o.memtype > self.memtype:
return True
if o.memtype == self.memtype:
if int(o.payload) >= int(self.payload):
return True
else:
return False
if o.memtype < self.memtype:
return False
else:
raise(TypeError)
def __str__(self):
return "%s,%d,%f,%f,%f"%(self.memtype,self.payload,self.bps, self.busp, self.loss)
#regex = re.compile("/^\d* \d*: receiver TEST:REPORT:throughput_bytes:(?P<bytes>\d+):(?P<scale>\d+):(?P<unit>.*)$/g")
regex = re.compile("^\d* \d*: receiver TEST:REPORT:throughput_bytes:(?P<bytes>\d+):(?P<scale>\d+):(?P<unit>.*)$")
regexBusp = re.compile("^\d* \d*: receiver TEST:REPORT:throughput:(?P<bundles>\d+):(?P<scale>\d+):(?P<unit>.*)$")
regexLoss = re.compile("^\d* \d*: receiver TEST:REPORT:packetloss:(?P<loss>\d+):(?P<scale>\d+):(?P<unit>.*)$")
results = []
for dirname, dirnames, filenames in os.walk("./throughput-log/"):
for subdir in dirnames:
ddir="./throughput-log/"+subdir+'/'
for dirname, dirnames, filenames in os.walk(ddir):
for subdir in dirnames:
dir=ddir+subdir
if os.path.isfile(dir+'/receiver.log'):
with open(dir+'/receiver.log') as f:
res = None
resBusp = None
resLoss = None
for line in f:
resultBusp= regexBusp.search(line)
result = regex.search(line)
resultLoss = regexLoss.search(line)
if result != None:
res = ((float(result.group('bytes')) / float(result.group('scale')))*8)/1000
if resultBusp != None:
resBusp = (float(resultBusp.group('bundles')) / float(resultBusp.group('scale')))
if resultLoss != None:
resLoss = (float(resultLoss.group('loss')) / float(resultLoss.group('scale')))
if resLoss != None and resBusp != None and res != None:
r = Result(subdir.split('-')[1],int(subdir.split('-')[2]),res,resBusp,resLoss)
results.append(r)
#else:
# print("file not found: "+dir+'/sender.log')
pl = 0
vals = []
valsBusp = []
valsLoss = []
t = None
fm = open("mmem.csv",'w')
ff = open("flash.csv",'w')
count = 0
for r in sorted(results):
#print(r)
if pl != r.payload:
if pl !=0 :
print(str(count)+'x : '+t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+ ','+str(numpy.mean(valsBusp))+','+str(numpy.std(valsBusp))+','+str(numpy.mean(valsLoss))+','+str(numpy.std(valsLoss)))
if t == 'flash':
ff.write(str(count)+'x : '+t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+ ','+str(numpy.mean(valsBusp))+','+str(numpy.std(valsBusp))+','+str(numpy.mean(valsLoss))+','+str(numpy.std(valsLoss)))
if t == 'mmem':
fm.write(str(count)+'x : '+t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+ ','+str(numpy.mean(valsBusp))+','+str(numpy.std(valsBusp))+','+str(numpy.mean(valsLoss))+','+str(numpy.std(valsLoss)))
count=0
vals = []
valsBusp = []
valsLoss = []
pl = r.payload
t = r.memtype
vals.append(r.bps)
valsBusp.append(r.busp)
valsLoss.append(r.loss)
count += 1
print(str(count)+'x : '+t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+ ','+str(numpy.mean(valsBusp))+','+str(numpy.std(valsBusp))+','+str(numpy.mean(valsLoss))+','+str(numpy.std(valsLoss)))
#if t == 'flash':
# ff.write(t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+'\n')
#if t == 'mmem':
# fm.write(t+','+str(pl)+','+str(numpy.mean(vals))+','+str(numpy.std(vals))+'\n')