feat: add ns-3 discrete-event simulation support (ndndSIM)#178
Draft
markverick wants to merge 9 commits intonamed-data:mainfrom
Draft
feat: add ns-3 discrete-event simulation support (ndndSIM)#178markverick wants to merge 9 commits intonamed-data:mainfrom
markverick wants to merge 9 commits intonamed-data:mainfrom
Conversation
- Add clock injection (fw/core/clock.go): NowFunc variable defaults to time.Now, overridable for simulation. Replace all time.Now() calls in forwarding plane with core.Now(). - Add per-thread FIB override (fw/fw/thread.go): SetFib()/Fib() allow isolated FIB per simulated node while defaulting to global FibStrategyTable. - Add synchronous packet processing (ProcessPacket, RunMaintenance) for single-threaded discrete-event simulation. - Add NewFibStrategyTree() standalone constructor. - Add sim/ package: CGo bridge, SimEngine, SimForwarder, SimFace, and supporting types for ns-3 integration.
…tches, SVS sim support
- AnnouncePrefix/WithdrawPrefix in sim/dv.go for runtime DV route manipulation - AddRouteWithOrigin/RemoveRouteWithOrigin in sim/forwarder.go - CGo exports in sim/cgo_export.go - SimNode wiring in sim/node.go - InitRoot() in fw/table/rib.go for RIB initialization - Fix engine.go face ID lookup
Author
Export RIB entry count from Go forwarder to C++ via CGo bridge. Supports optional prefix filter to count only entries under a specific namespace (e.g., /ndn for DV routing entries).
- Add SimTrust for shared Ed25519 root key and per-node keychain generation, matching the emulation security pipeline - Config: add optional KeyChain/Store fields for pre-built keychain injection (bypasses KeyChainUri) - Router: use injected keychain/store when provided - Engine: include NextHopFaceId in LP packets for cert fetching - Forwarder: extract NextHopFaceId from LP for forwarding pipeline - Node: replace insecure mode with Ed25519 trust setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add ns-3 discrete-event simulation support (ndndSIM)
Summary
This PR adds support for running NDNd inside the ns-3 network simulator as part of the ndndSIM project. It introduces a new
sim/package that bridges NDNd's Go forwarding plane with ns-3's C++ simulation engine via CGo, and makes targeted changes to the forwarding, routing, and sync layers to allow deterministic, single-threaded, discrete-event simulation.Motivation
NDN simulation is critical for protocol research and evaluation. ndnSIM is the standard ns-3–based NDN simulator, but until now it has been tightly coupled with the C++ NFD forwarder. This patch enables ndndSIM to use NDNd as its forwarding and routing engine, allowing researchers to simulate NDNd's DV routing and SVS sync protocols at scale in a controlled, reproducible environment.
Changes
New
sim/package (~2,200 LOC)A complete CGo bridge between NDNd (Go) and ns-3 (C++):
sim/engine.goSimEngineimplementsndn.Engine, translating NDNd's async engine interface into synchronous calls suitable for discrete-event simulation. Manages face dispatch, Interest/Data handler registration, and management command execution.sim/forwarder.goSimForwarderwrapsfw.Threadwith per-node FIB, face table, and route management (AddRoute/RemoveRoute/AddRouteWithOrigin/RemoveRouteWithOrigin).sim/face.goSimFacerepresents a simulated network face backed by ns-3 NetDevices.sim/fw_face.gofw.Faceinterface for the simulation layer.sim/node.goSimNodeties together the engine, forwarder, DV router, and application-level callbacks per simulated node.sim/dv.gosim/clock.gocore.NowFuncto ns-3 simulation time.sim/timer.gosim/runtime.gosim/cgo_export.go//exportfunctions callable from C++ (node creation, packet injection, face management, DV control, etc.).sim/ndndsim_sim.hsim/doc.go,sim/util.go,sim/cmd/main.goForwarding plane hooks (minimal, non-breaking)
fw/core/clock.go(new)core.NowFunc(defaults totime.Now) andcore.Now(). Alltime.Now()calls in the forwarding plane are replaced withcore.Now()so simulation can inject ns-3 time.fw/fw/thread.goSetFib()/Fib()for per-thread FIB override (defaults to globalFibStrategyTable). AddsProcessPacket()andRunMaintenance()for synchronous single-threaded packet processing. Replacestime.Now()→core.Now().fw/fw/bestroute.go,fw/fw/multicast.gotime.Now()→core.Now().fw/table/fib-strategy-tree.goNewFibStrategyTree()standalone constructor (does not touch global state).fw/table/pit-cs-tree.go,fw/table/pit-cs.go,fw/table/dead-nonce-list.gotime.Now()→core.Now().fw/table/rib.goInitRoot()for standalone RIB table initialization.DV routing — simulation compatibility
dv/dv/router.goGoFunc,NowFunc,AfterFuncfields to decouple goroutine/timer usage. AddsInit()(non-blocking setup),RunHeartbeat(),RunDeadcheck(),Cleanup(), andNfdc()for simulation-driven lifecycle. Replacesgo f()→dv.GoFunc(f)andtime.AfterFunc→dv.AfterFuncthroughout.dv/dv/advert_data.go,dv/dv/advert_sync.go,dv/dv/table_algo.gogo f()→dv.GoFunc(f),time.AfterFunc→engine.Timer().Schedule().dv/nfdc/nfdc.goSynchronousmode for direct command execution (no goroutine queue).dv/table/neighbor_table.gotime.Now()/time.Since()→core.Now().SVS sync — simulation compatibility
std/sync/svs.goGoFunc,NowFunc,AfterFunctoSvSyncOpts. Replacestime.TickerwithscheduleTimer()using injectableAfterFunc. RemovesrecvSvchannel; state vectors are now processed inline viaGoFunc.std/sync/svs_alo.gorun()loop (outpipe/errpipe/publpipe/stop). Publications and errors are delivered directly viaGoFunc.std/sync/svs_alo_data.gotime.AfterFunc→s.opts.Svs.AfterFunc.Design Principles
time.Now,go f(),time.AfterFunc). Existing users and tests are unaffected.time.Now()withcore.Now()and adding opt-in per-thread FIB support. No existing APIs are removed or changed.GoFuncdispatch and channels are replaced with direct callbacks, enabling single-threaded, deterministic execution under ns-3's discrete-event scheduler.Testing
These changes have been validated in the atlas-scenarios framework, which runs multi-node grid topologies (2×2 through 6×6) with DV routing and SVS sync under both ndndSIM simulation and Mini-NDN emulation. Both modes produce consistent per-packet byte sizes and convergence behavior when run with matching parameters.