mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add packet test: LpPacketTest
This commit is contained in:
1 parent
56eeae6dd7
commit
43468b0999
23 files changed
+208
-16
No files matched your search
@@ -13,6 +13,13 @@ public class CanBePrefix implements TlvComponentBase,InitialAble, IEncodingAble
|
||||
// 成员变量
|
||||
private boolean canBePrefix;
|
||||
|
||||
public CanBePrefix(){
|
||||
}
|
||||
|
||||
public CanBePrefix(boolean canBePrefix){
|
||||
this.setCanBePrefix(canBePrefix);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public void setCanBePrefix(boolean canBePrefix){
|
||||
this.canBePrefix=canBePrefix;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class CongestionMark implements TlvComponentBase, InitialAble, IEncodingA
|
||||
// 成员变量 todo: 越界问题
|
||||
private long congestionMark;
|
||||
|
||||
public CongestionMark(){
|
||||
}
|
||||
|
||||
public CongestionMark(long congestionMark){
|
||||
this.setCongestionLevel(congestionMark);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getCongestionLevel() {
|
||||
return this.congestionMark;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class FreshnessPeriod implements TlvComponentBase, InitialAble, IEncoding
|
||||
// 成员变量
|
||||
private long freshnessPeriod;
|
||||
|
||||
public FreshnessPeriod(){
|
||||
}
|
||||
|
||||
public FreshnessPeriod(long freshnessPeriod){
|
||||
this.setFreshnessPeriod(freshnessPeriod);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getFreshnessPeriod() {
|
||||
return this.freshnessPeriod;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class HopLimit implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
// 成员变量
|
||||
private long hopLimit;
|
||||
|
||||
public HopLimit(){
|
||||
}
|
||||
|
||||
public HopLimit(long hopLimit){
|
||||
this.setHopLimit(hopLimit);
|
||||
}
|
||||
|
||||
// 成员函数
|
||||
public long getHopLimit() {
|
||||
return hopLimit;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import packet.Interest;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
@@ -13,6 +14,13 @@ public class InterestLifeTime implements TlvComponentBase,InitialAble, IEncoding
|
||||
// 变量
|
||||
private long interestLifeTime;
|
||||
|
||||
public InterestLifeTime(){
|
||||
}
|
||||
|
||||
public InterestLifeTime(long interestLifeTime){
|
||||
this.setInterestLifeTime(interestLifeTime);
|
||||
}
|
||||
|
||||
// 方法
|
||||
public long getInterestLifeTime() {
|
||||
return interestLifeTime;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class LpPacketFragmentId implements TlvComponentBase,InitialAble,IEncodin
|
||||
// 成员变量
|
||||
private long id;
|
||||
|
||||
public LpPacketFragmentId(){
|
||||
}
|
||||
|
||||
public LpPacketFragmentId(long id){
|
||||
this.setId(id);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getId() {
|
||||
return id;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class LpPacketFragmentNum implements TlvComponentBase,InitialAble, IEncod
|
||||
// 成员变量
|
||||
private long fragmentNum;
|
||||
|
||||
public LpPacketFragmentNum(){
|
||||
}
|
||||
|
||||
public LpPacketFragmentNum(long fragmentNum){
|
||||
this.setFragmentNum(fragmentNum);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getFragmentNum() {
|
||||
return fragmentNum;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import packet.LpPacket;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
@@ -13,6 +14,13 @@ public class LpPacketFragmentSeq implements TlvComponentBase,InitialAble, IEncod
|
||||
// 成员变量
|
||||
private long fragmentSeq;
|
||||
|
||||
public LpPacketFragmentSeq(){
|
||||
}
|
||||
|
||||
public LpPacketFragmentSeq(long fragmentSeq){
|
||||
this.setFragmentSeq(fragmentSeq);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getFragmentSeq() {
|
||||
return fragmentSeq;
|
||||
|
||||
@@ -13,6 +13,13 @@ public class MustBeRefresh implements TlvComponentBase, InitialAble, IEncodingAb
|
||||
// 成员变量
|
||||
private boolean mustBeRefresh;
|
||||
|
||||
public MustBeRefresh(){
|
||||
}
|
||||
|
||||
public MustBeRefresh(boolean mustBeRefresh){
|
||||
this.setMustBeRefresh(mustBeRefresh);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public boolean getMustBeRefresh() {
|
||||
return mustBeRefresh;
|
||||
|
||||
@@ -10,10 +10,9 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class MutableDangerousField implements TlvComponentBase, IEncodingAble {
|
||||
private ElementContainer blocks;
|
||||
private ElementContainer blocks= new ElementContainer();
|
||||
|
||||
public MutableDangerousField() {
|
||||
blocks = new ElementContainer();
|
||||
public MutableDangerousField(){
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,12 +10,10 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class MutableField implements TlvComponentBase, IEncodingAble {
|
||||
public MutableProtectField mutableProtectField;
|
||||
public MutableDangerousField mutableDangerousField;
|
||||
public MutableProtectField mutableProtectField=new MutableProtectField();
|
||||
public MutableDangerousField mutableDangerousField=new MutableDangerousField();
|
||||
|
||||
public MutableField() {
|
||||
mutableProtectField = new MutableProtectField();
|
||||
mutableDangerousField = new MutableDangerousField();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,10 +10,9 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class MutableProtectField implements TlvComponentBase, IEncodingAble {
|
||||
private ElementContainer blocks;
|
||||
private ElementContainer blocks=new ElementContainer();
|
||||
|
||||
public MutableProtectField() {
|
||||
blocks = new ElementContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,13 @@ public class NackHeader implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
public static final long NackReasonDuplicate= 1;
|
||||
public static final long NackReasonNoRoute = 2;
|
||||
|
||||
public NackHeader(){
|
||||
}
|
||||
|
||||
public NackHeader(long nackReason){
|
||||
this.setNackReason(nackReason);
|
||||
}
|
||||
|
||||
// 函数
|
||||
public long getNackReason() {
|
||||
return nackReason;
|
||||
|
||||
@@ -15,6 +15,13 @@ public class Nonce implements TlvComponentBase, InitialAble, IEncodingAble {
|
||||
// 成员变量
|
||||
private long nonce;
|
||||
|
||||
public Nonce(){
|
||||
}
|
||||
|
||||
public Nonce(long nonce){
|
||||
this.setNonce(nonce);
|
||||
}
|
||||
|
||||
// 成员函数
|
||||
public long getNonce() {
|
||||
return this.nonce;
|
||||
|
||||
@@ -19,6 +19,10 @@ public class Payload implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
public Payload(){
|
||||
}
|
||||
|
||||
public Payload(byte[] value){
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param block
|
||||
|
||||
@@ -10,10 +10,9 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ReadOnlyField implements TlvComponentBase, IEncodingAble {
|
||||
private ElementContainer blocks;
|
||||
private ElementContainer blocks=new ElementContainer();
|
||||
|
||||
public ReadOnlyField() {
|
||||
blocks = new ElementContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,10 +45,9 @@ class SignatureAlgorithm{
|
||||
}
|
||||
}
|
||||
public class SignatureType implements TlvComponentBase, IEncodingAble {
|
||||
private SignatureAlgorithm value; // SignatureAlgorithm
|
||||
private SignatureAlgorithm value=new SignatureAlgorithm(); // SignatureAlgorithm
|
||||
|
||||
public SignatureType(){
|
||||
value=new SignatureAlgorithm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,12 +34,22 @@ import encoding.*;
|
||||
// }
|
||||
//
|
||||
public class CPacket implements InteractWithField, IEncodingAble {
|
||||
public MINPacket minPacket=new MINPacket();
|
||||
private MINPacket minPacket=new MINPacket();
|
||||
public TTL ttl=new TTL();
|
||||
public Payload payload=new Payload();
|
||||
public Identifier srcIdentifier=new Identifier();
|
||||
public Identifier dstIdentifier=new Identifier();
|
||||
|
||||
public CPacket(){
|
||||
}
|
||||
|
||||
public CPacket(Identifier srcIdentifier,Identifier dstIdentifier,
|
||||
Payload payload,TTL ttl){
|
||||
this.srcIdentifier=srcIdentifier;
|
||||
this.dstIdentifier=dstIdentifier;
|
||||
this.payload=payload;
|
||||
this.ttl=ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取源标识
|
||||
|
||||
@@ -33,13 +33,25 @@ import encoding.*;
|
||||
// }
|
||||
//
|
||||
public class Data implements IEncodingAble, InteractWithField {
|
||||
public MINPacket minPacket=new MINPacket();
|
||||
private MINPacket minPacket=new MINPacket();
|
||||
public FreshnessPeriod freshnessPeriod=new FreshnessPeriod();
|
||||
public Payload payload=new Payload();
|
||||
public CongestionMark congestionMark=new CongestionMark();
|
||||
public NackHeader nackHeader=new NackHeader();
|
||||
public Identifier name=new Identifier();
|
||||
|
||||
public Data(){
|
||||
}
|
||||
|
||||
public Data(Identifier name,Payload payload,FreshnessPeriod freshnessPeriod,
|
||||
CongestionMark congestionMark,NackHeader nackHeader){
|
||||
this.name=name;
|
||||
this.payload=payload;
|
||||
this.freshnessPeriod=freshnessPeriod;
|
||||
this.congestionMark=congestionMark;
|
||||
this.nackHeader=nackHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示数据包的 URI
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ import encoding.*;
|
||||
// }
|
||||
//
|
||||
public class Interest implements InteractWithField, IEncodingAble {
|
||||
public MINPacket minPacket=new MINPacket();
|
||||
private MINPacket minPacket=new MINPacket();
|
||||
public CanBePrefix canBePrefix=new CanBePrefix();
|
||||
public MustBeRefresh mustBeRefresh=new MustBeRefresh();
|
||||
public InterestLifeTime interestLifeTime=new InterestLifeTime();
|
||||
@@ -50,6 +50,24 @@ public class Interest implements InteractWithField, IEncodingAble {
|
||||
|
||||
public Identifier name=new Identifier();
|
||||
|
||||
public Interest(){
|
||||
}
|
||||
|
||||
public Interest(Identifier name,Payload payload,InterestLifeTime interestLifeTime,
|
||||
CanBePrefix canBePrefix,MustBeRefresh mustBeRefresh,Nonce nonce,
|
||||
HopLimit hopLimit,NackHeader nackHeader,CongestionMark congestionMark,TTL ttl){
|
||||
this.name=name;
|
||||
this.payload=payload;
|
||||
this.interestLifeTime=interestLifeTime;
|
||||
this.canBePrefix=canBePrefix;
|
||||
this.mustBeRefresh=mustBeRefresh;
|
||||
this.nonce=nonce;
|
||||
this.hopLimit=hopLimit;
|
||||
this.nackHeader=nackHeader;
|
||||
this.congestionMark=congestionMark;
|
||||
this.ttl=ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容兴趣包的名字
|
||||
*
|
||||
|
||||
@@ -16,6 +16,14 @@ public class LpPacket implements IEncodingAble {
|
||||
public LpPacketHeader lpPacketHeader=new LpPacketHeader();
|
||||
public Payload payload=new Payload();
|
||||
|
||||
public LpPacket(){
|
||||
}
|
||||
|
||||
public LpPacket(LpPacketHeader lpPacketHeader,Payload payload){
|
||||
this.lpPacketHeader=lpPacketHeader;
|
||||
this.payload=payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 LpPacket 线速编码为一个 TLV
|
||||
* @param encoder
|
||||
|
||||
@@ -32,6 +32,14 @@ import encoding.IEncodingAble;
|
||||
public class Nack implements IEncodingAble {
|
||||
public Interest interest=new Interest();
|
||||
|
||||
public Nack(){
|
||||
}
|
||||
|
||||
public Nack(Interest interest,long reason){
|
||||
this.interest=interest;
|
||||
this.setNackReason(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 Nack 的原因
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user