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