Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfdc / dvc + URI refactor + client conf #93

Merged
merged 36 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a4b95f
refactor: move cmdtree to std
pulsejet Jan 2, 2025
9adc883
nfdc: implement route list
pulsejet Jan 2, 2025
9964b35
nfdc: add fib list
pulsejet Jan 2, 2025
42fa407
nfdc: add more datasets
pulsejet Jan 2, 2025
e6db8e2
nfdc: add more status datasets
pulsejet Jan 2, 2025
1bb789c
nfdc: refactor start
pulsejet Jan 2, 2025
c07c200
nfdc: add face create
pulsejet Jan 2, 2025
18822a9
nfdc: improve face create
pulsejet Jan 2, 2025
7304e46
nfdc: implement route create and destroy
pulsejet Jan 2, 2025
451618a
nfdc: implement strategy commands
pulsejet Jan 2, 2025
5f76601
std: fix docs
pulsejet Jan 2, 2025
bbf0233
refactor: move nfdc to package
pulsejet Jan 2, 2025
52cf0a7
fw: add missing nil check
pulsejet Jan 2, 2025
4a43596
nfdc: add face creation
pulsejet Jan 2, 2025
c90295d
nfdc: fix output of route add
pulsejet Jan 2, 2025
a8742b9
fw: fix strategy log
pulsejet Jan 2, 2025
096eab8
cmd: add dv link commands
pulsejet Jan 2, 2025
167d837
engine: add NewDefaultFace
pulsejet Jan 2, 2025
cf24106
std: implement client configuration
pulsejet Jan 2, 2025
f1bf133
dvc: fix error message
pulsejet Jan 2, 2025
5e7196a
dv: simplify config
pulsejet Jan 2, 2025
921bf6e
nfdc: fix face create error
pulsejet Jan 2, 2025
95fc6bb
fw: reimplement URI parsing
pulsejet Jan 2, 2025
284541e
fw: fix log spacing
pulsejet Jan 2, 2025
559c50d
fw: default port to 6363
pulsejet Jan 2, 2025
9779c62
fw: various fixes
pulsejet Jan 2, 2025
5429e7b
dv: do not reset time when ping is not active
pulsejet Jan 2, 2025
2f88002
fw: refactor transport uri parsing
pulsejet Jan 2, 2025
74e5664
fw: refactor startup URI parsing
pulsejet Jan 2, 2025
aff18b0
fw: register global tcp and udp listeners
pulsejet Jan 2, 2025
2275939
fw: refactor some logging
pulsejet Jan 2, 2025
4303776
docs: update for nfdc and dvc
pulsejet Jan 2, 2025
88de60c
engine: fix return value
pulsejet Jan 2, 2025
36bbb41
fw: add lock to RIB (fix #82)
pulsejet Jan 2, 2025
b198a0a
std: refactor mgmt/const -> persistency
pulsejet Jan 3, 2025
8ee8188
std: switch mgmt/nfd/status to time
pulsejet Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions cmd/ndnd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,46 @@ package main
import (
"os"

"github.com/named-data/ndnd/cmd"
dv "github.com/named-data/ndnd/dv/executor"
fw "github.com/named-data/ndnd/fw/executor"
"github.com/named-data/ndnd/std/utils"
tools "github.com/named-data/ndnd/tools"
dvc "github.com/named-data/ndnd/tools/dvc"
nfdc "github.com/named-data/ndnd/tools/nfdc"
)

func main() {
// subtrees from other packages
nfdcTree := nfdc.GetNfdcCmdTree()

// create a command tree
tree := cmd.CmdTree{
tree := utils.CmdTree{
Name: "ndnd",
Help: "Named Data Networking Daemon",
Sub: []*cmd.CmdTree{{
Sub: []*utils.CmdTree{{
Name: "fw",
Help: "NDN Forwarding Daemon",
Sub: []*cmd.CmdTree{{
Sub: append([]*utils.CmdTree{{
Name: "run",
Help: "Start the NDN Forwarding Daemon",
Fun: fw.Main,
}},
}, {},
}, nfdcTree.Sub...),
}, {
Name: "dv",
Help: "NDN Distance Vector Routing Daemon",
Sub: []*cmd.CmdTree{{
Sub: []*utils.CmdTree{{
Name: "run",
Help: "Start the NDN Distance Vector Routing Daemon",
Fun: dv.Main,
}, {}, {
Name: "link create",
Help: "Create a new active neighbor link",
Fun: dvc.RunDvLinkCreate(&nfdcTree),
}, {
Name: "link destroy",
Help: "Destroy an active neighbor link",
Fun: dvc.RunDvLinkDestroy(&nfdcTree),
}},
}, {
// tools separator
Expand Down
18 changes: 15 additions & 3 deletions dv/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Config struct {
// Prefix Table Data Prefix
pfxDataPfxN enc.Name
// NLSR readvertise prefix
readvertisePfxN enc.Name
localPfxN enc.Name
}

func DefaultConfig() *Config {
Expand Down Expand Up @@ -103,7 +103,7 @@ func (c *Config) Parse() (err error) {
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
enc.NewStringComponent(enc.TypeKeywordNameComponent, "PFX"),
)
c.readvertisePfxN = append(Localhost,
c.localPfxN = append(Localhost,
enc.NewStringComponent(enc.TypeGenericNameComponent, "nlsr"),
)

Expand Down Expand Up @@ -142,8 +142,20 @@ func (c *Config) PrefixTableDataPrefix() enc.Name {
return c.pfxDataPfxN
}

func (c *Config) LocalPrefix() enc.Name {
return c.localPfxN
}

func (c *Config) ReadvertisePrefix() enc.Name {
return c.readvertisePfxN
return append(c.localPfxN,
enc.NewStringComponent(enc.TypeGenericNameComponent, "rib"),
)
}

func (c *Config) StatusPrefix() enc.Name {
return append(c.localPfxN,
enc.NewStringComponent(enc.TypeGenericNameComponent, "status"),
)
}

func (c *Config) AdvertisementSyncInterval() time.Duration {
Expand Down
6 changes: 1 addition & 5 deletions dv/dv.sample.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
nfd:
# [optional] Unix socket used to connect to the local forwarder
unix: /var/run/nfd/nfd.sock

config:
dv:
# [required] Global prefix for all DV routers in the network
network: /ndn
# [required] Unique name for each router in the network
Expand Down
11 changes: 10 additions & 1 deletion dv/dv/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,22 @@ func (dv *Router) register() (err error) {
return err
}

// Router status
err = dv.engine.AttachHandler(dv.config.StatusPrefix(),
func(args ndn.InterestHandlerArgs) {
go dv.statusOnInterest(args)
})
if err != nil {
return err
}

// Register routes to forwarder
pfxs := []enc.Name{
dv.config.AdvertisementSyncPrefix(),
dv.config.AdvertisementDataPrefix(),
dv.config.PrefixTableSyncPrefix(),
dv.config.PrefixTableDataPrefix(),
dv.config.ReadvertisePrefix(),
dv.config.LocalPrefix(),
}
for _, prefix := range pfxs {
dv.nfdc.Exec(nfdc.NfdMgmtCmd{
Expand Down
34 changes: 34 additions & 0 deletions dv/dv/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dv

import (
"time"

"github.com/named-data/ndnd/dv/tlv"
"github.com/named-data/ndnd/std/log"
"github.com/named-data/ndnd/std/ndn"
"github.com/named-data/ndnd/std/security"
"github.com/named-data/ndnd/std/utils"
)

// Received advertisement Interest
func (dv *Router) statusOnInterest(args ndn.InterestHandlerArgs) {
status := tlv.Status{
NetworkName: &tlv.Destination{Name: dv.config.NetworkName()},
RouterName: &tlv.Destination{Name: dv.config.RouterName()},
}

name := args.Interest.Name()
cfg := &ndn.DataConfig{
ContentType: utils.IdPtr(ndn.ContentTypeBlob),
Freshness: utils.IdPtr(time.Second),
}
signer := security.NewSha256Signer()

data, err := dv.engine.Spec().MakeData(name, cfg, status.Encode(), signer)
if err != nil {
log.Warnf("readvertise: failed to make response Data: %+v", err)
return
}

args.Reply(data.Wire)
}
17 changes: 5 additions & 12 deletions dv/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ import (
)

type DvConfig struct {
// NFD related options
Nfd struct {
Unix string `json:"unix"`
} `json:"nfd"`

// Underlying configuration
Config *config.Config `json:"config"`
Config *config.Config `json:"dv"`
}

func DefaultConfig() DvConfig {
dc := DvConfig{}
dc.Nfd.Unix = "/var/run/nfd/nfd.sock"
dc.Config = config.DefaultConfig()
return dc
return DvConfig{
Config: config.DefaultConfig(),
}
}

func (dc DvConfig) Parse() error {
Expand All @@ -45,7 +38,7 @@ func NewDvExecutor(dc DvConfig) (*DvExecutor, error) {
}

// Start NDN engine
dve.engine = engine.NewBasicEngine(engine.NewUnixFace(dc.Nfd.Unix))
dve.engine = engine.NewBasicEngine(engine.NewDefaultFace())

// Create the DV router
dve.router, err = dv.NewRouter(dc.Config, dve.engine)
Expand Down
2 changes: 1 addition & 1 deletion dv/nfdc/nfdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m *NfdMgmtThread) Start() {
select {
case cmd := <-m.channel:
for i := 0; i < cmd.Retries || cmd.Retries < 0; i++ {
err := m.engine.ExecMgmtCmd(cmd.Module, cmd.Cmd, cmd.Args)
_, err := m.engine.ExecMgmtCmd(cmd.Module, cmd.Cmd, cmd.Args)
if err != nil {
log.Errorf("nfdc %s %s failed: %s %+v [%d]", cmd.Module, cmd.Cmd, cmd.Args.Name, err, i)
time.Sleep(100 * time.Millisecond)
Expand Down
12 changes: 7 additions & 5 deletions dv/table/neighbor_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,18 @@ func (ns *NeighborState) IsDead() bool {
// and update the last seen time for the neighbor.
// Return => true if the face ID has changed
func (ns *NeighborState) RecvPing(faceId uint64, active bool) (error, bool) {
if ns.isFaceActive && !active {
// This ping is passive, but we already have an active ping.
return nil, false // ignore this ping.
}

// Update last seen time for neighbor
// Note that we skip this when the face is active and the ping is passive.
// This is because we want to detect if the active face is removed.
ns.lastSeen = time.Now()

// If face ID has changed, re-register face.
if ns.faceId != faceId {
if ns.isFaceActive && !active {
// This ping is passive, but we already have an active ping.
return nil, false // ignore this ping.
}

ns.isFaceActive = active
log.Infof("neighbor: %s face ID changed from %d to %d", ns.Name, ns.faceId, faceId)
ns.routeUnregister()
Expand Down
7 changes: 7 additions & 0 deletions dv/tlv/tlv.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ type PrefixOpRemove struct {
//+field:name
Name enc.Name `tlv:"0x07"`
}

type Status struct {
//+field:struct:Destination
NetworkName *Destination `tlv:"0x191"`
//+field:struct:Destination
RouterName *Destination `tlv:"0x193"`
}
Loading
Loading