mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-10-04 19:42:02 +08:00
增加CoordinateLsa、NameLsa及其组件,已完成一部分函数
This commit is contained in:
1 parent
ae67a125a1
commit
368c3cee86
8 files changed
+171
-13
No files matched your search
@@ -11,18 +11,26 @@
|
||||
package extensions
|
||||
|
||||
const (
|
||||
// TlvMlsrLsa for MLSR
|
||||
// Lsa for MLSR
|
||||
TlvMlsrLsaAdjacency = 401 // 表示MIR之间邻接关系信息的LSA
|
||||
TlvMlsrLsaContent = 402 // 表示内容标识信息的LSA
|
||||
TlvMlsrLsaNamePrefix = 402 // 表示名称前缀(内容标识、身份标识等以前缀形式命名的标识)信息的LSA
|
||||
TlvMlsrLsaCoordinate = 403 // 表示坐标信息的LSA
|
||||
|
||||
TlvMlsrLsaBase = 410 // 表示LSA最基本信息:源MIR、序列号、过期时间
|
||||
TlvMlsrLsaExpirationTime = 420 // LSA过期时间
|
||||
TlvMlsrLsaSequenceNumber = 421 // LSA序列号
|
||||
// 所有类型Lsa的必需部分
|
||||
TlvMlsrLsaBase = 410 // 表示LSA最基本信息:源MIR、序列号、过期时间
|
||||
TlvMlsrLsaExpirationTime = 420 // LSA过期时间
|
||||
TlvMlsrLsaSequenceNumber = 421 // LSA序列号
|
||||
|
||||
TlvMlsrAdjLsaLogicFaceId = 422 // logicfaceId
|
||||
// AdjLsa的组件
|
||||
TlvMlsrAdjLsaLogicFaceId = 422 // logicface Id
|
||||
TlvMlsrAdjLsaLinkCost = 423 // 链路开销
|
||||
TlvMlsrAdjLsaLogicFaceUri = 424 // LogicFace前缀
|
||||
TlvMlsrAdjLsaAdjacencyInfo = 425 // 单条邻接LSA信息
|
||||
TlvMlsrAdjLsaAdjacencyInfo = 425 // 单条邻接信息
|
||||
TlvMlsrAdjLsaAdjacencyList = 426 // 一个邻接LSA包含的所有邻接信息
|
||||
|
||||
// NameLsa的组件
|
||||
TlvMlsrNameLsaNamePrefixSource = 427 // 名称前缀的来源
|
||||
TlvMlsrNameLsaNamePrefixInfo = 428 // 单条名称前缀信息
|
||||
TlvMlsrNameLsaNamePrefixList = 429 // 一个名称LSA包含的所有名称前缀信息
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ type AdjLsaAdjacencyInfo struct {
|
||||
AdjLsaLinkCost // 两个路由器之间的链路成本
|
||||
AdjLsaLogicFaceUri // MIR层级对LogicFace的字符串描述,如udp://1.0.0.2,或ether:aa.aa.aa.aa...
|
||||
AdjLsaLogicFaceId // MIR给LogicFace分配的uint64类型的id,如182828,nlsr可通过该id定位到哪个logicface负责传该链路数据
|
||||
lsaNeighborRouterIdentifier *component.Identifier // NLSR已配置的邻居路由器标识符,如/min/pkusz/group1
|
||||
lsaNeighborRouterIdentifier *component.Identifier // NLSR已配置的邻居路由器标识符,如/min/pkusz/group1/router1
|
||||
|
||||
InterestTimedOutNo uint32 // 自从收到最后一个回复之后,记录已经失败的hello兴趣包的数目
|
||||
Status int // 表示邻居路由器的状态:未知-1、未激活0、激活1
|
||||
|
||||
@@ -28,7 +28,7 @@ type AdjLsaLogicFaceUri struct {
|
||||
// @receiver l
|
||||
// @return string
|
||||
//
|
||||
func (l AdjLsaLogicFaceUri) LogicFaceUri() string {
|
||||
func (l *AdjLsaLogicFaceUri) LogicFaceUri() string {
|
||||
return l.CommonString.Value()
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (l AdjLsaLogicFaceUri) LogicFaceUri() string {
|
||||
// @receiver l
|
||||
// @param logicFaceUri
|
||||
//
|
||||
func (l AdjLsaLogicFaceUri) setLogicFaceUri(logicFaceUri string) {
|
||||
func (l *AdjLsaLogicFaceUri) setLogicFaceUri(logicFaceUri string) {
|
||||
l.CommonString.SetValue(logicFaceUri)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (l AdjLsaLogicFaceUri) setLogicFaceUri(logicFaceUri string) {
|
||||
// @return int
|
||||
// @return error
|
||||
//
|
||||
func (l AdjLsaLogicFaceUri) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
func (l *AdjLsaLogicFaceUri) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
l.CommonString.SetTlvType(extensions.TlvMlsrAdjLsaLogicFaceUri)
|
||||
return l.CommonString.WireEncode(encoder)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (l AdjLsaLogicFaceUri) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
// @param block
|
||||
// @return error
|
||||
//
|
||||
func (l AdjLsaLogicFaceUri) WireDecode(block *encoding.Block) error {
|
||||
func (l *AdjLsaLogicFaceUri) WireDecode(block *encoding.Block) error {
|
||||
// 检查type是否正确
|
||||
if err := encoding.ExpectType(block.GetType(),extensions.TlvMlsrAdjLsaLogicFaceUri); err!=nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Package lsa
|
||||
// @Author: Wang Feng
|
||||
// @Description:
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/3/17 16:46
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsa
|
||||
|
||||
import "minlib/encoding"
|
||||
|
||||
type HyperbolicRadius float64 // 双曲半径
|
||||
type HyperbolicAngles []float64 // 双曲角度
|
||||
|
||||
//
|
||||
// CoordinateLsa
|
||||
// @Description: 双曲坐标LSA。
|
||||
// 当前版本的mlsr暂不做详细实现,留置等mir同时支持双曲路由时,再进行方法填充。
|
||||
//
|
||||
type CoordinateLsa struct {
|
||||
HyperbolicRadius
|
||||
HyperbolicAngles
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) IsEqualContent(lsa *CoordinateLsa) bool {
|
||||
panic("")
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) ToString() string {
|
||||
panic("")
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
panic("")
|
||||
}
|
||||
|
||||
func (c *CoordinateLsa) WireDecode(block *encoding.Block) error {
|
||||
panic("")
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package lsa
|
||||
// @Author: Wang Feng
|
||||
// @Description: 与nlsr中的name-lsa类似,用以表示源路由器可到达的名称前缀。
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/3/9 22:13
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsa
|
||||
|
||||
type NameLsa struct {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Package lsa
|
||||
// @Author: Wang Feng
|
||||
// @Description:
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/3/17 16:29
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsa
|
||||
|
||||
import "minlib/component"
|
||||
|
||||
// todo:疑问1,为啥是字符串?字符串是路由器的名称前缀吗?
|
||||
// todo:疑问2,用NameLsa去告知其他节点的这些名称前缀,是本地的,还是本地及其邻居的,还是全网的?
|
||||
type Sources []*NameLsaNamePrefixSource // 表示一个名称前缀的来源。由于其可能有多个来源,这里是列表形式。
|
||||
|
||||
type NameLsaNamePrefixInfo struct {
|
||||
NamePrefix *component.Identifier
|
||||
Sources
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
// @Author: Wang Feng
|
||||
// @Description:
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/3/9 22:13
|
||||
// @Date: 2022/3/17 16:28
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsa
|
||||
|
||||
type NameLsaNamePrefixList struct {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Package lsa
|
||||
// @Author: Wang Feng
|
||||
// @Description:
|
||||
// @Version: 0.1.0
|
||||
// @Date: 2022/3/17 17:15
|
||||
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
//
|
||||
|
||||
package lsa
|
||||
|
||||
import (
|
||||
"minlib/component"
|
||||
"minlib/encoding"
|
||||
"mlsr/extensions"
|
||||
)
|
||||
|
||||
//
|
||||
// NameLsaNamePrefixSource
|
||||
// @Description: 名称前缀的source。
|
||||
//
|
||||
type NameLsaNamePrefixSource struct {
|
||||
component.CommonString
|
||||
}
|
||||
|
||||
//
|
||||
// NamePrefixSource
|
||||
// @Description: 获取source
|
||||
// @receiver s
|
||||
// @return string
|
||||
//
|
||||
func (s *NameLsaNamePrefixSource) NamePrefixSource() string {
|
||||
return s.CommonString.Value()
|
||||
}
|
||||
|
||||
//
|
||||
// SetNamePrefixSource
|
||||
// @Description: 设置source
|
||||
// @receiver s
|
||||
// @param source
|
||||
//
|
||||
func (s *NameLsaNamePrefixSource) SetNamePrefixSource(source string) {
|
||||
s.CommonString.SetValue(source)
|
||||
}
|
||||
|
||||
//
|
||||
// WireEncode
|
||||
// @Description: 线速编码
|
||||
// @receiver s
|
||||
// @param encoder
|
||||
// @return int
|
||||
// @return error
|
||||
//
|
||||
func (s *NameLsaNamePrefixSource) WireEncode(encoder *encoding.Encoder) (int,error) {
|
||||
s.CommonString.SetTlvType(extensions.TlvMlsrNameLsaNamePrefixSource)
|
||||
return s.CommonString.WireEncode(encoder)
|
||||
}
|
||||
|
||||
//
|
||||
// WireDecode
|
||||
// @Description: 线速解码
|
||||
// @receiver s
|
||||
// @param block
|
||||
// @return error
|
||||
//
|
||||
func (s *NameLsaNamePrefixSource) WireDecode(block *encoding.Block) error {
|
||||
// 检查type是否正确
|
||||
if err := encoding.ExpectType(block.GetType(),extensions.TlvMlsrNameLsaNamePrefixSource); err!=nil {
|
||||
return err
|
||||
}
|
||||
return s.CommonString.WireDecode(block)
|
||||
}
|
||||
Reference in new issue
Block a user