Skip to content

Commit

Permalink
Merge pull request #94 from named-data/localhop
Browse files Browse the repository at this point in the history
Implement Localhop
  • Loading branch information
pulsejet authored Jan 3, 2025
2 parents 2a4a911 + ade6724 commit 8d7e426
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 195 deletions.
10 changes: 4 additions & 6 deletions dv/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
)

const CostInfinity = uint64(16)
const MulticastStrategy = "/localhost/nfd/strategy/multicast"
const NlsrOrigin = uint64(128)

var Localhop = enc.Name{enc.NewStringComponent(enc.TypeGenericNameComponent, "localhop")}
var Localhost = enc.Name{enc.NewStringComponent(enc.TypeGenericNameComponent, "localhost")}
var MulticastStrategy, _ = enc.NameFromStr("/localhost/nfd/strategy/multicast")

type Config struct {
// Network should be the same for all routers in the network.
Expand Down Expand Up @@ -81,7 +79,7 @@ func (c *Config) Parse() (err error) {
}

// Create name table
c.advSyncPfxN = append(Localhop, append(c.networkNameN,
c.advSyncPfxN = append(enc.Name{enc.LOCALHOP}, append(c.networkNameN,
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
enc.NewStringComponent(enc.TypeKeywordNameComponent, "ADS"),
)...)
Expand All @@ -91,7 +89,7 @@ func (c *Config) Parse() (err error) {
c.advSyncPassivePfxN = append(c.advSyncPfxN,
enc.NewStringComponent(enc.TypeKeywordNameComponent, "PSV"),
)
c.advDataPfxN = append(Localhop, append(c.routerNameN,
c.advDataPfxN = append(enc.Name{enc.LOCALHOP}, append(c.routerNameN,
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
enc.NewStringComponent(enc.TypeKeywordNameComponent, "ADV"),
)...)
Expand All @@ -103,7 +101,7 @@ func (c *Config) Parse() (err error) {
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
enc.NewStringComponent(enc.TypeKeywordNameComponent, "PFX"),
)
c.localPfxN = append(Localhost,
c.localPfxN = append(enc.Name{enc.LOCALHOST},
enc.NewStringComponent(enc.TypeGenericNameComponent, "nlsr"),
)

Expand Down
3 changes: 1 addition & 2 deletions dv/dv/advert_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dv
import (
"time"

"github.com/named-data/ndnd/dv/config"
"github.com/named-data/ndnd/dv/tlv"
enc "github.com/named-data/ndnd/std/encoding"
"github.com/named-data/ndnd/std/log"
Expand All @@ -20,7 +19,7 @@ func (dv *Router) advertDataFetch(nodeId enc.Name, seqNo uint64) {
return
}

advName := append(config.Localhop, append(nodeId,
advName := append(enc.Name{enc.LOCALHOP}, append(nodeId,
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
enc.NewStringComponent(enc.TypeKeywordNameComponent, "ADV"),
enc.NewSequenceNumComponent(seqNo), // unused for now
Expand Down
1 change: 0 additions & 1 deletion dv/dv/advert_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func (dv *Router) advertSyncSendInterestImpl(prefix enc.Name) (err error) {
}

// State Vector for our group
// TODO: switch to new TLV types
sv := &svs_2024.StateVectorAppParam{
StateVector: &svs_2024.StateVector{
Entries: []*svs_2024.StateVectorEntry{{
Expand Down
3 changes: 1 addition & 2 deletions dv/dv/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ func (dv *Router) register() (err error) {
}

// Set strategy to multicast for sync prefixes
mcast, _ := enc.NameFromStr(config.MulticastStrategy)
pfxs = []enc.Name{
dv.config.AdvertisementSyncPrefix(),
dv.config.PrefixTableSyncPrefix(),
Expand All @@ -240,7 +239,7 @@ func (dv *Router) register() (err error) {
Args: &mgmt.ControlArgs{
Name: prefix,
Strategy: &mgmt.Strategy{
Name: mcast,
Name: config.MulticastStrategy,
},
},
Retries: -1,
Expand Down
2 changes: 1 addition & 1 deletion dv/table/neighbor_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (ns *NeighborState) delete() {
}

func (ns *NeighborState) localRoute() enc.Name {
return append(config.Localhop, append(ns.Name,
return append(enc.Name{enc.LOCALHOP}, append(ns.Name,
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
)...)
}
Expand Down
5 changes: 3 additions & 2 deletions fw/defn/pkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type Pkt struct {

PitToken []byte
CongestionMark *uint64
IncomingFaceID *uint64
NextHopFaceID *uint64
CachePolicy *uint64

IncomingFaceID uint64
NextHopFaceID *uint64
}
2 changes: 1 addition & 1 deletion fw/dispatch/face.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Face interface {
type OutPkt struct {
Pkt *defn.Pkt
PitToken []byte
InFace *uint64
InFace uint64
}

// FaceDispatch is used to allow forwarding to interact with faces without a circular dependency issue.
Expand Down
3 changes: 1 addition & 2 deletions fw/face/internal-transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func (t *InternalTransport) runReceive() {

func (t *InternalTransport) Close() {
if t.running.Swap(false) {
close(t.recvQueue)
close(t.sendQueue)
// do not close the queues, let them be garbage collected
}
}
Loading

0 comments on commit 8d7e426

Please # to comment.