Commit d97830b8 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

merge develop

parent 08b1d0e6
Pipeline #3377 passed with stages
in 9 minutes and 4 seconds
......@@ -108,7 +108,7 @@ int main(int argc, char **argv) {
PrrtSocket_enable_thread_pinning(s);
}
check(PrrtSocket_bind(s, "0.0.0.0", arguments.port), "bind failed");
check(PrrtSocket_bind(s, "0.0.0.0", arguments.port) == 0, "bind failed");
XlapTimestampTable *tstable_data = malloc(sizeof(XlapTimestampTable));
XlapTimestampTable *tstable_redundancy = malloc(sizeof(XlapTimestampTable));
......@@ -129,6 +129,10 @@ int main(int argc, char **argv) {
buffer[n] = '\0';
unsigned int seqno;
sscanf(buffer, "%u", &seqno);
prrtTimestamp_t current_time = PrrtClock_get_current_time_us();
prrtTimestamp_t prrt_time = PrrtClock_get_prrt_time_us(&s->clock);
printf("C: %d\nP: %d\nD: \n%d\n\n", current_time, prrt_time, prrt_time - current_time);
debug(DEBUG_RECEIVER, "[B (n: %3d, i: %3d)] %s", n, i, buffer);
i++;
}
......
......@@ -122,7 +122,7 @@ int main(int argc, char **argv) {
PrrtSocket_enable_thread_pinning(s);
}
check(PrrtSocket_bind(s, "0.0.0.0", arguments.local_port), "bind failed");
check(PrrtSocket_bind(s, "0.0.0.0", arguments.local_port) == EXIT_SUCCESS, "bind failed");
//PrrtSocket_set_coding_parameters(s, 1, 1); // comment this line to re-enable coding.
......
......@@ -274,7 +274,6 @@ static inline long long int _app_deliver_pace_external(socket_t conn) {
return 0;
}
#else
# define PROTOCOL "prrt"
......
add_library(UTIL ../defines.h
set (UTIL_SOURCES ../defines.h
common.c common.h
list.c list.h
pipe.c pipe.h
......@@ -8,5 +8,19 @@ add_library(UTIL ../defines.h
time.c time.h
mpsc_queue.c mpsc_queue.h
windowedFilter.c windowedFilter.h)
set_property(TARGET UTIL PROPERTY C_STANDARD 99)
target_link_libraries(UTIL ${M_LIB})
add_library(prrtUtil_obj OBJECT ${UTIL_SOURCES})
set_property(TARGET prrtUtil_obj PROPERTY C_STANDARD 99)
add_library(prrtUtil_shared SHARED $<TARGET_OBJECTS:prrtUtil_obj>)
set_target_properties(prrtUtil_shared PROPERTIES OUTPUT_NAME "prrtUtil")
add_library(prrtUtil_static SHARED $<TARGET_OBJECTS:prrtUtil_obj>)
set_target_properties(prrtUtil_static PROPERTIES OUTPUT_NAME "prrtUtil")
target_link_libraries(prrtUtil_shared ${M_LIB})
target_link_libraries(prrtUtil_static ${M_LIB})
install(TARGETS prrtUtil_shared prrtUtil_static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include "common.h"
......@@ -28,11 +29,17 @@ void print_gf(const gf *start, const int len) {
printf("\n");
}
void pin_thread_to_core(pthread_attr_t *ap, int core)
#include "cpulist.h"
int pin_thread_to_core(pthread_attr_t *ap, int core)
{
char *cpulist_conf = getenv("PRRT_CORES");
if (cpulist_conf) {
uint32_t cpulist = cpulist_parse(cpulist_conf);
core = cpulist_get_cpu(cpulist, core);
}
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(core, &cpuset);
pthread_attr_setaffinity_np(ap, sizeof(cpu_set_t), &cpuset);
return pthread_attr_setaffinity_np(ap, sizeof(cpu_set_t), &cpuset);
}
......@@ -8,7 +8,7 @@
int print_buffer(const char *buf, const int length);
void print_gf(const gf *start, const int len);
void pin_thread_to_core(pthread_attr_t *ap, int core);
int pin_thread_to_core(pthread_attr_t *ap, int core);
#define PERROR(fmt, args...) \
printf("PRRT ERROR (" __FILE__ ":%d)\n" fmt, __LINE__, ## args);
......
#ifndef PRRT_CPULIST_H
#define PRRT_CPULIST_H
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#define CPULIST_ERR ((uint32_t) 0)
#ifdef __GNUC__
# define cpulist__inline inline __attribute__((__always_inline__,__unused__))
#else
# define cpulist__inline inline
#endif
/**
* Add a cpu number to a cpu list
*
* \param cpulist the cpu list
* \param num the cpu number
* \returns a new cpu list that contains all cpus from the given cpu list, plus
* the new number. If the old cpu list already contains the given cpu number,
* it is returned unmodified.
*/
static cpulist__inline
uint32_t cpulist_add_cpu(uint32_t cpulist, unsigned int bit) {
if (bit >= 32)
return cpulist;
uint32_t one = 1;
return cpulist | (one << bit);
}
/**
* Check if a cpu number is included in a cpu list
*
* \param cpulist the cpu list
* \param num a cpu number
* \returns \c true if the cpu list included the given cpu number, \c false otherwise
*/
static cpulist__inline
bool cpulist_has_cpu(uint32_t cpulist, unsigned int num) {
if (num >= 32)
return false;
uint32_t one = 1;
return !!(cpulist & (one << num));
}
/**
*
* The purpose of this function is to assign arbitrary cpu numbers to cpu
* numbers allowed by the given cpu list. This is a very simple way of work
* distribution.
*
* \param cpulist the cpu list
* \param num an arbitrary cpu number that is mapped to a cpu number allowed by the given cpu list
* \returns a cpu number that is included in the cpu list, if possible
* \returns UINT_MAX if the cpu list is empty
*/
static cpulist__inline
unsigned int cpulist_get_cpu(uint32_t cpulist, unsigned int num) {
if (!cpulist)
return 0;
// TODO: find a better load distribution algorithm
unsigned int bit = UINT_MAX;
bool has = 0;
do {
num -= has;
bit = (bit + 1) & 31;
has = cpulist_has_cpu(cpulist, bit);
} while (num || !has);
return bit;
}
/**
* Remove all large cpu numbers from a cpu list
*
* This function removes all large cpu numbers from a cpu list. The given limit
* is removed as well. Only cpus lower than num remain in the cpu list.
*
* The purpose of this function is to limit a cpu list to cpu numbers that are
* actually available in the system.
*
* \param cpulist the cpu list
* \param num the cpu limit
* \returns the new cpu list with large numbers removed
*/
static cpulist__inline
uint32_t cpulist_cut(uint32_t cpulist, unsigned int num) {
uint32_t one = 1;
uint32_t all = (one << num) - 1;
return cpulist & all;
}
/**
* Parse a cpu list
*
* This function takes a string that describes a cpu list in an intuitive
* format and converts it to a machine-readable cpu list.
*
* Example: "1-3,5" ==> [ 1, 2, 3, 5 ]
*
* Syntax:
* cpulist ::= <range> | <range> ',' <range> # comma-separated list of ranges
* range ::= <num> | <num> '-' <num> # single number or actual range
* num ::= <digit> | <num> <digit> # at least one digit
* digit ::= '0' .. '9'
*/
static cpulist__inline
uint32_t cpulist_parse(const char *str)
{
uint32_t result = 0;
char *pos = (char *) str;
while (*pos) {
char *end;
long from = strtol(pos, &end, 10);
long to;
switch(*end) {
case '\0':
case ',':
to = from;
break;
case '-':
pos = end + 1;
to = strtol(pos, &end, 10);
break;
default:
return CPULIST_ERR;
}
pos = end;
for (long l = from; l <= to; l++)
result = cpulist_add_cpu(result, (int) l);
switch (*pos) {
case '\0':
return result;
case ',':
pos++;
break;
default:
return CPULIST_ERR;
}
}
return result;
}
#endif /* PRRT_CPULIST_H */
......@@ -9,7 +9,7 @@
#include <string.h>
#define DEBUG_ALL 0
#define DEBUG_BBR 0
#define DEBUG_BBR 1
#define DEBUG_BLOCK 0
#define DEBUG_PACKET 0
#define DEBUG_RECEIVER 0
......
......@@ -2,4 +2,4 @@ add_subdirectory(lib/gtest-1.8.0)
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(prrtTests common.h util_tests.cpp bitmap_tests.cpp receptionTable_tests.cpp delivered_packet_table_tests.cpp bptree_tests.cpp PrrtBlock_tests.cpp)
target_link_libraries(prrtTests LINK_PUBLIC gtest PRRT UTIL gtest_main)
\ No newline at end of file
target_link_libraries(prrtTests LINK_PUBLIC gtest prrt_shared prrtUtil_shared gtest_main)
\ No newline at end of file
......@@ -5,6 +5,7 @@ import datetime
import threading
import prrt
import numpy as np
import pandas as pd
import math
class ReceiverThread(threading.Thread):
......@@ -89,6 +90,13 @@ class TestResults(object):
return "%s\n%s\n%s\n%s" % (loss, duplicates, delays, losses)
def export(self):
df = pd.DataFrame({
"delays": self.delays
}, index=range(self.packetsSent))
df.to_csv("eval.csv")
class TestSetup(object):
def __init__(self, packets=20, packet_interval=0.0001, delay=1, delay_variation=0, delay_correlation=0, loss=0, loss_correlation=0, duplicate=0, reorder=0, reorder_correlation=0, loss_pattern=True):
self.packets = packets
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment