Verified Commit cad15e34 authored by Pavel Doležal's avatar Pavel Doležal
Browse files

Config: Make export of implementation specific fields in C-DNS optional (asn,...

Config: Make export of implementation specific fields in C-DNS optional (asn, country_code, round_trip_time)
parent 96a3b5fa
......@@ -77,6 +77,7 @@ default:
export-format: 'parquet'
# This sequence indicates which fields from the C-DNS standard schema are included in exported data.
# 3 implementation specific fields are also included (asn, country_code, round_trip_time).
# By default all fields available in DNS Probe are enabled as shown below.
cdns-fields:
- 'transaction_id'
......@@ -102,7 +103,9 @@ default:
- 'query_opt_rdata'
- 'response_additional_sections'
- 'response_size'
- 'response_delay' # TCP RTT
- 'asn' # asn-maxmind-db configuration option also needs to be set
- 'country_code' # country-maxmind-db configuration option also needs to be set
- 'round_trip_time' # TCP RTT
# Maximum number of DNS records in one exported C-DNS block.
cdns-records-per-block: 10000
......
......@@ -63,7 +63,7 @@ namespace DDP {
asn_db(),
export_format(ExportFormat::PARQUET),
parquet_records(5000000),
cdns_fields(0xFFFFFF),
cdns_fields(get_cdns_bitmask()),
cdns_records_per_block(10000),
cdns_blocks_per_file(0),
export_location(ExportLocation::LOCAL),
......
......@@ -37,7 +37,14 @@ namespace DDP {
using IPv4_t = uint32_t;
using IPv6_t = std::array<uint32_t, 4>;
static constexpr uint8_t CdnsBits = 24; //!< Number of C-DNS fields options
static constexpr uint8_t CdnsBits = 26; //!< Number of C-DNS fields options
static constexpr uint64_t get_cdns_bitmask() {
uint64_t bitmask = 0;
for (unsigned i = 0; i < CdnsBits; i++) {
bitmask |= 1 << i;
}
return bitmask;
}
/**
* Available values for PCAP export config.
......@@ -91,7 +98,9 @@ namespace DDP {
QUERY_OPT_RDATA,
RESPONSE_ADDITIONAL_SECTIONS,
RESPONSE_SIZE,
RESPONSE_DELAY
ASN,
COUNTRY_CODE,
ROUND_TRIP_TIME
};
static const std::unordered_map<std::string, uint32_t> CdnsFieldsMap = {
......@@ -117,7 +126,9 @@ namespace DDP {
{"query_opt_data", static_cast<uint32_t>(CDNSField::QUERY_OPT_RDATA)},
{"response_additional_sections", static_cast<uint32_t>(CDNSField::RESPONSE_ADDITIONAL_SECTIONS)},
{"response_size", static_cast<uint32_t>(CDNSField::RESPONSE_SIZE)},
{"response_delay", static_cast<uint32_t>(CDNSField::RESPONSE_DELAY)},
{"asn", static_cast<uint32_t>(CDNSField::ASN)},
{"country_code", static_cast<uint32_t>(CDNSField::COUNTRY_CODE)},
{"round_trip_time", static_cast<uint32_t>(CDNSField::ROUND_TRIP_TIME)},
};
/**
......
......@@ -218,13 +218,14 @@ boost::any DDP::CdnsExport::buffer_record(DnsRecord& record)
if (m_fields[static_cast<uint32_t>(CDNSField::RESPONSE_SIZE)])
qr.response_size = record.m_res_dns_len;
if (m_fields[static_cast<uint32_t>(CDNSField::RESPONSE_DELAY)])
qr.response_delay = record.m_tcp_rtt;
if (m_fields[static_cast<uint32_t>(CDNSField::ROUND_TRIP_TIME)])
// need to convert millisecond m_tcp_rtt to ticks which represent microseconds
qr.round_trip_time = record.m_tcp_rtt * 1000;
if (!asn.empty())
if (m_fields[static_cast<uint32_t>(CDNSField::ASN)] && !asn.empty())
qr.asn = asn;
if (!country.empty())
if (m_fields[static_cast<uint32_t>(CDNSField::COUNTRY_CODE)] && !country.empty())
qr.country_code = country;
// Add QueryResponseSignature to the QueryResponse
......
......@@ -96,9 +96,6 @@ void DDP::set_cdns_hints(uint32_t& qr_hints, uint32_t& qr_sig_hints, std::bitset
if (fields[static_cast<uint32_t>(CDNSField::RESPONSE_SIZE)])
qr_hints |= CDNS::QueryResponseHintsMask::response_size;
if (fields[static_cast<uint32_t>(CDNSField::RESPONSE_DELAY)])
qr_hints |= CDNS::QueryResponseHintsMask::response_delay;
}
DDP::CdnsWriter::CdnsWriter(Config& cfg, uint32_t process_id) : BaseWriter(cfg, process_id,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment