#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <string.h>
#include "utils.h"

struct measure_conf {
  uint64_t max_measure;
  uint64_t payload_size;
  uint64_t read_size;
  uint64_t interval;
  char* payload;
  char* payload_rcv;
  uint64_t counter;
  uint8_t is_server, is_rtt;
};

struct measure_packet {
  uint64_t counter;
  uint8_t is_echo;
  uint8_t flag;
  struct timespec emit_time;
};

void measure_parse(int size, struct measure_conf* mc);
void measure_prepare(struct measure_conf* mc);
struct measure_packet* measure_generate(struct measure_conf* mc);
uint8_t measure_need_reply(struct measure_conf* mc);
void measure_next_tick(struct measure_conf *mc, struct timespec *next);
