mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-16 16:28:01 +08:00
241 lines
5.7 KiB
Go
241 lines
5.7 KiB
Go
// Package lsdb
|
|
// @Author: Wang Feng
|
|
// @Description:
|
|
// @Version: 0.1.0
|
|
// @Date: 2022/3/24 11:41
|
|
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
//
|
|
|
|
package lsdb
|
|
|
|
import (
|
|
"bytes"
|
|
"minlib/component"
|
|
"minlib/packet"
|
|
"mlsr/communication"
|
|
"mlsr/lsa"
|
|
"mlsr/lsdb/LsaContainer"
|
|
"time"
|
|
)
|
|
|
|
// Lsdb更新状态
|
|
const (
|
|
INSTALLED = 0 // 已安装
|
|
UPDATED = 1 // 已更新
|
|
REMOVED = -1 // 已移除
|
|
)
|
|
|
|
type Lsdb struct {
|
|
// 配置参数
|
|
|
|
// 同步协议配置项
|
|
sync *communication.SyncLogicHandler
|
|
|
|
// LSA容器
|
|
lsaContainer *LsaContainer.LsaContainer
|
|
|
|
lsaRefreshTime *time.Duration // lsa刷新时间
|
|
adjLsaBuildInterval *time.Duration // 邻接LSA构建间隔
|
|
ThisRouterPrefix *component.Identifier // 当前路由器的标识
|
|
|
|
// 任务调度器
|
|
scheduler *Scheduler
|
|
|
|
// 将LSA的名称从sync映射到其已知的最高序列号;
|
|
// 用于阻止MLSR尝试获取过时的LSA
|
|
highestSeqNo map[*component.Identifier]uint64
|
|
|
|
// 不同类型lsa的序列号管理器
|
|
sequencingManager *SequencingManager
|
|
|
|
isBuildAdjLsaScheduled bool // 是否安排构建邻接LSA
|
|
adjBuildCount uint64 // 邻接LSA的构建的统计数目
|
|
}
|
|
|
|
//
|
|
// DoesLsaExist
|
|
// @Description: 返回LSDB是否存在某些LSA的查询结果
|
|
// @receiver l
|
|
// @param routerIdentifier
|
|
// @param lsaType
|
|
// @return bool
|
|
//
|
|
func (l *Lsdb) DoesLsaExist(routerIdentifier *component.Identifier, lsaType int) bool {
|
|
panic("implement me")
|
|
}
|
|
|
|
//
|
|
// BuildAndInstallOwnNameLsa
|
|
// @Description: 构建一个属于本路由器的名称LSA,并安装它到LSDB。
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) BuildAndInstallOwnNameLsa() {
|
|
}
|
|
|
|
//
|
|
// BuildAndInstallOwnCoordinateLsa
|
|
// @Description: 构建一个属于本路由器的坐标LSA,并安装它到LSDB
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) BuildAndInstallOwnCoordinateLsa() {
|
|
// todo
|
|
}
|
|
|
|
//
|
|
// ScheduleAdjLsaBuild
|
|
// @Description: 安排LSA的构建
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) ScheduleAdjLsaBuild() {
|
|
}
|
|
|
|
//
|
|
// ProcessInterest
|
|
// @Description: 处理兴趣包。类似NDN的拉式传输。
|
|
// 在NLSR的设计中,由于对兴趣包进行了进一步的分段,因此有以下两种兴趣包:
|
|
//* 1) 需要从segment fetcher中查找的兴趣包:
|
|
//* /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>
|
|
//* 2) 已经包含segment number的兴趣包:
|
|
//* /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>/<version>/<segmentNo>
|
|
// @receiver l
|
|
// @param interest
|
|
//
|
|
func (l *Lsdb) ProcessInterest(interest *packet.Interest) {
|
|
}
|
|
|
|
func (l *Lsdb) ProcessGPPkt(pkt *packet.GPPkt) {
|
|
}
|
|
|
|
//
|
|
// GetIsBuildAdjLsaScheduled
|
|
// @Description: 判断是否已经安排了邻接LSA的构建
|
|
// @receiver l
|
|
// @return bool
|
|
//
|
|
func (l *Lsdb) GetIsBuildAdjLsaScheduled() bool {
|
|
return l.isBuildAdjLsaScheduled
|
|
}
|
|
|
|
//
|
|
// GetSync
|
|
// @Description: 获取Sync协议逻辑处理器
|
|
// @receiver l
|
|
// @return communication.SyncLogicHandler
|
|
//
|
|
func (l *Lsdb) GetSync() *communication.SyncLogicHandler {
|
|
return l.sync
|
|
}
|
|
|
|
//
|
|
// FindLsa
|
|
// @Description: 根据LSA类型及所属路由器,获取LSA
|
|
// @receiver l*
|
|
// @param routerIdentifier
|
|
// @param lsaType
|
|
// @return lsa.ILsa
|
|
//
|
|
func (l *Lsdb) FindLsa(routerIdentifier *component.Identifier,
|
|
lsaType lsa.LsaType) lsa.ILsa {
|
|
// todo
|
|
return &lsa.NameLsa{}
|
|
}
|
|
|
|
//
|
|
// IsLsaNew
|
|
// @Description: 返回来自某个路由器的seq是否表示新的LSA。
|
|
// @receiver l
|
|
// @param routerIdentifier
|
|
// @param lsaType
|
|
// @param seqNo
|
|
// @return bool
|
|
//
|
|
func (l *Lsdb) IsLsaNew(routerIdentifier *component.Identifier,
|
|
lsaType lsa.LsaType, seqNo uint64) bool {
|
|
lsa := l.FindLsa(routerIdentifier, lsaType)
|
|
if lsa.GetSeqNo() >= seqNo {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (l *Lsdb) InstallLsa(lsa lsa.ILsa) {
|
|
}
|
|
|
|
func (l *Lsdb) RemoveLsa(routerIdentifier *component.Identifier,
|
|
lsaType lsa.LsaType) {
|
|
}
|
|
|
|
func (l *Lsdb) RemoveLsaByContainerIndex(index int) {
|
|
}
|
|
|
|
//
|
|
// BuildAdjLsa
|
|
// @Description: 构建一个邻接LSA
|
|
// 只有当路由器的所有邻居状态是已知的时,才可以构建它的邻接LSA。
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) BuildAdjLsa() {
|
|
}
|
|
|
|
//
|
|
// BuildAndInstallOwnAdjLsa
|
|
// @Description: 为当前路由器构建并安装一个邻接LSA
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) BuildAndInstallOwnAdjLsa() {
|
|
}
|
|
|
|
//
|
|
// ScheduleLsaExpiration
|
|
// @Description: 在调度器中安排一个刷新或过期事件
|
|
// @receiver l
|
|
//
|
|
func (l *Lsdb) ScheduleLsaExpiration(lsa lsa.ILsa, duration *time.Duration) {
|
|
|
|
}
|
|
|
|
func (l *Lsdb) ExpireOrRefreshLsa(lsa lsa.ILsa) {
|
|
}
|
|
|
|
func (l *Lsdb) ProcessInterestForLsa(interest *packet.Interest,
|
|
originRouterIdentifier *component.Identifier, lsaType lsa.LsaType, seqNo uint64) {
|
|
}
|
|
|
|
func (l *Lsdb) ExpressInterest(interestName *component.Identifier,
|
|
timeOut uint32, deadline *time.Time) {
|
|
}
|
|
|
|
//
|
|
// OnFetchLsaError
|
|
// @Description: 在发生所有错误的情况下,将尝试重新获取LSA,直到deadline到达。
|
|
// @receiver l
|
|
// @param errorCode
|
|
// @param msg
|
|
// @param interestName
|
|
// @param retransmitNo
|
|
// @param deadline
|
|
// @param lsaName
|
|
// @param seqNo
|
|
//
|
|
func (l *Lsdb) OnFetchLsaError(errorCode uint32, msg string,
|
|
interestName *component.Identifier, retransmitNo uint32,
|
|
deadline *time.Time, lsaName *component.Identifier, seqNo uint64) {
|
|
}
|
|
|
|
//
|
|
// AfterFetchLsa
|
|
// @Description: 当SegmentFetcher返回一个有效LSA之后的成功回调
|
|
// 在NLSR的设计中,一个获取LSA的基础兴趣包格式为:
|
|
// /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
|
// @receiver l
|
|
// @param buffer
|
|
// @param interestName
|
|
//
|
|
func (l *Lsdb) AfterFetchLsa(buffer bytes.Buffer, interestName *component.Identifier) {
|
|
}
|
|
|
|
func (l *Lsdb) getLsaExpirationTimePoint() time.Time {
|
|
// todo
|
|
return time.Time{}
|
|
}
|