137 #if defined(__linux__) || defined(__FreeBSD__) || (__MINGW32__) 141 #if defined(_MSC_VER) 147 #define PACKETS 100L // How many packets to send 148 #define PACKET_SIZE 296L // Packet size to transmit (incl crc.) 149 #define PACKET_GAP 500000L // Distance in 1ns between packets 150 #define REPLAYS 1000L // How many times we will repeat the packets 151 #define TX_DELAY 1000000000 // Initial transmission delay (one second) 160 #define REPLAY_TRANSMIT_TIME (PACKET_GAP * PACKETS) 163 #define TOTAL_TRANSMIT_TIME (REPLAY_TRANSMIT_TIME * REPLAYS) 184 fprintf(stderr,
"%s: %s\n", prefix, errorBuffer);
191 switch (data->tsType) {
199 return data->nativeUnixTs * 10;
225 if ((status =
NT_ConfigOpen(&hConfig,
"replay")) != NT_SUCCESS) {
233 if ((status =
NT_ConfigRead(hConfig, &config)) != NT_SUCCESS) {
258 const uint64_t txBeginTS = adapterTS +
TX_DELAY;
274 printError(
"NT_ConfigWrite() failed", status);
283 &hNetTx,
"transmit_on_timestamp_example_txstream", 1ULL <<
PORT,
287 printError(
"NT_NetTxOpen_v2() failed", status);
296 printf(
"Commencing transmission of %ld packets %ld times\n",
PACKETS,
REPLAYS);
299 int totalPackets = 0;
301 for (
int replays = 0; replays <
REPLAYS; replays++) {
303 uint64_t timestamp = 0;
304 for (
int pkts = 0; pkts <
PACKETS; pkts++, totalPackets++) {
320 hdr->
time.
ts_sec = (uint32_t)(timestamp / 1000000000U);
321 hdr->
time.
ts_usec = (uint32_t)(timestamp % 1000000000U);
332 NT_NET_SET_PKT_TXSETCLOCK(hNetBufTx, 1);
345 printError(
"NT_NetTxRelease() failed", status);
356 printf(
"Waiting for transmission to end\n");
362 uint64_t newAdapterTS;
365 if ((status =
NT_ConfigRead(hConfig, &config)) != NT_SUCCESS) {
371 }
while (newAdapterTS < txStopTS);
385 printError(
"NT_ConfigWrite() failed", status);
392 printf(
"Done: %d packets sent\n", totalPackets);