Commit 368c430e authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Time sender payload size is now configurable.

parent 269d70ba
Loading
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ static struct argp_option options[] = {
        {"port",                'p', "PORT",       0,  "Target Port" },
        {"local port",          'l', "PORT",       0,  "Local Port" },
        {"rounds",              'r', "ROUNDS",     0,  "Rounds" },
        {"size",                's', "SIZE",       0,  "Size" },
        {"output",              'o', "FILE",       0,  "Output to FILE instead of standard output" },
        {"threadpinning",       'T',  0,           0,  "Enable thread pinning"},
        {"pacing",              'P',  0,           0,  "Enable pacing"},
@@ -25,6 +26,7 @@ static struct arguments
    uint16_t port;
    uint16_t local_port;
    uint16_t rounds;
    uint16_t size;
    char* outfile;
    bool thread_pinning;
    bool pacing;
@@ -45,6 +47,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
        case 'p':
            arguments->port = (uint16_t) strtol(arg, &pEnd, 10);
            break;
        case 's':
            arguments->size = (uint16_t) strtol(arg, &pEnd, 10);
            break;
        case 'P':
            arguments->pacing = true;
            break;
@@ -77,6 +82,7 @@ int main(int argc, char **argv) {
        .target = "127.0.0.1",
        .port = 5000,
        .local_port = 6000,
        .size = 1500,
        .rounds = 127,
        .pacing = false,
        .outfile = "-",
@@ -125,9 +131,9 @@ int main(int argc, char **argv) {
    XlapTimestampTableInstall(s, ts_redundancy_packet, tstable_redundancy);

    uint32_t j = 0;
    char buf[6250];
	memset(buf, 0x0, sizeof(buf));
	assert(sizeof(buf) >= sizeof(struct timespec));
    uint16_t buffer_size = arguments.size;
    char* buf = calloc(buffer_size, sizeof(char));
	assert(sizeof(buf) >= 2* sizeof(struct timespec) + 20);
    while (j < rounds) {
		struct timespec now;
		clock_gettime(CLOCK_REALTIME, &now);
@@ -137,8 +143,6 @@ int main(int argc, char **argv) {
        PrrtSocket_send(s, (unsigned char *) buf, sizeof(buf));

        j++;
        // Send every 100us, as this is a sensible packet interval.
        //usleep_nano(100);
    }
    sleep_nano(10);