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

Add size parameter to time-receiver.

parent 2614d54c
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ static char doc[] = "PRRT Receiver";
static struct argp_option options[] = {
        {"port",          'p', "PORT",   0, "Target 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"},
        {0}
@@ -20,6 +21,7 @@ struct arguments {
    uint16_t port;
    uint16_t local_port;
    uint16_t rounds;
    uint16_t size;
    char *outfile;
    char *target;
    bool thread_pinning;
@@ -41,6 +43,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 'r':
            arguments->rounds = (uint16_t) strtol(arg, &pEnd, 10);
            break;
@@ -82,6 +87,7 @@ int main(int argc, char **argv) {
    struct arguments arguments = {
            .port = 5000,
            .rounds = 127,
            .size = 1500,
            .outfile = "-",
            .thread_pinning = false,
    };
@@ -110,9 +116,9 @@ int main(int argc, char **argv) {

    uint32_t i = 0;
    while (i < rounds && keepRunning) {
        char buffer[MAX_PAYLOAD_LENGTH + 1];
        char* buffer = calloc(arguments.size + 1, sizeof(char));
        debug(DEBUG_RECEIVER, "About to receive.");
        int n = _recv(s, buffer, sizeof(buffer));
        int n = _recv(s, buffer, arguments.size);
        if (n < 0) {
            continue;
        }