Commit 4ca02206 authored by Joanne Hugé's avatar Joanne Hugé

Send increasing numbers as packet data

parent b94ded12
......@@ -54,7 +54,7 @@ typedef struct network_config {
// Static functions
static void process_options(int argc, char *argv[]);
static void do_tsn_task(struct thread_param *param, uint64_t next_txtime);
static void do_tsn_task(struct thread_param *param, char * data, uint64_t next_txtime);
static void print_histograms();
static void sigint_handler(int sig_num);
......@@ -78,6 +78,8 @@ static enum TSNTask tsn_task;
struct timespec measures_start;
struct timespec measures_end;
char send_data[MAX_BUFFER_SIZE];
static void help(char *argv[]) {
printf("Usage: %s -f IF [-abthgv] [-e ETF_OFFSET] [-d BUF_LEN] [-i USEC] [-l N] [-p PRIO] [-q PACKET_PRIO] [-r USEC]\n\n", argv[0]);
printf(" -a Run the real time thread on CPU1\n");
......@@ -138,7 +140,8 @@ static void *packet_sending_thread(void *p) {
if (stats->nb_cycles >= param->max_cycles)
break;
do_tsn_task(param, next_txtime);
sprintf(send_data, "%d", stats->nb_cycles % 1000);
do_tsn_task(param, send_data, next_txtime);
add_ns(&next, param->interval);
......@@ -237,7 +240,7 @@ int main(int argc, char *argv[]) {
}
// Critical TSN task
static void do_tsn_task(struct thread_param *param, uint64_t next_txtime) {
static void do_tsn_task(struct thread_param *param, char * data, uint64_t next_txtime) {
struct timespec t1, t2;
int rtt_us;
......@@ -245,14 +248,14 @@ static void do_tsn_task(struct thread_param *param, uint64_t next_txtime) {
if (tsn_task == SEND_PACKET_TASK) {
param->stats.packet_info = send_udp_packet(
enable_etf, enable_timestamps, next_txtime,
enable_etf, enable_timestamps, data, next_txtime,
network_config.ip_address, histograms);
// Round Trip Time measurement
} else if (tsn_task == RTT_TASK) {
clock_gettime(CLOCK_MONOTONIC, &t1);
send_udp_packet(0, 0, next_txtime,
send_udp_packet(0, 0, data, next_txtime,
network_config.ip_address, NULL);
recv_udp_packet(0, 0, NULL);
clock_gettime(CLOCK_MONOTONIC, &t2);
......
......@@ -74,12 +74,6 @@ static void init_tx_buffer(size_t _tx_buffer_len) {
tx_buffer_len = _tx_buffer_len;
tx_buffer = malloc(tx_buffer_len);
for (int i = 0; i < (((int)tx_buffer_len) - 1); i++) {
tx_buffer[i] = (unsigned char)i;
}
tx_buffer[tx_buffer_len - 1] = '\0';
}
/*
......@@ -147,6 +141,7 @@ uint64_t get_txtime() {
* Sends udp packets
*/
packet_info_t send_udp_packet(int use_etf, int use_timestamps,
char * data,
uint64_t txtime,
const char *server_ip,
int64_t histograms[NB_HISTOGRAMS][MAX_HIST_VAL]) {
......@@ -168,6 +163,8 @@ packet_info_t send_udp_packet(int use_etf, int use_timestamps,
packet_info.userspace_enter_ts = ts_to_uint(ts);
}
strcpy(tx_buffer, data);
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(server_ip);
......
......@@ -4,6 +4,6 @@
#include "utilities.h"
void init_udp_send(int use_etf, int use_timestamps, int so_priority, char *network_if, size_t tx_buffer_len);
packet_info_t send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime, const char *server_ip, int64_t histograms[NB_HISTOGRAMS][MAX_HIST_VAL]);
packet_info_t send_udp_packet(int use_etf, int use_timestamps, char * data, uint64_t txtime, const char *server_ip, int64_t histograms[NB_HISTOGRAMS][MAX_HIST_VAL]);
#endif
......@@ -130,7 +130,7 @@ static void *packet_receiving_thread(void *p) {
if (tsn_task == RTT_TASK) {
recv_udp_packet(0, 0, NULL);
send_udp_packet(0, 0, 0, network_config.ip_address, NULL);
send_udp_packet(0, 0, "", 0, network_config.ip_address, NULL);
} else if (tsn_task == RECV_PACKET_TASK) {
......
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