Skip to content

Commit b6afcc2

Browse files
authored
Merge branch 'main' into alloc-opt
2 parents e11a3ad + ca3ac59 commit b6afcc2

File tree

13 files changed

+110
-110
lines changed

13 files changed

+110
-110
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ndnd fw run yanfd.config.yml
6464
A full configuration example can be found in [fw/yanfd.sample.yml](fw/yanfd.sample.yml).
6565
Note that the default configuration may require root privileges to bind to multicast interfaces.
6666

67-
Once started, you can use the [Forwarder Control](tools/nfdc/README.md) tool to manage faces and routes.
67+
Once started, you can use the [forwarder control](tools/nfdc/README.md) tool to manage faces and routes.
6868

6969
## 📡 Distance Vector Router
7070

@@ -79,7 +79,7 @@ ndnd dv run dv.config.yml
7979
A full configuration example can be found in [dv/dv.sample.yml](dv/dv.sample.yml).
8080
Make sure the network and router name are correctly configured and the forwarder is running.
8181

82-
Once started, you can use the [DV Control](tools/dvc/README.md) tool to create and destroy neighbor links.
82+
Once started, you can use the [router control](tools/dvc/README.md) tool to create and destroy neighbor links.
8383

8484
## 📚 Standard Library
8585

dv/dv/advert_data.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ func (dv *Router) advertGenerateNew() {
3434
go dv.advertSyncSendInterest()
3535
}
3636

37-
func (dv *Router) advertDataFetch(nodeId enc.Name, seqNo uint64) {
37+
func (dv *Router) advertDataFetch(nName enc.Name, seqNo uint64) {
3838
// debounce; wait before fetching, then check if this is still the latest
3939
// sequence number known for this neighbor
4040
time.Sleep(10 * time.Millisecond)
41-
if ns := dv.neighbors.Get(nodeId); ns == nil || ns.AdvertSeq != seqNo {
41+
if ns := dv.neighbors.Get(nName); ns == nil || ns.AdvertSeq != seqNo {
4242
return
4343
}
4444

4545
// Fetch the advertisement
46-
advName := enc.LOCALHOP.Append(nodeId.Append(
46+
advName := enc.LOCALHOP.Append(nName.Append(
4747
enc.NewStringComponent(enc.TypeKeywordNameComponent, "DV"),
4848
enc.NewStringComponent(enc.TypeKeywordNameComponent, "ADV"),
4949
enc.NewVersionComponent(seqNo),
@@ -59,32 +59,32 @@ func (dv *Router) advertDataFetch(nodeId enc.Name, seqNo uint64) {
5959
if fetchErr != nil {
6060
log.Warnf("advert-data: failed to fetch advertisement %s: %+v", state.Name(), fetchErr)
6161
time.Sleep(1 * time.Second) // wait on error
62-
dv.advertDataFetch(nodeId, seqNo)
62+
dv.advertDataFetch(nName, seqNo)
6363
return
6464
}
6565

6666
// Process the advertisement
67-
dv.advertDataHandler(nodeId, seqNo, state.Content())
67+
dv.advertDataHandler(nName, seqNo, state.Content())
6868
}()
6969

7070
return true
7171
})
7272
}
7373

7474
// Received advertisement Data
75-
func (dv *Router) advertDataHandler(nodeId enc.Name, seqNo uint64, data []byte) {
75+
func (dv *Router) advertDataHandler(nName enc.Name, seqNo uint64, data []byte) {
7676
// Lock DV state
7777
dv.mutex.Lock()
7878
defer dv.mutex.Unlock()
7979

8080
// Check if this is the latest advertisement
81-
ns := dv.neighbors.Get(nodeId)
81+
ns := dv.neighbors.Get(nName)
8282
if ns == nil {
83-
log.Warnf("advert-handler: unknown advertisement %s", nodeId)
83+
log.Warnf("advert-handler: unknown advertisement %s", nName)
8484
return
8585
}
8686
if ns.AdvertSeq != seqNo {
87-
log.Debugf("advert-handler: old advertisement for %s (%d != %d)", nodeId, ns.AdvertSeq, seqNo)
87+
log.Debugf("advert-handler: old advertisement for %s (%d != %d)", nName, ns.AdvertSeq, seqNo)
8888
return
8989
}
9090

dv/dv/advert_sync.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func (dv *Router) advertSyncSendInterestImpl(prefix enc.Name) (err error) {
4343
sv := &svs_2024.StateVectorAppParam{
4444
StateVector: &svs_2024.StateVector{
4545
Entries: []*svs_2024.StateVectorEntry{{
46-
NodeId: dv.config.RouterName(),
47-
SeqNo: dv.advertSyncSeq,
46+
Name: dv.config.RouterName(),
47+
SeqNo: dv.advertSyncSeq,
4848
}},
4949
},
5050
}
@@ -102,15 +102,15 @@ func (dv *Router) advertSyncOnInterest(args ndn.InterestHandlerArgs, active bool
102102

103103
// There should only be one entry in the StateVector, but check all anyway
104104
for _, entry := range params.StateVector.Entries {
105-
// Parse name from NodeId
106-
nodeId := entry.NodeId
107-
if nodeId == nil {
108-
log.Warnf("advertSyncOnInterest: failed to parse NodeId: %+v", err)
105+
// Parse name from entry
106+
nName := entry.Name
107+
if nName == nil {
108+
log.Warnf("advertSyncOnInterest: failed to parse neighbor name: %+v", err)
109109
continue
110110
}
111111

112112
// Check if the entry is newer than what we know
113-
ns := dv.neighbors.Get(nodeId)
113+
ns := dv.neighbors.Get(nName)
114114
if ns != nil {
115115
if ns.AdvertSeq >= entry.SeqNo {
116116
// Nothing has changed, skip
@@ -121,13 +121,13 @@ func (dv *Router) advertSyncOnInterest(args ndn.InterestHandlerArgs, active bool
121121
// Create new neighbor entry cause none found
122122
// This is the ONLY place where neighbors are created
123123
// In all other places, quit if not found
124-
ns = dv.neighbors.Add(nodeId)
124+
ns = dv.neighbors.Add(nName)
125125
}
126126

127127
markRecvPing(ns)
128128
ns.AdvertSeq = entry.SeqNo
129129

130-
go dv.advertDataFetch(nodeId, entry.SeqNo)
130+
go dv.advertDataFetch(nName, entry.SeqNo)
131131
}
132132

133133
// Update FIB if needed

dv/dv/prefix_sync.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ func (dv *Router) prefixDataFetchAll() {
2626
func (dv *Router) onPfxSyncUpdate(ssu ndn_sync.SvSyncUpdate) {
2727
// Update the prefix table
2828
dv.mutex.Lock()
29-
dv.pfx.GetRouter(ssu.NodeId).Latest = ssu.High
29+
dv.pfx.GetRouter(ssu.Name).Latest = ssu.High
3030
dv.mutex.Unlock()
3131

3232
// Start a fetching thread (if needed)
33-
dv.prefixDataFetch(ssu.NodeId)
33+
dv.prefixDataFetch(ssu.Name)
3434
}
3535

3636
// Fetch prefix data
37-
func (dv *Router) prefixDataFetch(nodeId enc.Name) {
37+
func (dv *Router) prefixDataFetch(nName enc.Name) {
3838
dv.mutex.Lock()
3939
defer dv.mutex.Unlock()
4040

4141
// Check if the RIB has this destination
42-
if !dv.rib.Has(nodeId) {
42+
if !dv.rib.Has(nName) {
4343
return
4444
}
4545

4646
// At any given time, there is only one thread fetching
4747
// prefix data for a node. This thread recursively calls itself.
48-
router := dv.pfx.GetRouter(nodeId)
48+
router := dv.pfx.GetRouter(nName)
4949
if router == nil || router.Fetching || router.Known >= router.Latest {
5050
return
5151
}
5252
router.Fetching = true
5353

5454
// Fetch the prefix data object
55-
log.Debugf("prefix-table: fetching object for %s [%d => %d]", nodeId, router.Known, router.Latest)
55+
log.Debugf("prefix-table: fetching object for %s [%d => %d]", nName, router.Known, router.Latest)
5656

5757
name := router.GetNextDataName()
5858
dv.client.Consume(name, func(state *object.ConsumeState) bool {
@@ -78,7 +78,7 @@ func (dv *Router) prefixDataFetch(nodeId enc.Name) {
7878

7979
// Done fetching, restart if needed
8080
router.Fetching = false
81-
go dv.prefixDataFetch(nodeId)
81+
go dv.prefixDataFetch(nName)
8282
}()
8383

8484
return true

std/examples/low-level/svs/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ func main() {
2121
logger := log.WithField("module", "main")
2222

2323
if len(os.Args) < 2 {
24-
log.Fatalf("Usage: %s <nodeId>", os.Args[0])
24+
log.Fatalf("Usage: %s <name>", os.Args[0])
2525
}
2626

2727
// Parse command line arguments
28-
nodeId, err := enc.NameFromStr(os.Args[1])
28+
name, err := enc.NameFromStr(os.Args[1])
2929
if err != nil {
3030
log.Fatalf("Invalid node ID: %s", os.Args[1])
3131
}
@@ -63,7 +63,7 @@ func main() {
6363
ticker := time.NewTicker(3 * time.Second)
6464

6565
for range ticker.C {
66-
new := svsync.IncrSeqNo(nodeId)
66+
new := svsync.IncrSeqNo(name)
6767
logger.Infof("Published new sequence number: %d", new)
6868
}
6969
}

std/examples/schema-test/chat/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const SchemaJson = `{
4141
"ChannelSize": 1000,
4242
"SyncInterval": 15000,
4343
"SuppressionInterval": 100,
44-
"SelfNodeId": "$nodeId",
44+
"SelfName": "$nodeId",
4545
"BaseMatching": {}
4646
}
4747
}
@@ -238,15 +238,15 @@ func main() {
238238
select {
239239
case missData := <-ch:
240240
for i := missData.StartSeq; i < missData.EndSeq; i++ {
241-
dataName := syncNode.Call("GetDataName", missData.NodeId, i).(enc.Name)
241+
dataName := syncNode.Call("GetDataName", missData.Name, i).(enc.Name)
242242
mLeafNode := tree.Match(dataName)
243243
result := <-mLeafNode.Call("NeedChan").(chan schema.NeedResult)
244244
if result.Status != ndn.InterestResultData {
245-
fmt.Printf("Data fetching failed for (%s, %d): %+v\n", missData.NodeId.String(), i, result.Status)
245+
fmt.Printf("Data fetching failed for (%s, %d): %+v\n", missData.Name, i, result.Status)
246246
} else {
247247
dataLock.Lock()
248-
fmt.Printf("Fetched (%s, %d): %s\n", missData.NodeId.String(), i, string(result.Content.Join()))
249-
msg := fmt.Sprintf("%s[%d]: %s", missData.NodeId.String(), i, string(result.Content.Join()))
248+
fmt.Printf("Fetched (%s, %d): %s\n", missData.Name.String(), i, string(result.Content.Join()))
249+
msg := fmt.Sprintf("%s[%d]: %s", missData.Name.String(), i, string(result.Content.Join()))
250250
msgList = append(msgList, msg)
251251
if wsConn != nil {
252252
wsConn.WriteMessage(websocket.TextMessage, []byte(msg))

std/examples/schema-test/chat/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ChannelSize": 1000,
77
"SyncInterval": 15000,
88
"SuppressionInterval": 100,
9-
"SelfNodeId": "$nodeId",
9+
"SelfName": "$nodeId",
1010
"BaseMatching": {}
1111
}
1212
}

std/examples/schema-test/sync/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const SchemaJson = `{
2828
"ChannelSize": 1000,
2929
"SyncInterval": 2000,
3030
"SuppressionInterval": 100,
31-
"SelfNodeId": "$nodeId",
31+
"SelfName": "$nodeId",
3232
"BaseMatching": {}
3333
}
3434
}
@@ -132,13 +132,13 @@ func main() {
132132
select {
133133
case missData := <-ch:
134134
for i := missData.StartSeq; i < missData.EndSeq; i++ {
135-
dataName := mNode.Call("GetDataName", missData.NodeId, i).(enc.Name)
135+
dataName := mNode.Call("GetDataName", missData.Name, i).(enc.Name)
136136
mLeafNode := tree.Match(dataName)
137137
result := <-mLeafNode.Call("NeedChan").(chan schema.NeedResult)
138138
if result.Status != ndn.InterestResultData {
139-
fmt.Printf("Data fetching failed for (%s, %d): %+v\n", missData.NodeId.String(), i, result.Status)
139+
fmt.Printf("Data fetching failed for (%s, %d): %+v\n", missData.Name.String(), i, result.Status)
140140
} else {
141-
fmt.Printf("Fetched (%s, %d): %s", missData.NodeId.String(), i, string(result.Content.Join()))
141+
fmt.Printf("Fetched (%s, %d): %s", missData.Name.String(), i, string(result.Content.Join()))
142142
}
143143
}
144144
case <-ctx.Done():

std/examples/schema-test/sync/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ChannelSize": 1000,
77
"SyncInterval": 2000,
88
"SuppressionInterval": 100,
9-
"SelfNodeId": "$nodeId",
9+
"SelfName": "$nodeId",
1010
"BaseMatching": {}
1111
}
1212
}

std/ndn/svs_2024/definitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type StateVector struct {
1717

1818
type StateVectorEntry struct {
1919
//+field:name
20-
NodeId enc.Name `tlv:"0x07"`
20+
Name enc.Name `tlv:"0x07"`
2121
//+field:natural
2222
SeqNo uint64 `tlv:"0xcc"`
2323
}

0 commit comments

Comments
 (0)