mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-03 15:56:13 +08:00
对MlscConfig增加ToString,并测试通过MlsrConfigParameters中关于标识和时间的参数
This commit is contained in:
+117
-31
@@ -12,6 +12,7 @@ import (
|
||||
"encoding/json"
|
||||
"gopkg.in/ini.v1"
|
||||
common2 "minlib/common"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const DefaultConfFileName = "mlsrConf.ini"
|
||||
@@ -36,28 +37,105 @@ type MlsrConfig struct {
|
||||
neighbors []NeighborConfig // NeighborsConfig中的信息
|
||||
}
|
||||
|
||||
//
|
||||
// ToString
|
||||
// @Description:
|
||||
// @receiver c
|
||||
//
|
||||
func (c *MlsrConfig) ToString() string {
|
||||
var str string
|
||||
str += "----------------------- MlsrConfig -------------------------\n"
|
||||
str += "Config File Path: " + c.mlsrConfigPath + "\n"
|
||||
str += "----------------- 1. GeneralConfig -------------------------\n"
|
||||
bytes, err := json.Marshal(c.GeneralConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 2. LogConfig -----------------------------\n"
|
||||
bytes, err = json.Marshal(c.LogConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 3. NeighborsConfig -----------------------\n"
|
||||
bytes, err = json.Marshal(c.NeighborsConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 4. HyperbolicConfig ----------------------\n"
|
||||
bytes, err = json.Marshal(c.HyperbolicConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 5. FibConfig -----------------------------\n"
|
||||
bytes, err = json.Marshal(c.FibConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 6. AdvertisingConfig ---------------------\n"
|
||||
bytes, err = json.Marshal(c.AdvertisingConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "----------------- 7. SecurityConfig ------------------------\n"
|
||||
bytes, err = json.Marshal(c.SecurityConfig)
|
||||
if err == nil {
|
||||
str += string(bytes) + "\n"
|
||||
}
|
||||
str += "\n"
|
||||
return str
|
||||
}
|
||||
|
||||
func (c *MlsrConfig) ParametersToString() string {
|
||||
var str string
|
||||
str += "----------------------- MlsrConfigParameters -------------------------\n"
|
||||
str += "----------------------- 1. 标识符 -------------------------------------\n"
|
||||
str += "路由器定位符:" + c.MlsrConfigParameters.m_routerName.ToUri() + "\n"
|
||||
str += "网域定位符:" + c.MlsrConfigParameters.m_siteName.ToUri() + "\n"
|
||||
str += "网络定位符:" + c.MlsrConfigParameters.m_network.ToUri() + "\n"
|
||||
str += "路由器前缀:" + c.MlsrConfigParameters.m_routerPrefix.ToUri() + "\n"
|
||||
str += "同步用户前缀:" + c.MlsrConfigParameters.m_syncUserPrefix.ToUri() + "\n"
|
||||
str += "同步前缀:" + c.MlsrConfigParameters.m_syncPrefix.ToUri() + "\n"
|
||||
str += "LSA前缀:" + c.MlsrConfigParameters.m_lsaPrefix.ToUri() + "\n"
|
||||
str += "----------------------- 2. 时间 ---------------------------------------\n"
|
||||
str += "LSA刷新时间:" + strconv.Itoa(int(c.MlsrConfigParameters.m_lsaRefreshTime.Seconds())) + " " +
|
||||
"秒 = " + strconv.Itoa(int(c.MlsrConfigParameters.m_lsaRefreshTime.Seconds())/60) + "分钟\n"
|
||||
str += "LSA兴趣包生命周期:" + strconv.Itoa(int(c.MlsrConfigParameters.m_lsaInterestLifetime.Seconds())) + " 秒" + "\n"
|
||||
str += "路由器死亡间隔:" + strconv.Itoa(int(c.MlsrConfigParameters.m_routerDeadInterval.Seconds())) + " " +
|
||||
"秒 = " + strconv.Itoa(int(c.MlsrConfigParameters.m_routerDeadInterval.Seconds())/60) + "分钟\n"
|
||||
str += "同步兴趣包生命周期:" + strconv.Itoa(int(c.MlsrConfigParameters.m_syncInterestLifetime.Seconds())) + " 秒" + "\n"
|
||||
|
||||
str += "hello超时时间:" + strconv.Itoa(int(c.MlsrConfigParameters.m_helloTimeout.Seconds())) + " 秒" + "\n"
|
||||
str += "hello发送间隔:" + strconv.Itoa(int(c.MlsrConfigParameters.m_helloInterval.Seconds())) + " 秒" + "\n"
|
||||
str += "邻接LSA构建间隔:" + strconv.Itoa(int(c.MlsrConfigParameters.m_adjLsaBuildInterval.Seconds())) + " 秒" + "\n"
|
||||
str += "LogicFace数据集请求间隔:" + strconv.Itoa(int(c.MlsrConfigParameters.m_faceDatasetFetchInterval.Seconds())) + " " +
|
||||
"秒 = " + strconv.Itoa(int(c.MlsrConfigParameters.m_faceDatasetFetchInterval.Seconds())/60) + "分钟\n"
|
||||
str += "路由计算间隔:" + strconv.Itoa(int(c.MlsrConfigParameters.m_RoutingCalcInterval.Seconds())) + " 秒" + "\n"
|
||||
str += "\n"
|
||||
return str
|
||||
}
|
||||
|
||||
//
|
||||
// GeneralConfig
|
||||
// @Description: 最基础配置信息:LSA、同步协议
|
||||
// @Description: 一、最基础配置信息:LSA、同步协议
|
||||
//
|
||||
type GeneralConfig struct {
|
||||
Network string `ini:"Network"` // 所属网络
|
||||
Site string `ini:"Site"` // 所属站点
|
||||
Router string `ini:"Router"` // 所属路由器
|
||||
|
||||
LsaRefreshTime uint32 `ini:"LsaRefreshTime"` // LSA刷新时间
|
||||
LsaRefreshTime uint32 `ini:"LsaRefreshTime"` // LSA刷新时间【单位:毫秒】
|
||||
|
||||
RouterDeadInterval uint32 `ini:"RouterDeadInterval"` // 路由器判断死亡的时间间隔(必须大于LSA刷新时间)
|
||||
RouterDeadInterval uint32 `ini:"RouterDeadInterval"` // 路由器判断死亡的时间间隔(必须大于LSA刷新时间)【单位:毫秒】
|
||||
|
||||
LsaInterestLifetime int `ini:"LsaInterestLifetime"` // LSA兴趣包生存周期。当使用推式包时,此值无效【单位:毫秒】
|
||||
|
||||
SyncProtocol string `ini:"SyncProtocol"` // 同步协议
|
||||
SyncInterestLifetime uint32 `ini:"SyncInterestLifetime"` // 同步协议兴趣包生命周期
|
||||
SyncInterestLifetime uint32 `ini:"SyncInterestLifetime"` // 同步协议兴趣包生命周期【单位:毫秒】
|
||||
}
|
||||
|
||||
//
|
||||
// LogConfig
|
||||
// @Description: 日志模块
|
||||
// @Description: 二、日志模块
|
||||
//
|
||||
type LogConfig struct {
|
||||
LogLevel string `ini:"LogLevel"` // 日志等级
|
||||
@@ -68,14 +146,14 @@ type LogConfig struct {
|
||||
|
||||
//
|
||||
// NeighborsConfig
|
||||
// @Description: 邻居路由器相关配置
|
||||
// @Description: 三、邻居路由器相关配置
|
||||
//
|
||||
type NeighborsConfig struct {
|
||||
HelloRetries int `ini:"HelloRetries"` // hello协议探测最大次数
|
||||
HelloTimeout uint32 `ini:"HelloTimeout"` // hello协议中的超时时间
|
||||
HelloInterval uint32 `ini:"HelloInterval"` // 两个hello包之间的间隔时间
|
||||
HelloRetries int `ini:"HelloRetries"` // hello协议探测最大次数【单位:毫秒】
|
||||
HelloTimeout uint32 `ini:"HelloTimeout"` // hello协议中的超时时间【单位:毫秒】
|
||||
HelloInterval uint32 `ini:"HelloInterval"` // 两个hello包之间的间隔时间【单位:毫秒】
|
||||
|
||||
AdjLsaBuildInterval uint32 `ini:"AdjLsaBuildInterval"` // 邻接LSA构建的时间间隔
|
||||
AdjLsaBuildInterval uint32 `ini:"AdjLsaBuildInterval"` // 邻接LSA构建的时间间隔【单位:毫秒】
|
||||
LogicFaceDatasetFetchRetries uint32 `ini:"LogicFaceDatasetFetchRetries"` // 获取FaceStatus数据集的重试次数
|
||||
LogicFaceDatasetFetchInterval uint32 `ini:"LogicFaceDatasetFetchInterval"` // FaceStatus数据集获取尝试之间的间隔【单位:毫秒】
|
||||
|
||||
@@ -124,24 +202,32 @@ func parseJsonStringToNeighbors(jsonString NeighborsJsonString) ([]NeighborConfi
|
||||
|
||||
//
|
||||
// HyperbolicConfig
|
||||
// @Description: 预留双曲坐标的接口
|
||||
// @Description: 四、预留双曲坐标的配置
|
||||
//
|
||||
type HyperbolicConfig struct {
|
||||
}
|
||||
|
||||
//
|
||||
// FibConfig
|
||||
// @Description: 路由计算相关配置
|
||||
// @Description: 五、路由计算与FIB更新相关配置
|
||||
//
|
||||
type FibConfig struct {
|
||||
MaxLogicFacesPerPrefix int `ini:"MaxLogicFacesPerPrefix"` // 每个前缀对应的下一跳face列表的最大数目
|
||||
RoutingCalcInterval uint32 `ini:"RoutingCalcInterval"` // 两次路由计算的时间间隔
|
||||
RoutingCalcInterval uint32 `ini:"RoutingCalcInterval"` // 两次路由计算的时间间隔【单位:毫秒】
|
||||
}
|
||||
|
||||
//
|
||||
// AdvertisingConfig
|
||||
// @Description: 六、需要通告给其它路由器的前缀
|
||||
//
|
||||
type AdvertisingConfig struct {
|
||||
Prefixs []string `ini:"Prefixs"` // 需要广告给其他路由器的本机前缀
|
||||
}
|
||||
|
||||
//
|
||||
// SecurityConfig
|
||||
// @Description: 七、预留安全相关的配置
|
||||
//
|
||||
type SecurityConfig struct {
|
||||
}
|
||||
|
||||
@@ -151,29 +237,29 @@ type SecurityConfig struct {
|
||||
// @receiver c
|
||||
//
|
||||
func (c *MlsrConfig) Init() {
|
||||
// 通用配置参数
|
||||
// 1. 通用配置参数
|
||||
c.GeneralConfig.Network = "/min"
|
||||
c.GeneralConfig.Site = "/pkusz"
|
||||
c.GeneralConfig.Router = "/routerA"
|
||||
c.GeneralConfig.LsaRefreshTime = 1800 // 240-7200
|
||||
c.GeneralConfig.RouterDeadInterval = 2 * c.GeneralConfig.LsaRefreshTime
|
||||
c.GeneralConfig.LsaInterestLifetime = 4 // 4-60
|
||||
c.GeneralConfig.LsaRefreshTime = 30 * 60 * 1000 // 60*4-60*120,范围是4分钟-2小时。默认半小时
|
||||
c.GeneralConfig.RouterDeadInterval = 2 * c.GeneralConfig.LsaRefreshTime // 默认一小时
|
||||
c.GeneralConfig.LsaInterestLifetime = 4 * 1000 // 4-60,范围是4秒钟到1分钟。默认4秒钟
|
||||
c.GeneralConfig.SyncProtocol = "min-sync"
|
||||
c.GeneralConfig.SyncInterestLifetime = 60000 // 1000-120000
|
||||
c.GeneralConfig.SyncInterestLifetime = 60 * 1000 // 1000-120*1000,范围是1秒到2分钟。默认1分钟
|
||||
|
||||
// Log
|
||||
// 2. Log
|
||||
c.LogConfig.LogLevel = "INFO"
|
||||
c.LogConfig.ReportCaller = true
|
||||
c.LogConfig.LogFormat = "text"
|
||||
c.LogConfig.LogFilePath = ""
|
||||
|
||||
// 邻居路由器配置参数
|
||||
c.NeighborsConfig.HelloRetries = 3 // 1-15
|
||||
c.NeighborsConfig.HelloTimeout = 1 // 1-15
|
||||
c.NeighborsConfig.HelloInterval = 60 // 30-90
|
||||
c.NeighborsConfig.AdjLsaBuildInterval = 10 // 5-30
|
||||
c.NeighborsConfig.LogicFaceDatasetFetchRetries = 3 // 1-10
|
||||
c.NeighborsConfig.LogicFaceDatasetFetchInterval = 3600 // 1800-5400
|
||||
// 3. 邻居路由器配置参数
|
||||
c.NeighborsConfig.HelloRetries = 3 // 1-15,次数
|
||||
c.NeighborsConfig.HelloTimeout = 1 * 1000 // 1-15,超时时间,范围1秒-15秒。默认1秒钟
|
||||
c.NeighborsConfig.HelloInterval = 60 * 1000 // 30-90,间隔时间,范围30秒到1分钟。默认1分钟
|
||||
c.NeighborsConfig.AdjLsaBuildInterval = 10 * 1000 // 5-30,构建间隔,范围5秒到30秒。默认10秒钟
|
||||
c.NeighborsConfig.LogicFaceDatasetFetchRetries = 3 // 1-10,次数
|
||||
c.NeighborsConfig.LogicFaceDatasetFetchInterval = 60 * 60 * 1000 // 30*60-90*60,半小时到一个半小时。默认1小时
|
||||
// 将邻居链路信息存储到配置文件中 todo:用于测试
|
||||
neighborConfig1 := NeighborConfig{
|
||||
NeighborName: "/routerB",
|
||||
@@ -190,11 +276,11 @@ func (c *MlsrConfig) Init() {
|
||||
//c.NeighborsConfig.NeighborsInfo=neighborsJsonString
|
||||
c.neighbors = []NeighborConfig{neighborConfig1, neighborConfig2}
|
||||
|
||||
// 路由计算配置参数
|
||||
c.FibConfig.MaxLogicFacesPerPrefix = 0 // 0-60 todo:为啥默认是0呢
|
||||
c.FibConfig.RoutingCalcInterval = 15 // 0-15
|
||||
// 5. FIB更新配置参数
|
||||
c.FibConfig.MaxLogicFacesPerPrefix = 0 // 0-60,个数,最多有多少个下一跳。置0表示保留所有计算出的下一跳
|
||||
c.FibConfig.RoutingCalcInterval = 15 * 1000 // 0-15,路由计算间隔。默认15秒计算一次
|
||||
|
||||
// 广播本地前缀配置参数
|
||||
// 6. 广播本地前缀配置参数
|
||||
c.AdvertisingConfig.Prefixs = []string{"/videos", "/files", "voices"} // todo:用于测试
|
||||
}
|
||||
|
||||
@@ -233,7 +319,7 @@ func ParseConfig(configPath string) (*MlsrConfig, error) {
|
||||
mlsrConfig.mlsrConfigPath = configPath
|
||||
// 初始化配置,给所有的配置项设置默认值
|
||||
mlsrConfig.Init()
|
||||
// 加载配置文件中的配置
|
||||
// 加载配置文件中的配置:如果有,则理应覆盖Init中设置的默认配置
|
||||
if err = cfg.MapTo(&mlsrConfig); err != nil {
|
||||
common2.LogFatal("ParseConfig error, mapTo error, path is ", configPath, err.Error())
|
||||
return nil, err
|
||||
|
||||
+170
-29
@@ -32,14 +32,20 @@ type MlsrConfigParameters struct {
|
||||
m_syncPrefix *component.Identifier
|
||||
m_lsaPrefix *component.Identifier
|
||||
|
||||
m_lsaRefreshTime time.Duration
|
||||
m_adjLsaBuildInterval time.Duration
|
||||
|
||||
// 路由器死亡时间(经过了该时间,NameLsa将触发超时)
|
||||
m_routerDeadInterval time.Duration
|
||||
// 时间:通用配置
|
||||
m_lsaRefreshTime time.Duration
|
||||
m_lsaInterestLifetime time.Duration
|
||||
m_routerDeadInterval time.Duration // 路由器死亡时间(经过了该时间,NameLsa将触发超时)
|
||||
m_syncInterestLifetime time.Duration
|
||||
|
||||
// 时间:邻居路由器
|
||||
m_helloTimeout time.Duration
|
||||
m_helloInterval time.Duration
|
||||
m_adjLsaBuildInterval time.Duration
|
||||
m_faceDatasetFetchInterval time.Duration
|
||||
m_lsaInterestLifetime time.Duration
|
||||
|
||||
// 时间:FIB更新
|
||||
m_RoutingCalcInterval time.Duration
|
||||
}
|
||||
|
||||
// MlsrConfig初始化
|
||||
@@ -49,6 +55,8 @@ func (mcp *MlsrConfigParameters) Init(config *MlsrConfig) {
|
||||
_ = mcp.build3Prefix()
|
||||
_ = mcp.buildSyncAndLsaPrefix()
|
||||
_ = mcp.buildRouterAndSyncUserPrefix()
|
||||
// 构建时间间隔
|
||||
mcp.genDurations()
|
||||
}
|
||||
|
||||
//
|
||||
@@ -61,19 +69,32 @@ func (mcp *MlsrConfigParameters) setMetaData(config *MlsrConfig) {
|
||||
mcp.mlsrconf = config
|
||||
}
|
||||
|
||||
//
|
||||
// genDurations
|
||||
// @Description: 生成时间相关配置信息
|
||||
// @receiver mcp
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) genDurations() {
|
||||
mcp.m_lsaRefreshTime =
|
||||
time.Duration(mcp.mlsrconf.LsaRefreshTime) * time.Millisecond
|
||||
mcp.m_adjLsaBuildInterval =
|
||||
time.Duration(mcp.mlsrconf.AdjLsaBuildInterval) * time.Millisecond
|
||||
|
||||
mcp.m_routerDeadInterval =
|
||||
time.Duration(mcp.mlsrconf.RouterDeadInterval) * time.Millisecond
|
||||
|
||||
mcp.m_faceDatasetFetchInterval =
|
||||
time.Duration(mcp.mlsrconf.LogicFaceDatasetFetchInterval) * time.Millisecond
|
||||
mcp.m_lsaInterestLifetime =
|
||||
time.Duration(mcp.mlsrconf.LsaInterestLifetime) * time.Millisecond
|
||||
mcp.m_routerDeadInterval =
|
||||
time.Duration(mcp.mlsrconf.RouterDeadInterval) * time.Millisecond
|
||||
mcp.m_syncInterestLifetime =
|
||||
time.Duration(mcp.mlsrconf.SyncInterestLifetime) * time.Millisecond
|
||||
|
||||
mcp.m_helloTimeout =
|
||||
time.Duration(mcp.mlsrconf.HelloTimeout) * time.Millisecond
|
||||
mcp.m_helloInterval =
|
||||
time.Duration(mcp.mlsrconf.HelloInterval) * time.Millisecond
|
||||
mcp.m_adjLsaBuildInterval =
|
||||
time.Duration(mcp.mlsrconf.AdjLsaBuildInterval) * time.Millisecond
|
||||
mcp.m_faceDatasetFetchInterval =
|
||||
time.Duration(mcp.mlsrconf.LogicFaceDatasetFetchInterval) * time.Millisecond
|
||||
|
||||
mcp.m_RoutingCalcInterval =
|
||||
time.Duration(mcp.mlsrconf.RoutingCalcInterval) * time.Millisecond
|
||||
}
|
||||
|
||||
//
|
||||
@@ -137,30 +158,72 @@ func (mcp *MlsrConfigParameters) buildRouterAndSyncUserPrefix() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// GetNetwork
|
||||
// @Description: 网络定位符
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetNetwork() *component.Identifier {
|
||||
return mcp.m_network
|
||||
}
|
||||
|
||||
//
|
||||
// GetSiteName
|
||||
// @Description:网域定位符
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetSiteName() *component.Identifier {
|
||||
return mcp.m_siteName
|
||||
}
|
||||
|
||||
//
|
||||
// GetRouterName
|
||||
// @Description: 路由器定位符
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetRouterName() *component.Identifier {
|
||||
return mcp.m_routerName
|
||||
}
|
||||
|
||||
//
|
||||
// GetRouterPrefix
|
||||
// @Description: 路由器前缀
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetRouterPrefix() *component.Identifier {
|
||||
return mcp.m_routerPrefix
|
||||
}
|
||||
|
||||
//
|
||||
// GetSyncUserPrefix
|
||||
// @Description: 同步用户前缀
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetSyncUserPrefix() *component.Identifier {
|
||||
return mcp.m_syncUserPrefix
|
||||
}
|
||||
|
||||
//
|
||||
// GetSyncPrefix
|
||||
// @Description: 同步前缀
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetSyncPrefix() *component.Identifier {
|
||||
return mcp.m_syncPrefix
|
||||
}
|
||||
|
||||
//
|
||||
// GetLsaPrefix
|
||||
// @Description: LSA前缀
|
||||
// @receiver mcp
|
||||
// @return *component.Identifier
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetLsaPrefix() *component.Identifier {
|
||||
return mcp.m_lsaPrefix
|
||||
}
|
||||
@@ -169,38 +232,120 @@ func (mcp *MlsrConfigParameters) GetSyncProtocol() {
|
||||
// todo
|
||||
}
|
||||
|
||||
//
|
||||
// GetLsaRefreshTime
|
||||
// @Description: LSA刷新时间
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetLsaRefreshTime() time.Duration {
|
||||
return mcp.m_lsaRefreshTime
|
||||
}
|
||||
|
||||
//
|
||||
// GetLsaInterestLifetime
|
||||
// @Description: LSA兴趣包生命周期
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetLsaInterestLifetime() time.Duration {
|
||||
return mcp.m_lsaInterestLifetime
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetAdjLsaBuildInterval() time.Duration {
|
||||
return mcp.m_adjLsaBuildInterval
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetRoutingCalcInterval() uint32 {
|
||||
return mcp.mlsrconf.RoutingCalcInterval
|
||||
}
|
||||
|
||||
//
|
||||
// GetRouterDeadInterval
|
||||
// @Description: 路由器死亡间隔
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetRouterDeadInterval() time.Duration {
|
||||
return mcp.m_routerDeadInterval
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetFaceDatasetFetchTries() uint32 {
|
||||
return mcp.mlsrconf.LogicFaceDatasetFetchRetries
|
||||
//
|
||||
// GetSyncInterestLifetime
|
||||
// @Description: 同步兴趣包生命周期
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetSyncInterestLifetime() time.Duration {
|
||||
return mcp.m_syncInterestLifetime
|
||||
}
|
||||
|
||||
//
|
||||
// GetAdjLsaBuildInterval
|
||||
// @Description: 邻接LSA构建间隔
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetAdjLsaBuildInterval() time.Duration {
|
||||
return mcp.m_adjLsaBuildInterval
|
||||
}
|
||||
|
||||
//
|
||||
// GetFaceDatasetFetchInterval
|
||||
// @Description: LogicFace数据集请求间隔
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetFaceDatasetFetchInterval() time.Duration {
|
||||
return mcp.m_faceDatasetFetchInterval
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetInterestRetryNumber() int {
|
||||
//
|
||||
// GetRoutingCalcInterval
|
||||
// @Description: 路由计算间隔
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetRoutingCalcInterval() time.Duration {
|
||||
return mcp.m_RoutingCalcInterval
|
||||
}
|
||||
|
||||
//
|
||||
// GetFaceDatasetFetchTries
|
||||
// @Description: LogicFace数据集请求次数
|
||||
// @receiver mcp
|
||||
// @return int
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetFaceDatasetFetchTries() uint32 {
|
||||
return mcp.mlsrconf.LogicFaceDatasetFetchRetries
|
||||
}
|
||||
|
||||
//
|
||||
// GetHelloRetries
|
||||
// @Description: hello兴趣包重传次数
|
||||
// @receiver mcp
|
||||
// @return int
|
||||
//
|
||||
func (mcp MlsrConfigParameters) GetHelloRetries() int {
|
||||
return mcp.mlsrconf.HelloRetries
|
||||
}
|
||||
|
||||
//
|
||||
// GetHelloTimeout
|
||||
// @Description: Hello超时时间
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetHelloTimeout() time.Duration {
|
||||
return mcp.m_helloTimeout
|
||||
}
|
||||
|
||||
//
|
||||
// GetHelloInterval
|
||||
// @Description: Hello重传间隔
|
||||
// @receiver mcp
|
||||
// @return time.Duration
|
||||
//
|
||||
func (mcp *MlsrConfigParameters) GetHelloInterval() time.Duration {
|
||||
return mcp.m_helloInterval
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetInterestRetryNumber() {
|
||||
// todo
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetInterestResendTime() {
|
||||
// todo
|
||||
}
|
||||
@@ -213,10 +358,6 @@ func (mcp *MlsrConfigParameters) GetMaxFacesPerPrefix() int {
|
||||
return mcp.mlsrconf.MaxLogicFacesPerPrefix
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetSyncInterestLifetime() uint32 {
|
||||
return mcp.mlsrconf.SyncInterestLifetime
|
||||
}
|
||||
|
||||
func (mcp *MlsrConfigParameters) GetAdjacencyList() *lsa.AdjLsaAdjacenctList {
|
||||
// todo
|
||||
return nil
|
||||
|
||||
@@ -25,6 +25,8 @@ func getCurrentDirectory() string {
|
||||
return dir
|
||||
}
|
||||
|
||||
const testConfigPath = "D:\\" + DefaultConfFileName
|
||||
|
||||
//
|
||||
// TestCreatConfigFile
|
||||
// @Description: 测试生成mlsrConfig文件
|
||||
@@ -42,6 +44,25 @@ func TestCreatConfigFile(t *testing.T) {
|
||||
_ = mlsrConfig.Save()
|
||||
}
|
||||
|
||||
//
|
||||
// TestMlsrConfigParameters
|
||||
// @Description: 测试配置项所有参数
|
||||
// @param t
|
||||
//
|
||||
func TestMlsrConfigParameters(t *testing.T) {
|
||||
// 1、从指定目录解析配置文件
|
||||
mlsrConfig, err := ParseConfig(testConfigPath)
|
||||
if err != nil {
|
||||
fmt.Println("配置文件解析错误")
|
||||
}
|
||||
// 2、打印配置中的普通字符串信息
|
||||
fmt.Println(mlsrConfig.ToString())
|
||||
// 3、打印配置中的特殊参数信息
|
||||
fmt.Println(mlsrConfig.ParametersToString())
|
||||
fmt.Println("!!!", mlsrConfig.MlsrConfigParameters.GetSyncUserPrefix().ToUri()+"00000")
|
||||
fmt.Println("end")
|
||||
}
|
||||
|
||||
//
|
||||
// TestMlsrConfig_ParseConfigAndSave
|
||||
// @Description: 测试配置文件解析和存储
|
||||
|
||||
Reference in New Issue
Block a user