diff --git a/src/main/java/component/Identifier.java b/src/main/java/component/Identifier.java index 188222a..c6ba63a 100644 --- a/src/main/java/component/Identifier.java +++ b/src/main/java/component/Identifier.java @@ -1,6 +1,9 @@ package component; import encoding.*; +import mgmt.ControlParameters; +import mgmt.MgmtException; +import packet.PacketException; import java.util.LinkedList; import java.util.List; @@ -278,4 +281,47 @@ public class Identifier implements TlvComponentBase, IEncodingAble { public void append(IdentifierComponent component) { this.components.addElement(component); } + + /** + * AppendCommandParameters 在名字中添加命令参数字段 + * @param parameters + * @return + * @throws ComponentException + */ + public boolean appendCommandParameters(ControlParameters parameters) throws ComponentException { + try { + byte[] buffer=new SelfEncodingBase().selfWireEncode(parameters).getRaw(); + if(buffer==null || buffer.length<=0){ + return false; + } + this.append(new IdentifierComponent(buffer)); + return true; + } catch (EncoderException | BlockException | ComponentException | PacketException | MgmtException e) { + throw new ComponentException("Identifier.appendCommandParameters: "+e.getMessage()); + } + } + + /** + * AppendVersionNumber 在名字后面添加一个版本号 + * @param versionNumber + * @return + */ + public boolean appendVersionNumber(long versionNumber){ + IdentifierComponent identifierComponent=new IdentifierComponent(); + identifierComponent.buildVersionNumberIdentifierComponent(versionNumber); + this.append(identifierComponent); + return true; + } + + /** + * AppendFragmentNumber 在名字后面添加一个分片号 + * @param fragmentNumber + * @return + */ + public boolean appendFragmentNumber(long fragmentNumber){ + IdentifierComponent identifierComponent=new IdentifierComponent(); + identifierComponent.buildFragmentNumberIdentifierComponent(fragmentNumber); + this.append(identifierComponent); + return true; + } } diff --git a/src/main/java/mgmt/CommandBase.java b/src/main/java/mgmt/CommandBase.java index 83e0025..7e619ad 100644 --- a/src/main/java/mgmt/CommandBase.java +++ b/src/main/java/mgmt/CommandBase.java @@ -15,7 +15,7 @@ import packet.Interest; * @Date: 21:13 2021/4/23 * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 */ -public class CommandBase { +public class CommandBase implements IControlCommand{ public static final String ManagementModuleFaceMgmt ="face-mgmt"; public static final String ManagementModuleFibMgmt ="fib-mgmt"; public static final String ManagementModuleCsMgmt = "cs-mgmt"; @@ -23,12 +23,13 @@ public class CommandBase { public String topPrefix; // 顶级前缀 public String moduleName; // 模块名称 public String action; // 命令动作 - public ControlParameters parameters; //管理命令参数 + public ControlParameters parameters; // 管理命令参数 /** * GetTopPrefix 获取顶级前缀 * @return */ + @Override public String getTopPrefix(){ return this.topPrefix; } @@ -45,6 +46,7 @@ public class CommandBase { * GetModuleName 获取模块名称 * @return */ + @Override public String getModuleName() { return moduleName; } @@ -61,6 +63,7 @@ public class CommandBase { * GetAction 获取命令动作 * @return */ + @Override public String getAction() { return action; } @@ -77,6 +80,7 @@ public class CommandBase { * GetParameters 获取管理命令前缀 * @return */ + @Override public ControlParameters getParameters() { return parameters; } diff --git a/src/main/java/mgmt/CommandExecutor.java b/src/main/java/mgmt/CommandExecutor.java index 766cafb..1e79a7d 100644 --- a/src/main/java/mgmt/CommandExecutor.java +++ b/src/main/java/mgmt/CommandExecutor.java @@ -4,8 +4,11 @@ import component.ComponentException; import component.Identifier; import jnr.ffi.annotations.In; import logicface.LogicFace; -import packet.Data; -import packet.Interest; +import logicface.LogicFaceException; +import packet.*; +import security.KeyChain; + +import static mgmt.ControlResponse.ControlResponseCodeSuccess; /* * @Author: Wang Feng @@ -31,6 +34,8 @@ public class CommandExecutor { public long ttl; // ICN 逻辑接口,用于和路由器进行ICN通信 public LogicFace logicFace; + // 用于给通信包签名(如果没有设置则不执行包签名) + public KeyChain keyChain; // 是否在命令执行完成后自动执行 LogicFace 的关闭操作 public boolean autoShutdown; @@ -47,6 +52,22 @@ public class CommandExecutor { this.autoShutdown=false; } + /** + * GetKeyChain 获取用于签名的秘钥链 + * @return + */ + public KeyChain getKeyChain() { + return keyChain; + } + + /** + * SetKeyChain 设置用于签名的秘钥链 + * @param keyChain + */ + public void setKeyChain(KeyChain keyChain) { + this.keyChain = keyChain; + } + /** * GetInterestLifeTime 获取命令兴趣包的生存期 * @return @@ -116,8 +137,11 @@ public class CommandExecutor { interest.ttl.setTtl(this.ttl); interest.interestLifeTime.setInterestLifeTime(this.interestLifeTime); interest.isCommandInterest=true; + if(this.keyChain!=null){ + this.keyChain.signInterest(interest); + } return interest; - } catch (ComponentException e) { + } catch (Exception e) { throw new MgmtException("CommandExecutor.newCommandInterest: "+e.getMessage()); } } @@ -127,9 +151,89 @@ public class CommandExecutor { * @param data * @return */ -// public ControlParameters onReceiveFirstMetaData(Data data){ -// -// } + private ControlResponse onReceiveFirstMetaData(Data data){ + ControlResponse controlResponse=new ControlResponse(); + // todo : json解析,将byte[]转为对象 +// if err := json.Unmarshal(data.GetValue(), controlResponse); err != nil { +// common.LogError("parse mgmt_data fail!the err is:", err) +// return nil, err +// } + + // 判断状态码 + switch (controlResponse.code){ + case ControlResponse.ControlResponseCodeSuccess: + // 请求成功,直接返回结果 + return controlResponse; + case ControlResponse.ControlResponseCodeCommonError: + // 请求失败,直接返回结果,结果中已经包含错误信息 + return controlResponse; + case ControlResponse.ControlResponseCodeContinue: + // 请求到元数据,继续请求所有的分片 + // todo: blabla + + } + + return controlResponse; + } + + /** + * Start 开始执行命令 + * // @Description: + * // 这是一个阻塞调用,会在命令请求结束之后返回一个结果 + * @return + */ + public ControlResponse start() throws MgmtException { + try { + // 构造管理命令前缀 + Interest commandInterest=this.newCommandInterest(); + if(commandInterest==null){ + return null; + } + + // 如果存在管理命令参数,则将其添加到命令兴趣包的名字当中 + if(this.command.getParameters()!=null){ + if(!commandInterest.appendCommandParameters(this.command.getParameters())){ + return null; + } + } + + ControlResponse controlResponse=new ControlResponse(); + + // 发送第一个命令兴趣包 + if(!this.logicFace.sendInterest(commandInterest)){ + return null; + } + + // 等待兴趣包应答 + MINPacket minPacket=this.logicFace.receivePacket(commandInterest.interestLifeTime.getInterestLifeTime()); + + // 判断收到的是什么包 + if(minPacket==null){ + controlResponse.code=ControlResponse.ControlResponseCodeCommonError; + controlResponse.msg="Request timeout!"; + return controlResponse; + } + + // 根据收到的包的类型分别处理 + if(PacketTypeHelper.isData(minPacket)){ + // onData + Data data=new Data().createDataByMINPacket(minPacket); + if(data==null){ + return null; + }else{ + return this.onReceiveFirstMetaData(data); + } + }else if(PacketTypeHelper.isNack(minPacket)){ + // onNack +// Nack nack=new Nack().createNackByInterest(); + // todo: here here!!!! + } + + return null; + } catch (MgmtException | ComponentException | LogicFaceException | PacketException e) { + throw new MgmtException("CommandExecutor.start: "+e.getMessage()); + } + } /** * buildPrefix 构造命令兴趣包请求前缀 diff --git a/src/main/java/mgmt/FibCommands/FibAddCommand.java b/src/main/java/mgmt/FibCommands/FibAddCommand.java new file mode 100644 index 0000000..fd435ab --- /dev/null +++ b/src/main/java/mgmt/FibCommands/FibAddCommand.java @@ -0,0 +1,28 @@ +package mgmt.FibCommands; + +import mgmt.CommandBase; +import mgmt.ControlParameters; + +/* + * @Author: Wang Feng + * @Description: FibAddCommand 表示一个添加下一跳的命令 + * @Version: 1.0.0 + * @Date: 20:06 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class FibAddCommand extends CommandBase { + /** + * CreateFibAddCommand 创建一个 FibAddCommand 命令 + * @param topPrefix + * @param parameters + * @return + */ + public static FibAddCommand createFibAddCommand(String topPrefix, ControlParameters parameters){ + FibAddCommand command=new FibAddCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFibMgmt); + command.setAction(FibCommands.FibManagementActionAdd); + command.setParameters(parameters); + return command; + } +} diff --git a/src/main/java/mgmt/FibCommands/FibCommands.java b/src/main/java/mgmt/FibCommands/FibCommands.java new file mode 100644 index 0000000..d475fc3 --- /dev/null +++ b/src/main/java/mgmt/FibCommands/FibCommands.java @@ -0,0 +1,15 @@ +package mgmt.FibCommands; + +/* + * @Author: Wang Feng + * @Description: + * @Version: 1.0.0 + * @Date: 20:07 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class FibCommands { + public static final String FibManagementActionAdd = "add"; + public static final String FibManagementActionDel = "del"; + public static final String FibManagementActionList = "list"; + public static final String FibManagementActionRegister = "register"; +} diff --git a/src/main/java/mgmt/FibCommands/FibDeleteCommand.java b/src/main/java/mgmt/FibCommands/FibDeleteCommand.java new file mode 100644 index 0000000..e206fbb --- /dev/null +++ b/src/main/java/mgmt/FibCommands/FibDeleteCommand.java @@ -0,0 +1,28 @@ +package mgmt.FibCommands; + +import mgmt.CommandBase; +import mgmt.ControlParameters; + +/* + * @Author: Wang Feng + * @Description: FibDeleteCommand 表示删除前缀指定logic face命令 + * @Version: 1.0.0 + * @Date: 20:33 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class FibDeleteCommand extends CommandBase { + /** + * CreateFibDeleteCommand 创建一个 FibDeleteCommand 命令 + * @param topPrefix + * @param parameters + * @return + */ + public static FibDeleteCommand createFibDeleteCommand(String topPrefix, ControlParameters parameters){ + FibDeleteCommand command=new FibDeleteCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFibMgmt); + command.setAction(FibCommands.FibManagementActionDel); + command.setParameters(parameters); + return command; + } +} diff --git a/src/main/java/mgmt/FibCommands/FibListCommand.java b/src/main/java/mgmt/FibCommands/FibListCommand.java new file mode 100644 index 0000000..eba3e4d --- /dev/null +++ b/src/main/java/mgmt/FibCommands/FibListCommand.java @@ -0,0 +1,25 @@ +package mgmt.FibCommands; + +import mgmt.CommandBase; + +/* + * @Author: Wang Feng + * @Description: FibListCommand 显示fib中的所有表项 + * @Version: 1.0.0 + * @Date: 20:36 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class FibListCommand extends CommandBase { + /** + * CreateFibListCommand 创建一个 FibListCommand 命令 + * @param topPrefix + * @return + */ + public static FibDeleteCommand createFibListCommand(String topPrefix){ + FibDeleteCommand command=new FibDeleteCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFibMgmt); + command.setAction(FibCommands.FibManagementActionList); + return command; + } +} diff --git a/src/main/java/mgmt/FibCommands/RegisterPrefixCommand.java b/src/main/java/mgmt/FibCommands/RegisterPrefixCommand.java new file mode 100644 index 0000000..67d7369 --- /dev/null +++ b/src/main/java/mgmt/FibCommands/RegisterPrefixCommand.java @@ -0,0 +1,28 @@ +package mgmt.FibCommands; + +import mgmt.CommandBase; +import mgmt.ControlParameters; + +/* + * @Author: Wang Feng + * @Description: RegisterPrefixCommand 注册一个前缀监听的命令 + * @Version: 1.0.0 + * @Date: 20:39 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class RegisterPrefixCommand extends CommandBase { + /** + * CreateRegisterPrefixCommand 创建一个 RegisterPrefixCommand 命令 + * @param topPrefix + * @param parameters + * @return + */ + public static RegisterPrefixCommand createRegisterPrefixCommand(String topPrefix, ControlParameters parameters){ + RegisterPrefixCommand command=new RegisterPrefixCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFibMgmt); + command.setAction(FibCommands.FibManagementActionRegister); + command.setParameters(parameters); + return command; + } +} diff --git a/src/main/java/mgmt/LogicFaceBuilder.java b/src/main/java/mgmt/LogicFaceBuilder.java new file mode 100644 index 0000000..b9c1e8d --- /dev/null +++ b/src/main/java/mgmt/LogicFaceBuilder.java @@ -0,0 +1,14 @@ +package mgmt; + +import logicface.LogicFace; + +/* + * @Author: Wang Feng + * @Description: LogicFaceBuilder ICN逻辑接口构造器 + * @Version: 1.0.0 + * @Date: 19:24 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +interface LogicFaceBuilderInterface { + LogicFace LogicFaceBuilder(); +} \ No newline at end of file diff --git a/src/main/java/mgmt/LogicFaceCommands/LogicFaceAddCommand.java b/src/main/java/mgmt/LogicFaceCommands/LogicFaceAddCommand.java new file mode 100644 index 0000000..c7de225 --- /dev/null +++ b/src/main/java/mgmt/LogicFaceCommands/LogicFaceAddCommand.java @@ -0,0 +1,28 @@ +package mgmt.LogicFaceCommands; + +import mgmt.CommandBase; +import mgmt.ControlParameters; + +/* + * @Author: Wang Feng + * @Description: LogicFaceAddCommand 表示一个添加 LogicFace 的命令 + * @Version: 1.0.0 + * @Date: 20:11 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class LogicFaceAddCommand extends CommandBase { + /** + * CreateLogicFaceAddCommand 创建一个 LogicFaceAddCommand 命令 + * @param topPrefix + * @param parameters + * @return + */ + public static LogicFaceAddCommand createLogicFaceAddCommand(String topPrefix, ControlParameters parameters){ + LogicFaceAddCommand command=new LogicFaceAddCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFaceMgmt); + command.setAction(LogicFaceCommands.LogicFaceManagementActionAdd); + command.setParameters(parameters); + return command; + } +} diff --git a/src/main/java/mgmt/LogicFaceCommands/LogicFaceCommands.java b/src/main/java/mgmt/LogicFaceCommands/LogicFaceCommands.java new file mode 100644 index 0000000..66cd397 --- /dev/null +++ b/src/main/java/mgmt/LogicFaceCommands/LogicFaceCommands.java @@ -0,0 +1,14 @@ +package mgmt.LogicFaceCommands; + +/* + * @Author: Wang Feng + * @Description: + * @Version: 1.0.0 + * @Date: 20:15 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class LogicFaceCommands { + public static final String LogicFaceManagementActionList = "list"; + public static final String LogicFaceManagementActionAdd = "add"; + public static final String LogicFaceManagementActionDel = "del"; +} diff --git a/src/main/java/mgmt/LogicFaceCommands/LogicFaceDelCommand.java b/src/main/java/mgmt/LogicFaceCommands/LogicFaceDelCommand.java new file mode 100644 index 0000000..0fe3127 --- /dev/null +++ b/src/main/java/mgmt/LogicFaceCommands/LogicFaceDelCommand.java @@ -0,0 +1,30 @@ +package mgmt.LogicFaceCommands; + +import mgmt.CommandBase; +import mgmt.ControlParameters; + +/* + * @Author: Wang Feng + * @Description: LogicFaceDelCommand 表示一个删除 LogicFace 的命令 + * @Version: 1.0.0 + * @Date: 20:20 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class LogicFaceDelCommand extends CommandBase { + /** + * CreateLogicFaceDelCommand 创建一个 LogicFaceDelCommand 命令 + * @param topPrefix + * @param id + * @return + */ + public static LogicFaceDelCommand createLogicFaceDelCommand(String topPrefix,long id){ + LogicFaceDelCommand command=new LogicFaceDelCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFaceMgmt); + command.setAction(LogicFaceCommands.LogicFaceManagementActionDel); + ControlParameters parameters=new ControlParameters(); + parameters.controlParameterLogicFaceId.setLogicFaceId(id); + command.setParameters(parameters); + return command; + } +} diff --git a/src/main/java/mgmt/LogicFaceCommands/LogicFaceListCommand.java b/src/main/java/mgmt/LogicFaceCommands/LogicFaceListCommand.java new file mode 100644 index 0000000..4a87939 --- /dev/null +++ b/src/main/java/mgmt/LogicFaceCommands/LogicFaceListCommand.java @@ -0,0 +1,25 @@ +package mgmt.LogicFaceCommands; + +import mgmt.CommandBase; + +/* + * @Author: Wang Feng + * @Description: LogicFaceListCommand 表示一个获取 MIR LogicFace 信息的命令 + * @Version: 1.0.0 + * @Date: 20:31 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class LogicFaceListCommand extends CommandBase { + /** + * CreateLogicFaceListCommand 创建一个 LogicFaceListCommand 命令 + * @param topPrefix + * @return + */ + public static LogicFaceListCommand createLogicFaceListCommand(String topPrefix){ + LogicFaceListCommand command=new LogicFaceListCommand(); + command.setTopPrefix(topPrefix); + command.setModuleName(ManagementModuleFaceMgmt); + command.setAction(LogicFaceCommands.LogicFaceManagementActionList); + return command; + } +} diff --git a/src/main/java/mgmt/MIRController.java b/src/main/java/mgmt/MIRController.java new file mode 100644 index 0000000..1bd0fdc --- /dev/null +++ b/src/main/java/mgmt/MIRController.java @@ -0,0 +1,59 @@ +package mgmt; + +import logicface.LogicFace; +import security.KeyChain; + +/* + * @Author: Wang Feng + * @Description: MIRController 表示一个 MIR 控制器 +// 主要用于和 MIR 进行管理命令通信 + * @Version: 1.0.0 + * @Date: 19:21 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class MIRController { + // LogicFace 构造工厂 + public LogicFaceBuilderInterface logicFaceBuilderInterface; + // 用于包签名的秘钥链 + public KeyChain keyChain; + // 是否让命令执行器在执行完命令之后就Shutdown,如果只希望执行一次命令,则设置为 true + public boolean autoShutdown; + + /** + * reateMIRController 创建一个 MIRController + * @param logicFaceBuilderInterface LogicFaceICN 构造器,每次执行需要返回一个新构造的逻辑接口 + * @param autoShutdown + * @param keyChain + * @return + */ + public static MIRController createMIRController(LogicFaceBuilderInterface logicFaceBuilderInterface, + boolean autoShutdown,KeyChain keyChain){ + MIRController mirController=new MIRController(); + + // 记录 LogicFace 构造器,之后发起命令时,可以使用这个构造器构造一个逻辑接口发起命令请求 + mirController.logicFaceBuilderInterface=logicFaceBuilderInterface; + mirController.autoShutdown=autoShutdown; + mirController.keyChain=keyChain; + + return mirController; + } + + /** + * PrepareCommandExecutor 构造一个命令执行器用来执行命令 + * @param command + * @return + */ + public CommandExecutor prepareCommandExecutor(IControlCommand command){ + LogicFace logicFace=this.logicFaceBuilderInterface.LogicFaceBuilder(); + if(logicFace==null){ + return null; + } + + CommandExecutor commandExecutor=new CommandExecutor(); + commandExecutor.init(command,logicFace); + commandExecutor.setAutoShutdown(this.autoShutdown); + commandExecutor.setKeyChain(this.keyChain); + + return commandExecutor; + } +} diff --git a/src/main/java/mgmt/RegisterPrefixHelper.java b/src/main/java/mgmt/RegisterPrefixHelper.java new file mode 100644 index 0000000..fc9934b --- /dev/null +++ b/src/main/java/mgmt/RegisterPrefixHelper.java @@ -0,0 +1,45 @@ +package mgmt; + +import component.Identifier; +import logicface.LogicFace; +import mgmt.FibCommands.RegisterPrefixCommand; +import security.KeyChain; + +/* + * @Author: Wang Feng + * @Description: RegisterPrefixHelper 一个用户辅助执行前缀注册的工具类 +// 因为go语言循环引用的限制,所以不能在logicface包里面引用mgmt中命令通信相关的工具, +// 所以使用了一个 IRegisterPrefixHelper 作为接口实现这个功能 + * @Version: 1.0.0 + * @Date: 19:17 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class RegisterPrefixHelper { + /** + * 注册前缀 + * @param identifier + * @param face + * @param keyChain + * @return + */ + public boolean registerPrefix(Identifier identifier, LogicFace face, KeyChain keyChain){ + MIRController controller=MIRController.createMIRController(new LogicFaceBuilderInterface() { + @Override + public LogicFace LogicFaceBuilder() { + return face; + } + }, + false, keyChain); + ControlParameters parameters=new ControlParameters(); + parameters.controlParameterPrefix.setPrefix(identifier); + CommandExecutor commandExecutor=controller.prepareCommandExecutor( + RegisterPrefixCommand.createRegisterPrefixCommand("/min-mir/mgmt/localhost",parameters)); + if(commandExecutor==null){ + return false; + } +// ControlResponse response=commandExecutor + // todo: here here!!! + + return true; + } +} diff --git a/src/main/java/packet/Interest.java b/src/main/java/packet/Interest.java index 09806fb..45e9818 100644 --- a/src/main/java/packet/Interest.java +++ b/src/main/java/packet/Interest.java @@ -2,6 +2,7 @@ package packet; import component.*; import encoding.*; +import mgmt.ControlParameters; import mgmt.MgmtException; /* @@ -146,6 +147,37 @@ public class Interest implements InteractWithField, IEncodingAble { return this.name.toUri(); } + /** + * AppendCommandParameters 在名字中添加命令参数字段 + * @param parameters + * @return + */ + public boolean appendCommandParameters(ControlParameters parameters) throws ComponentException { + try { + return this.name.appendCommandParameters(parameters); + } catch (ComponentException e) { + throw new ComponentException("Interest.appendCommandParameters: "+e.getMessage()); + } + } + + /** + * AppendVersionNumber 在名字后面添加一个版本号 + * @param versionNumber + * @return + */ + public boolean appendVersionNumber(long versionNumber){ + return this.name.appendVersionNumber(versionNumber); + } + + /** + * AppendFragmentNumber 在名字后面添加一个分片号 + * @param fragmentNumber + * @return + */ + public boolean appendFragmentNumber(long fragmentNumber){ + return this.name.appendFragmentNumber(fragmentNumber); + } + /** * 将 Interest 的各项属性填充到 MINPacket 中定义的对应分区当中 * diff --git a/src/main/java/packet/PacketTypeHelper.java b/src/main/java/packet/PacketTypeHelper.java new file mode 100644 index 0000000..921adbf --- /dev/null +++ b/src/main/java/packet/PacketTypeHelper.java @@ -0,0 +1,30 @@ +package packet; + +/* + * @Author: Wang Feng + * @Description: + * @Version: 1.0.0 + * @Date: 21:39 2021/4/27 + * @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室 + */ +public class PacketTypeHelper { + public static boolean isInterest(MINPacket packet){ + // todo: 有待实现!!! + return true; + } + + public static boolean isData(MINPacket packet){ + // todo: 有待实现!!! + return true; + } + + public static boolean isNack(MINPacket packet){ + // todo: 有待实现!!! + return true; + } + + public static boolean isCPacket(MINPacket packet){ + // todo: 有待实现!!! + return true; + } +}