136 #if defined(__linux__) || defined(__FreeBSD__) || (__MINGW32__) 140 #if defined(_MSC_VER) 146 #define PACKETS 100L // How many packets to send 147 #define PACKET_SIZE 296L // Packet size to transmit (incl crc.) 148 #define PACKET_GAP 500000L // Distance in 1ns between packets 149 #define REPLAYS 1000L // How many times we will repeat the packets 150 #define TX_DELAY 1000000000 // Initial transmission delay (one second) 159 #define REPLAY_TRANSMIT_TIME (PACKET_GAP * PACKETS) 162 #define TOTAL_TRANSMIT_TIME (REPLAY_TRANSMIT_TIME * REPLAYS) 183 fprintf(stderr,
"%s: %s\n", prefix, errorBuffer);
190 switch (data->tsType) {
198 return data->nativeUnixTs * 10;
210 if ((status =
NT_Init(NTAPI_VERSION)) != NT_SUCCESS) {
224 if ((status =
NT_ConfigOpen(&hConfig,
"replay")) != NT_SUCCESS) {
232 if ((status =
NT_ConfigRead(hConfig, &config)) != NT_SUCCESS) {
257 const uint64_t txBeginTS = adapterTS +
TX_DELAY;
273 printError(
"NT_ConfigWrite() failed", status);
282 &hNetTx,
"transmit_on_timestamp_example_txstream", 1ULL <<
PORT,
286 printError(
"NT_NetTxOpen_v2() failed", status);
295 printf(
"Commencing transmission of %ld packets %ld times\n",
PACKETS,
REPLAYS);
298 int totalPackets = 0;
300 for (
int replays = 0; replays <
REPLAYS; replays++) {
302 uint64_t timestamp = 0;
303 for (
int pkts = 0; pkts <
PACKETS; pkts++, totalPackets++) {
319 hdr->
time.
ts_sec = (uint32_t)(timestamp / 1000000000U);
320 hdr->
time.
ts_usec = (uint32_t)(timestamp % 1000000000U);
331 NT_NET_SET_PKT_TXSETCLOCK(hNetBufTx, 1);
344 printError(
"NT_NetTxRelease() failed", status);
355 printf(
"Waiting for transmission to end\n");
361 uint64_t newAdapterTS;
364 if ((status =
NT_ConfigRead(hConfig, &config)) != NT_SUCCESS) {
370 }
while (newAdapterTS < txStopTS);
384 printError(
"NT_ConfigWrite() failed", status);
391 printf(
"Done: %d packets sent\n", totalPackets);