Shared DHCP message counters exist, and the DHCPv4 and DHCPv6 engines count every message they receive and every reply they send #113
Labels
No labels
agent
api-regen
agent
architect
agent
coder
agent
console-coder
agent
docs-writer
agent
mechanic
agent
protocol-coder
agent
storage-coder
area/api
area/ci
area/console
area/dhcp
area/dns
area/docs
area/packaging
area/process
area/storage
area/windows
kind
bug
kind
chore
kind
docs
kind
epic
kind
feature
kind
performance
kind
security
kind
test
priority
high
priority
low
priority
medium
resolution
duplicate
resolution
not-a-bug
resolution
wontfix
status
blocked
status
in-progress
status
needs-decision
status
needs-design
status
ready
theme
ad-samba-dns
theme
alternatives-benchmark
theme
console-toolchain
theme
later
theme
parity-devices
theme
parity-query
theme
post-release-fixes
theme
tracker-setup
theme
valkey
theme
windows-installer
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
lantea-one/ninlil#113
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Nothing counts DHCP traffic today. The only DHCP figures are the per-scope utilisation computed on demand (
src/dotnet/src/Ninlil.Dhcp.Server.Core/Statistics/DhcpScopeStatistics.cs:41-48). The local engines dispatch on the message type in one place each:Dhcpv4RequestHandler.HandleRequestAsync(src/dotnet/src/Ninlil.Dhcp.Server.Core/Dhcpv4RequestHandler.cs:58-131) andDhcpv6RequestHandler(src/dotnet/src/Ninlil.Dhcp.Server.Core/Dhcpv6RequestHandler.cs:287-345). The relay agents (#114) must record into the same counters, andNinlil.Dhcp.Server.Relayreferences onlyNinlil.Dns.Common,Ninlil.Dhcp.Commonand the two protocol projects (Ninlil.Dhcp.Server.Relay.csproj:40-70), notNinlil.Dhcp.Server.Core.What changes
src/dotnet/src/Ninlil.Dhcp.Common/Statistics/(new folder; the shared library both the engines and the relay reference):IDhcpMessageCounterswithRecordV4(Dhcpv4MessageTypeEnum received, Dhcpv4MessageTypeEnum? sent),RecordV6(Dhcpv6MessageTypeEnum received, Dhcpv6MessageTypeEnum? sent),RecordV4Relay(DhcpRelayCountEnum kind),RecordV6Relay(DhcpRelayCountEnum kind)andDhcpMessageCountSnapshot Drain(), which returns the counts since the last drain and resets them.DhcpRelayCountEnum:RequestForwarded,ReplyForwarded,Dropped.DhcpMessageCounters: fixed arrays indexed by message type and relay kind,Interlockedincrements andInterlocked.Exchangeon drain, so a message costs no allocation and no lock.nullsent type counts as "no reply" (no scope, no free address, or a message the server ignores).IDhcpMessageCountersas an optional constructor parameter (null = no counting, so existing tests compile) and record once per handled message, after the switch, from the reply's own message type.TryAddSingletoninServiceCollectionDhcpServerCoreExtension(DHCPv4 local engine) and the DHCPv6 core registration, so both engines share one instance. #114 adds the sameTryAddSingletonto the relay registrations, so a node with one protocol local and the other relayed (src/dotnet/src/Ninlil.Web/Startup/DhcpServiceRegistration.cs:42-76) still has one instance.Acceptance
src/dotnet/tests/Ninlil.Dhcp.Server.Core.Tests: a DISCOVER that gets an OFFER and a REQUEST that gets a NAK drain toreceived DISCOVER = 1,sent OFFER = 1,received REQUEST = 1,sent NAK = 1.received SOLICIT = 1andno reply = 1.RecordV4Relaydrain separately from the engine counts; a secondDrain()returns zeros.src/dotnet/benchmarks/Ninlil.Benchmarks/Dhcp/DhcpOfferBenchmarks.csbefore and after, numbers in the PR.Ninlil.Dhcp.Commonis shared: the whole solution passes. No schema, API or option change.Source