Commit 0abdf589 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

+= sender parameters

parent 9f718d31
Loading
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ static char doc[] = "PRRT Sender";
static struct argp_option options[] = {
        {"target",              't', "HOST",       0,  "Target Host" },
        {"port",                'p', "PORT",       0,  "Target Port" },
        {"delay",               'd', "DELAY",      0,  "Target Delay"},
        {"ipt",                 'i', "IPT",        0,  "Inter-Packet-Time"},
        {"local port",          'l', "PORT",       0,  "Local Port" },
        {"rounds",              'r', "ROUNDS",     0,  "Rounds" },
        {"output",              'o', "FILE",       0,  "Output to FILE instead of standard output" },
@@ -26,6 +28,8 @@ typedef struct arguments
{
    char* target;
    uint16_t port;
    uint32_t delay;
    uint32_t ipt;
    uint16_t local_port;
    uint16_t rounds;
    char* outfile;
@@ -48,6 +52,12 @@ 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 'd':
            arguments->delay = (uint32_t) strtol(arg, &pEnd, 10);
            break;
        case 'i':
            arguments->ipt = (uint32_t) strtol(arg, &pEnd, 10);
            break;
        case 'l':
            arguments->local_port = (uint16_t) strtol(arg, &pEnd, 10);
            break;
@@ -86,6 +96,8 @@ int main(int argc, char **argv) {
    struct arguments arguments = {
        .target = "127.0.0.1",
        .port = 5000,
        .delay = 10 * 1000 * 1000,
        .ipt = 100,
        .local_port = 6000,
        .rounds = 127,
        .outfile = "-",
@@ -111,7 +123,7 @@ int main(int argc, char **argv) {
    #endif


    s = PrrtSocket_create(1400, 10 * 1000 * 1000);
    s = PrrtSocket_create(1400, arguments.delay);
    check(s != NULL, "Socket create failed.");

    if(strcmp(arguments.hardwarestamping_interface, "-") != 0) {
@@ -145,7 +157,9 @@ int main(int argc, char **argv) {

        j++;
        // Send every 100us, as this is a sensible packet interval.
        usleep_nano(100);
        if (arguments.ipt != 0) {
          usleep_nano(arguments.ipt);
        }
    }
    sleep_nano(10);