--- Begin Message ---
Hello list,
I use libpcap on linux to start a measurement on the PCIe NIC that my company
developed. I set the tstamp type to adapter_unsynced. pcap_set_tstamp_type
returns with PCAP_WARNING_TSTAMP_TYPE_NOTSUP. The packets I receive in the
packet_handler function I registered contain a software timestamp (number of
seconds sind 1970-01-01).
When I capture via tcpdump I get the correct hardware timestamps (number of
seconds since the NIC was powered). I use following command:
sudo tcpdump -U -i eth0 -j adapter_unsynced -w log.pcap
Do you have an idea why libpcap does not read the hw timestamp but tcpdump does?
NIC tstamp capabilities:
Time stamping parameters for enp5s0f1:
Capabilities:
hardware-transmit (SOF_TIMESTAMPING_TX_HARDWARE)
software-transmit (SOF_TIMESTAMPING_TX_SOFTWARE)
hardware-receive (SOF_TIMESTAMPING_RX_HARDWARE)
software-receive (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
hardware-raw-clock (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes:
off (HWTSTAMP_TX_OFF)
on (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
none (HWTSTAMP_FILTER_NONE)
all (HWTSTAMP_FILTER_ALL)
pcap version:
libpcap version 1.9.1 (with TPACKET_V3)
tcpdump version 4.9.3 (with libpcap 1.9.1 with TPACKET_V3)
Here is the code of my application:
printf("pcap_create device: %s\n", deviceName.c_str());
handle = pcap_create(deviceName.c_str(), errbuf);
int returnVal = pcap_set_snaplen(handle, 65536);
if (returnVal != 0) printf("pcap_set_snaplen failed %s\n",
pcap_geterr(handle));
returnVal = pcap_set_timeout(handle, 1000);
if (returnVal != 0) printf("pcap_set_timeout failed %s\n",
pcap_geterr(handle));
returnVal = pcap_set_buffer_size(handle, 1000000);
if (returnVal != 0)
printf("pcap_set_buffer_size failed %s\n", pcap_geterr(handle));
returnVal = pcap_set_promisc(handle, 1);
if (returnVal != 0) printf("pcap_set_promisc failed %s\n",
pcap_geterr(handle));
int* tstypes;
int ntstypes = pcap_list_tstamp_types(handle, &tstypes);
printf("pcap_list_tstamp_types: number: %d\n", ntstypes);
int requiredTimestampType = 0;
if(ntstypes > 0)
{
for(int i = 0; i < ntstypes; i++)
{
const char* tsName = pcap_tstamp_type_val_to_name(tstypes[i]);
printf("index: %d. name: %s\n", i, tsName);
if(strcmp(tsName, "adapter_unsynced") == 0)
{
requiredTimestampType = i;
}
}
}
printf("requiredTimestampType: %d\n", requiredTimestampType);
returnVal = pcap_set_tstamp_type(handle, requiredTimestampType);
if (returnVal != 0)
{
printf("pcap_set_tstamp_type failed %s\n", pcap_geterr(handle));
if(returnVal == PCAP_ERROR_ACTIVATED)
printf("pcap_set_tstamp_type PCAP_ERROR_ACTIVATED\n");
else if(returnVal == PCAP_ERROR_CANTSET_TSTAMP_TYPE)
printf("pcap_set_tstamp_type PCAP_ERROR_CANTSET_TSTAMP_TYPE\n");
else if(returnVal == PCAP_WARNING_TSTAMP_TYPE_NOTSUP)
printf("pcap_set_tstamp_type
PCAP_WARNING_TSTAMP_TYPE_NOTSUP\n");
}
else
{
printf("pcap_set_tstamp_type ok\n");
}
pcap_free_tstamp_types(tstypes);
returnVal = pcap_activate(handle);
--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers