mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 10:46:23 +00:00
Merge branch 'meshextender' into 'development'
This commit is contained in:
commit
711364ad8d
@ -2772,6 +2772,56 @@ int app_reverse_lookup(const struct cli_parsed *parsed, struct cli_context *cont
|
||||
return 1;
|
||||
}
|
||||
|
||||
void context_switch_test(int);
|
||||
int app_mem_test(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
{
|
||||
int mem_size;
|
||||
int addr;
|
||||
uint64_t count;
|
||||
|
||||
|
||||
// First test context switch speed
|
||||
context_switch_test(1);
|
||||
|
||||
for(mem_size=1024;mem_size<=(128*1024*1024);mem_size*=2) {
|
||||
uint8_t *mem=malloc(mem_size);
|
||||
if (!mem) {
|
||||
fprintf(stderr,"Could not allocate %dKB memory -- stopping test.\n",mem_size/1024);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Fill memory with random stuff so that we don't have memory page-in
|
||||
// delays when doing the reads
|
||||
for(addr=0;addr<mem_size;addr++) mem[addr]=random()&0xff;
|
||||
|
||||
uint64_t end_time=gettime_ms()+100;
|
||||
uint64_t total=0;
|
||||
uint32_t mem_mask=mem_size-1;
|
||||
|
||||
for(count=0;gettime_ms()<end_time;count++) {
|
||||
addr=random()&mem_mask;
|
||||
total+=mem[addr];
|
||||
}
|
||||
printf("Memory size = %8dKB : %lld random reads per second (irrelevant sum is %016llx)\n",mem_size/1024,count*10,
|
||||
/* use total so that compiler doesn't optimise away our memory accesses */
|
||||
total);
|
||||
|
||||
end_time=gettime_ms()+100;
|
||||
for(count=0;gettime_ms()<end_time;count++) {
|
||||
addr=random()&mem_mask;
|
||||
mem[addr]=3;
|
||||
}
|
||||
printf("Memory size = %8dKB : %lld random writes per second (irrelevant sum is %016llx)\n",mem_size/1024,count*10,
|
||||
/* use total so that compiler doesn't optimise away our memory accesses */
|
||||
total);
|
||||
|
||||
|
||||
free(mem);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int app_network_scan(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
{
|
||||
int mdp_sockfd;
|
||||
@ -2926,6 +2976,8 @@ struct cli_schema command_line_options[]={
|
||||
"Run cryptography speed test"},
|
||||
{app_nonce_test,{"test","nonce",NULL}, 0,
|
||||
"Run nonce generation test"},
|
||||
{app_mem_test,{"test","memory",NULL}, 0,
|
||||
"Run memory speed test"},
|
||||
{app_byteorder_test,{"test","byteorder",NULL}, 0,
|
||||
"Run byte order handling test"},
|
||||
{app_slip_test,{"test","slip","[--seed=<N>]","[--duration=<seconds>|--iterations=<N>]",NULL}, 0,
|
||||
|
103
context1.c
Normal file
103
context1.c
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
/*******************************************************************************
|
||||
* The BYTE UNIX Benchmarks - Release 3
|
||||
* Module: context1.c SID: 3.3 5/15/91 19:30:18
|
||||
*
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* Ben Smith, Rick Grehan or Tom Yager
|
||||
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
|
||||
*
|
||||
*******************************************************************************
|
||||
* Modification Log:
|
||||
* $Header: context1.c,v 3.4 87/06/22 14:22:59 kjmcdonell Beta $
|
||||
* August 28, 1990 - changed timing routines--now returns total number of
|
||||
* iterations in specified time period
|
||||
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
|
||||
* Andy Kahn <kahn@zk3.dec.com>
|
||||
*
|
||||
******************************************************************************/
|
||||
char SCCSid[] = "@(#) @(#)context1.c:3.3 -- 5/15/91 19:30:18";
|
||||
/*
|
||||
* Context switching via synchronized unbuffered pipe i/o
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "timeit.c"
|
||||
|
||||
unsigned long iter;
|
||||
int stop_timing=0;
|
||||
|
||||
void report()
|
||||
{
|
||||
fprintf(stderr, "%lu context switches per second.\n", iter);
|
||||
stop_timing=1;
|
||||
}
|
||||
|
||||
void context_switch_test(int duration)
|
||||
{
|
||||
unsigned long check;
|
||||
int p1[2], p2[2];
|
||||
|
||||
|
||||
/* set up alarm call */
|
||||
iter = 0;
|
||||
wake_me(duration, report);
|
||||
|
||||
if (pipe(p1) || pipe(p2)) {
|
||||
perror("pipe create failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fork()) { /* parent process */
|
||||
/* master, write p1 & read p2 */
|
||||
close(p1[0]); close(p2[1]);
|
||||
while (!stop_timing) {
|
||||
if (write(p1[1], (char *)&iter, sizeof(iter)) != sizeof(iter)) {
|
||||
if ((errno != 0) && (errno != EINTR))
|
||||
perror("master write failed");
|
||||
exit(1);
|
||||
}
|
||||
if (read(p2[0], (char *)&check, sizeof(check)) != sizeof(check)) {
|
||||
if ((errno != 0) && (errno != EINTR))
|
||||
perror("master read failed");
|
||||
exit(1);
|
||||
}
|
||||
if (check != iter) {
|
||||
fprintf(stderr, "Master sync error: expect %lu, got %lu\n",
|
||||
iter, check);
|
||||
exit(2);
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
else { /* child process */
|
||||
unsigned long iter1;
|
||||
|
||||
iter1 = 0;
|
||||
/* slave, read p1 & write p2 */
|
||||
close(p1[1]); close(p2[0]);
|
||||
while (!stop_timing) {
|
||||
if (read(p1[0], (char *)&check, sizeof(check)) != sizeof(check)) {
|
||||
if ((errno != 0) && (errno != EINTR))
|
||||
perror("slave read failed");
|
||||
exit(1);
|
||||
}
|
||||
if (check != iter1) {
|
||||
fprintf(stderr, "Slave sync error: expect %lu, got %lu\n",
|
||||
iter, check);
|
||||
exit(2);
|
||||
}
|
||||
if (write(p2[1], (char *)&iter1, sizeof(iter1)) != sizeof(check)) {
|
||||
if ((errno != 0) && (errno != EINTR))
|
||||
perror("slave write failed");
|
||||
exit(1);
|
||||
}
|
||||
iter1++;
|
||||
}
|
||||
}
|
||||
}
|
38
fakeradio.c
38
fakeradio.c
@ -366,12 +366,48 @@ int transfer_bytes(struct radio_state *radios)
|
||||
return bytes;
|
||||
}
|
||||
|
||||
int calc_ber(double target_packet_fraction)
|
||||
{
|
||||
int byte_count=220+32;
|
||||
int max_error_bytes=16;
|
||||
|
||||
int ber;
|
||||
int p;
|
||||
int byte;
|
||||
int bit;
|
||||
|
||||
// 9,000,000 gives a packet delivery rate of ~99%
|
||||
// so no point starting smaller than that.
|
||||
// Only ~30,000,000 reduces packet delivery rate to
|
||||
// ~1%, so the search range is fairly narrow.
|
||||
ber=9000000;
|
||||
if (target_packet_fraction<=0.9) ber=13000000;
|
||||
if (target_packet_fraction<=0.5) ber=18000000;
|
||||
if (target_packet_fraction<=0.25) ber=21000000;
|
||||
if (target_packet_fraction<=0.1) ber=24000000;
|
||||
if (target_packet_fraction<=0.05) ber=26000000;
|
||||
for(;ber<0x70ffffff;ber+=100000)
|
||||
{
|
||||
int packet_errors=0;
|
||||
for(p=0;p<1000;p++) {
|
||||
int byte_errors=0;
|
||||
for(byte=0;byte<byte_count;byte++) {
|
||||
for(bit=0;bit<8;bit++) if (random()<ber) { byte_errors++; break; }
|
||||
if (byte_errors>max_error_bytes) { packet_errors++; break; }
|
||||
}
|
||||
}
|
||||
if (packet_errors>=((1.0-target_packet_fraction)*1000)) break;
|
||||
}
|
||||
fprintf(stderr,"ber magic value=%d\n",ber);
|
||||
return ber;
|
||||
}
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
if (argv[1]) {
|
||||
chars_per_ms=atol(argv[1]);
|
||||
if (argv[2])
|
||||
ber=atol(argv[2]);
|
||||
ber=calc_ber(atof(argv[2]));
|
||||
}
|
||||
fprintf(stderr, "Sending %d bytes per ms\n", chars_per_ms);
|
||||
fprintf(stderr, "Introducing %f%% bit errors\n", (ber * 100.0) / 0xFFFFFFFF);
|
||||
|
@ -76,4 +76,5 @@ SERVAL_SOURCES = \
|
||||
$(SERVAL_BASE)fec-3.0.1/ccsds_tables.c \
|
||||
$(SERVAL_BASE)fec-3.0.1/decode_rs_8.c \
|
||||
$(SERVAL_BASE)fec-3.0.1/encode_rs_8.c \
|
||||
$(SERVAL_BASE)fec-3.0.1/init_rs_char.c
|
||||
$(SERVAL_BASE)fec-3.0.1/init_rs_char.c \
|
||||
$(SERVAL_BASE)context1.c
|
||||
|
@ -209,59 +209,6 @@ test_UnicastTransfer() {
|
||||
receive_and_update_bundle
|
||||
}
|
||||
|
||||
doc_SimulatedRadio="MDP Transfer over simulated radio link"
|
||||
interface_up() {
|
||||
$GREP "Interface .* is up" $instance_servald_log || return 1
|
||||
return 0
|
||||
}
|
||||
start_radio_instance() {
|
||||
executeOk_servald config \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizome_ads on \
|
||||
set debug.rhizome_httpd on \
|
||||
set debug.rhizome_tx on \
|
||||
set debug.rhizome_rx on \
|
||||
set debug.throttling on \
|
||||
set debug.mavlink on \
|
||||
set rhizome.advertise.interval 5000 \
|
||||
set rhizome.rhizome_mdp_block_size 350 \
|
||||
set log.console.level debug \
|
||||
set log.console.show_pid on \
|
||||
set log.console.show_time on \
|
||||
set interfaces.1.type CATEAR \
|
||||
set interfaces.1.mdp.tick_ms 5000 \
|
||||
set interfaces.1.socket_type STREAM \
|
||||
set interfaces.1.encapsulation SINGLE \
|
||||
set interfaces.1.point_to_point on
|
||||
start_servald_server
|
||||
wait_until interface_up
|
||||
}
|
||||
setup_SimulatedRadio() {
|
||||
setup_common
|
||||
$servald_build_root/fakeradio 6 10000000 > "$SERVALD_VAR/radioout" 2> "$SERVALD_VAR/radioerr" &
|
||||
FAKERADIO_PID=$!
|
||||
sleep 1
|
||||
local END1=`head "$SERVALD_VAR/radioout" -n 1`
|
||||
local END2=`tail "$SERVALD_VAR/radioout" -n 1`
|
||||
tfw_log "Started fakeradio pid=$FAKERADIO_PID, end1=$END1, end2=$END2"
|
||||
set_instance +A
|
||||
rhizome_add_file file1 10000
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END1"
|
||||
set_instance +B
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END2"
|
||||
foreach_instance +A +B start_radio_instance
|
||||
}
|
||||
test_SimulatedRadio() {
|
||||
receive_and_update_bundle
|
||||
}
|
||||
teardown_SimulatedRadio() {
|
||||
teardown
|
||||
tfw_log "Killing fakeradio, pid=$FAKERADIO_PID"
|
||||
kill $FAKERADIO_PID
|
||||
tfw_cat "$SERVALD_VAR/radioerr"
|
||||
}
|
||||
|
||||
doc_journalMDP="Transfer and update a journal bundle via MDP"
|
||||
setup_journalMDP() {
|
||||
@ -744,4 +691,86 @@ test_DirectSync() {
|
||||
assert_rhizome_received fileA3
|
||||
}
|
||||
|
||||
interface_up() {
|
||||
$GREP "Interface .* is up" $instance_servald_log || return 1
|
||||
return 0
|
||||
}
|
||||
start_radio_instance() {
|
||||
executeOk_servald config \
|
||||
set debug.rhizome on \
|
||||
set debug.rhizome_ads on \
|
||||
set debug.rhizome_tx on \
|
||||
set debug.rhizome_rx on \
|
||||
set debug.throttling on \
|
||||
set debug.mavlink on \
|
||||
set rhizome.advertise.interval 5000 \
|
||||
set rhizome.rhizome_mdp_block_size 350 \
|
||||
set log.console.level debug \
|
||||
set log.console.show_pid on \
|
||||
set log.console.show_time on \
|
||||
set interfaces.1.type CATEAR \
|
||||
set interfaces.1.mdp.tick_ms 5000 \
|
||||
set interfaces.1.socket_type STREAM \
|
||||
set interfaces.1.encapsulation SINGLE \
|
||||
set interfaces.1.point_to_point on
|
||||
start_servald_server
|
||||
wait_until interface_up
|
||||
}
|
||||
|
||||
doc_SimulatedRadio="MDP Transfer over simulated radio link (~90% packet arrival)"
|
||||
setup_SimulatedRadio() {
|
||||
setup_common
|
||||
$servald_build_root/fakeradio 6 0.9 > "$SERVALD_VAR/radioout" 2> "$SERVALD_VAR/radioerr" &
|
||||
FAKERADIO_PID=$!
|
||||
sleep 5
|
||||
local END1=`head "$SERVALD_VAR/radioout" -n 1`
|
||||
local END2=`tail "$SERVALD_VAR/radioout" -n 1`
|
||||
tfw_log "Started fakeradio pid=$FAKERADIO_PID, end1=$END1, end2=$END2"
|
||||
set_instance +A
|
||||
rhizome_add_file file1 10000
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END1"
|
||||
set_instance +B
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END2"
|
||||
foreach_instance +A +B start_radio_instance
|
||||
}
|
||||
test_SimulatedRadio() {
|
||||
receive_and_update_bundle
|
||||
}
|
||||
teardown_SimulatedRadio() {
|
||||
teardown
|
||||
tfw_log "Killing fakeradio, pid=$FAKERADIO_PID"
|
||||
kill $FAKERADIO_PID
|
||||
tfw_cat "$SERVALD_VAR/radioerr"
|
||||
}
|
||||
|
||||
doc_SimulatedRadio2="MDP Transfer over simulated radio link (~50% packet arrival)"
|
||||
setup_SimulatedRadio2() {
|
||||
setup_common
|
||||
$servald_build_root/fakeradio 6 0.5 > "$SERVALD_VAR/radioout" 2> "$SERVALD_VAR/radioerr" &
|
||||
FAKERADIO_PID=$!
|
||||
sleep 1
|
||||
local END1=`head "$SERVALD_VAR/radioout" -n 1`
|
||||
local END2=`tail "$SERVALD_VAR/radioout" -n 1`
|
||||
tfw_log "Started fakeradio pid=$FAKERADIO_PID, end1=$END1, end2=$END2"
|
||||
set_instance +A
|
||||
rhizome_add_file file1 10000
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END1"
|
||||
set_instance +B
|
||||
executeOk_servald config \
|
||||
set interfaces.1.file "$END2"
|
||||
foreach_instance +A +B start_radio_instance
|
||||
}
|
||||
test_SimulatedRadio2() {
|
||||
receive_and_update_bundle
|
||||
}
|
||||
teardown_SimulatedRadio2() {
|
||||
teardown
|
||||
tfw_log "Killing fakeradio, pid=$FAKERADIO_PID"
|
||||
kill $FAKERADIO_PID
|
||||
tfw_cat "$SERVALD_VAR/radioerr"
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
@ -265,7 +265,7 @@ setup_simulate_extender() {
|
||||
setup_servald
|
||||
assert_no_servald_processes
|
||||
foreach_instance +A +B create_single_identity
|
||||
$servald_build_root/fakeradio 1 20000000 > "$SERVALD_VAR/radioout" 2> "$SERVALD_VAR/radioerr" &
|
||||
$servald_build_root/fakeradio 1 0.8 > "$SERVALD_VAR/radioout" 2> "$SERVALD_VAR/radioerr" &
|
||||
FAKERADIO_PID=$!
|
||||
sleep 1
|
||||
local END1=`head "$SERVALD_VAR/radioout" -n 1`
|
||||
|
41
timeit.c
Normal file
41
timeit.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* The BYTE UNIX Benchmarks - Release 3
|
||||
* Module: timeit.c SID: 3.3 5/15/91 19:30:21
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* Ben Smith, Rick Grehan or Tom Yager
|
||||
* ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
|
||||
*
|
||||
*******************************************************************************
|
||||
* Modification Log:
|
||||
* May 12, 1989 - modified empty loops to avoid nullifying by optimizing
|
||||
* compilers
|
||||
* August 28, 1990 - changed timing relationship--now returns total number
|
||||
* of iterations (ty)
|
||||
* October 22, 1997 - code cleanup to remove ANSI C compiler warnings
|
||||
* Andy Kahn <kahn@zk3.dec.com>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* this module is #included in other modules--no separate SCCS ID */
|
||||
|
||||
/*
|
||||
* Timing routine
|
||||
*
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void wake_me(seconds, func)
|
||||
int seconds;
|
||||
void (*func)();
|
||||
{
|
||||
/* set up the signal handler */
|
||||
signal(SIGALRM, func);
|
||||
/* get the clock running */
|
||||
alarm(seconds);
|
||||
}
|
||||
|
@ -115,7 +115,11 @@ if [ -n "$dirty" ] && ! $allow_modified; then
|
||||
fi
|
||||
|
||||
# Use the "git describe" command to form the version string and append $dirty.
|
||||
if error="$( (desc="$(git describe --match="$version_tag_glob")" && echo "$desc$dirty") 2>&1 1>&5)" 5>&1; then
|
||||
# This ugly construction is required for use on machines with bash version < 4.
|
||||
error="$(git describe --match="$version_tag_glob" 2>&1 1>/dev/null)" || true
|
||||
|
||||
if [ -z "$error" ]; then
|
||||
echo "$(git describe --match="$version_tag_glob")$dirty"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user