mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
47be345431
32 files changed
+571
-19
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
|
||||
*
|
||||
@@ -141,7 +153,6 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
return false;
|
||||
}
|
||||
this.minPacket.identifierField.addIdentifier(identifierWrapper);
|
||||
|
||||
return true;
|
||||
} catch (EncoderException | BlockException | ComponentException e) {
|
||||
throw new PacketException("Data.fillDataToFields: " + e.getMessage());
|
||||
@@ -228,7 +239,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws PacketException {
|
||||
// 首先将各项属性填充到分区当中
|
||||
if (this.fillDataToFields()) {
|
||||
if (!this.fillDataToFields()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -159,7 +159,6 @@ public class MINPacket implements IEncodingAble,IMINPacket {
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 的原因
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 14:03 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class LpPacketFragmentIdTest {
|
||||
@Test
|
||||
public void testLpPacketFragmentIdEncoderAndDecode() throws EncoderException, ComponentException, BlockException {
|
||||
LpPacketFragmentId lpPacketFragmentId=new LpPacketFragmentId(Long.MAX_VALUE);
|
||||
System.out.println("value: "+lpPacketFragmentId.getId());
|
||||
System.out.println("ini: "+lpPacketFragmentId.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
System.out.println("encode res: "+lpPacketFragmentId.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
LpPacketFragmentId newId=new LpPacketFragmentId();
|
||||
System.out.println("decode res: "+newId.wireDecode(block));
|
||||
System.out.println("new value: "+newId.getId());
|
||||
System.out.println("new ini: "+newId.isInitial());
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
newId.wireEncode(encoder);
|
||||
System.out.println("new buf: "+Arrays.toString(encoder.getBuffer()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 14:03 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class LpPacketFragmentNumTest {
|
||||
@Test
|
||||
public void testLpPacketFragmentNumEncoderAndDecode() throws EncoderException, ComponentException, BlockException {
|
||||
LpPacketFragmentNum lpPacketFragmentNum=new LpPacketFragmentNum(Long.MAX_VALUE);
|
||||
System.out.println("value: "+lpPacketFragmentNum.getFragmentNum());
|
||||
System.out.println("ini: "+lpPacketFragmentNum.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
System.out.println("encode res: "+lpPacketFragmentNum.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
LpPacketFragmentNum newNum=new LpPacketFragmentNum();
|
||||
System.out.println("decode res: "+newNum.wireDecode(block));
|
||||
System.out.println("new value: "+newNum.getFragmentNum());
|
||||
System.out.println("new ini: "+newNum.isInitial());
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
newNum.wireEncode(encoder);
|
||||
System.out.println("new buf: "+Arrays.toString(encoder.getBuffer()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 14:03 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class LpPacketFragmentSeqTest {
|
||||
@Test
|
||||
public void testLpPacketFragmentSeqEncoderAndDecode() throws EncoderException, ComponentException, BlockException {
|
||||
LpPacketFragmentSeq lpPacketFragmentSeq=new LpPacketFragmentSeq(Long.MAX_VALUE);
|
||||
System.out.println("value: "+lpPacketFragmentSeq.getFragmentSeq());
|
||||
System.out.println("ini: "+lpPacketFragmentSeq.isInitial());
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
System.out.println("encode res: "+lpPacketFragmentSeq.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
LpPacketFragmentSeq newSeq=new LpPacketFragmentSeq();
|
||||
System.out.println("decode res: "+newSeq.wireDecode(block));
|
||||
System.out.println("new value: "+newSeq.getFragmentSeq());
|
||||
System.out.println("new ini: "+newSeq.isInitial());
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
newSeq.wireEncode(encoder);
|
||||
System.out.println("new buf: "+Arrays.toString(encoder.getBuffer()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 14:19 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class LpPacketHeaderTest {
|
||||
@Test
|
||||
public void testLpPacketFragmentSeqEncoderAndDecode() throws EncoderException, ComponentException, BlockException {
|
||||
LpPacketHeader lpPacketHeader=new LpPacketHeader(new LpPacketFragmentId(Long.MAX_VALUE),
|
||||
new LpPacketFragmentNum(Long.MAX_VALUE),new LpPacketFragmentSeq(Long.MAX_VALUE));
|
||||
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
System.out.println("encode res: "+lpPacketHeader.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
LpPacketHeader newHeader=new LpPacketHeader();
|
||||
System.out.println("decode res: "+newHeader.wireDecode(block));
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize), new SizeT(0));
|
||||
newHeader.wireEncode(encoder);
|
||||
System.out.println("new buf: "+Arrays.toString(encoder.getBuffer()));
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,19 @@ public class CPacketTest {
|
||||
System.out.println("value: "+ Arrays.toString(cPacket.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* CPacket wireEncode:
|
||||
* [5, 61,
|
||||
* 50, 37,
|
||||
* 102, 19, 101, 17, 100, 4, 0, 109, 105, 110, 100, 4, 0, 112, 107, 117, 100, 3, 0, 115, 122,
|
||||
* 102, 14, 101, 12, 100, 4, 0, 110, 101, 116, 100, 4, 0, -25, -114, -117,
|
||||
* 52, 6, -52, 4, 1, 2, 3, 4,
|
||||
* 53, 12, 55, 10, -44, 8, 127, -1, -1, -1, -1, -1, -1, -1]
|
||||
* @throws EncoderException
|
||||
* @throws ComponentException
|
||||
* @throws PacketException
|
||||
* @throws BlockException
|
||||
*/
|
||||
@Test
|
||||
public void TestCPacket_WireEncode() throws EncoderException, ComponentException, PacketException, BlockException {
|
||||
MINPacket packet=new MINPacket();
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package packet;
|
||||
|
||||
import component.ComponentException;
|
||||
import component.Identifier;
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 21:19 2021/4/7
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class DataTest {
|
||||
@Test
|
||||
public void TestData_ToUri() throws ComponentException {
|
||||
Data data=new Data();
|
||||
Identifier name=new Identifier("/wefree/王");
|
||||
data.setName(name);
|
||||
System.out.println(data.getName().toUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data wireEncode:
|
||||
* [5, 53,
|
||||
* 50, 19,
|
||||
* 103, 17, 101, 15,
|
||||
* 100, 7, 0, 119, 101, 102, 114, 101, 101,
|
||||
* 100, 4, 0, -25, -114, -117,
|
||||
* 52, 16,
|
||||
* -46, 8, 127, -1, -1, -1, -1, -1, -1, -1,
|
||||
* -52, 4, -124, -35, -33, 25,
|
||||
* 53, 12, 54, 10, -45, 8, 127, -1, -1, -1, -1, -1, -1, -1]
|
||||
* @throws ComponentException
|
||||
* @throws EncoderException
|
||||
* @throws PacketException
|
||||
* @throws BlockException
|
||||
*/
|
||||
@Test
|
||||
public void TestData_WireEncode() throws ComponentException, EncoderException, PacketException, BlockException {
|
||||
Data data=new Data();
|
||||
data.freshnessPeriod.setFreshnessPeriod(Long.MAX_VALUE);
|
||||
byte[] value={(byte)132,(byte)221,(byte)223,(byte)25};
|
||||
data.payload.setValue(value);
|
||||
data.congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
Identifier name=new Identifier("/wefree/王");
|
||||
data.setName(name);
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+data.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
System.out.println("block buf: "+Arrays.toString(block.getValue()));
|
||||
Data newData=new Data();
|
||||
System.out.println("decode res: "+newData.wireDecode(block));
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+newData.wireEncode(encoder));
|
||||
byte[] newbuf=encoder.getBuffer();
|
||||
System.out.println("newbuf: "+ Arrays.toString(newbuf));
|
||||
System.out.println("new uri: "+newData.toUri()
|
||||
+" , freshness; "+newData.freshnessPeriod.getFreshnessPeriod());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package packet;
|
||||
|
||||
import component.ComponentException;
|
||||
import component.Identifier;
|
||||
import component.TTL;
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 10:32 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class InterestTest {
|
||||
@Test
|
||||
public void TestInterest_ToUri() throws ComponentException {
|
||||
Interest interest=new Interest();
|
||||
Identifier name=new Identifier("/wefree/王");
|
||||
interest.setName(name);
|
||||
System.out.println(interest.getName().toUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* Interest wireEncode:
|
||||
* [5, 69,
|
||||
* 50, 19,
|
||||
* 103, 17, 101, 15,
|
||||
* 100, 7, 0, 119, 101, 102, 114, 101, 101,
|
||||
* 100, 4, 0, -25, -114, -117,
|
||||
* 52, 20,
|
||||
* -49, 2, 15, -96,
|
||||
* -48, 8, 45, -7, 121, 78, -63, 21, -121, -66,
|
||||
* -52, 4, -124, -35, -33, 25,
|
||||
* 53, 24, 54, 10, -45, 8, 127, -1, -1, -1, -1, -1, -1, -1, 55, 10, -44, 8, 127, -1, -1, -1, -1, -1, -1, -1]
|
||||
* @throws ComponentException
|
||||
* @throws EncoderException
|
||||
* @throws PacketException
|
||||
* @throws BlockException
|
||||
*/
|
||||
@Test
|
||||
public void TestInterest_WireEncode() throws ComponentException, EncoderException, PacketException, BlockException {
|
||||
Interest interest=new Interest();
|
||||
interest.ttl.setTtl(Long.MAX_VALUE);
|
||||
byte[] value={(byte)132,(byte)221,(byte)223,(byte)25};
|
||||
interest.payload.setValue(value);
|
||||
interest.congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
Identifier name=new Identifier("/wefree/王");
|
||||
interest.setName(name);
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+interest.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
System.out.println("block buf: "+Arrays.toString(block.getValue()));
|
||||
Interest newInterest=new Interest();
|
||||
System.out.println("decode res: "+newInterest.wireDecode(block));
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+newInterest.wireEncode(encoder));
|
||||
byte[] newbuf=encoder.getBuffer();
|
||||
System.out.println("newbuf: "+ Arrays.toString(newbuf));
|
||||
System.out.println("new uri: "+newInterest.toUri()
|
||||
+" , ttl; "+newInterest.ttl.ttl());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package packet;
|
||||
|
||||
import component.*;
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 10:42 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class LpPacketTest {
|
||||
/**
|
||||
* LpPacket wireEncode:
|
||||
* [-15, 0, -6, 34,
|
||||
* -52, 4, 1, 2, 3, 4,
|
||||
* -15, 0, -5, 15,
|
||||
* -15, 0, -4, 1, 1,
|
||||
* -15, 0, -3, 1, 2,
|
||||
* -15, 0,-2, 1, 3]
|
||||
* @throws EncoderException
|
||||
* @throws PacketException
|
||||
* @throws BlockException
|
||||
*/
|
||||
@Test
|
||||
public void TestLpPacket_wireEncode() throws EncoderException, PacketException, BlockException {
|
||||
LpPacketHeader header=new LpPacketHeader(new LpPacketFragmentId(1),
|
||||
new LpPacketFragmentNum(2),new LpPacketFragmentSeq(3));
|
||||
byte[] value={(byte)1,(byte)2,(byte)3,(byte)4};
|
||||
LpPacket lpPacket=new LpPacket(header,new Payload(value));
|
||||
System.out.println(lpPacket.lpPacketHeader.getLpPacketFragmentId().getId()+", "
|
||||
+lpPacket.lpPacketHeader.getLpPacketFragmentNum().getFragmentNum()
|
||||
+", "+lpPacket.lpPacketHeader.getLpPacketFragmentSeq().getFragmentSeq()
|
||||
+", "+ Arrays.toString(lpPacket.payload.getValue()));
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+lpPacket.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
System.out.println("block buf: "+Arrays.toString(block.getValue()));
|
||||
LpPacket newLpPacket=new LpPacket();
|
||||
System.out.println("decode res: "+newLpPacket.wireDecode(block));
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+newLpPacket.wireEncode(encoder));
|
||||
byte[] newbuf=encoder.getBuffer();
|
||||
System.out.println("newbuf: "+ Arrays.toString(newbuf));
|
||||
System.out.println(newLpPacket.lpPacketHeader.getLpPacketFragmentId().getId()+". "
|
||||
+newLpPacket.lpPacketHeader.getLpPacketFragmentNum().getFragmentNum()
|
||||
+", "+newLpPacket.lpPacketHeader.getLpPacketFragmentSeq().getFragmentSeq()
|
||||
+", "+ Arrays.toString(newLpPacket.payload.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package packet;
|
||||
|
||||
import component.*;
|
||||
import encoding.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 11:23 2021/4/8
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class NackTest {
|
||||
/**
|
||||
* Nack wireEncode:
|
||||
* [5, 73,
|
||||
* 50, 19,
|
||||
* 103, 17, 101, 15,
|
||||
* 100, 7, 0, 119, 101, 102, 114, 101, 101,
|
||||
* 100, 4, 0, -25, -114, -117,
|
||||
* 52, 24,
|
||||
* -49, 2, 15, -96,
|
||||
* -48, 8, 28, -40, -82, -73, -63, -103, -15, -43,
|
||||
* -43, 2, 9, 29,
|
||||
* -52, 4, -124, -35, -33, 25,
|
||||
* 53, 24, 54, 10, -45, 8, 127, -1, -1, -1, -1, -1, -1, -1, 55, 10, -44, 8, 127, -1, -1, -1, -1, -1, -1, -1]
|
||||
* @throws EncoderException
|
||||
* @throws PacketException
|
||||
* @throws BlockException
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Test
|
||||
public void TestNack_wireEncode() throws EncoderException, PacketException, BlockException, ComponentException {
|
||||
Interest interest=new Interest();
|
||||
interest.ttl.setTtl(Long.MAX_VALUE);
|
||||
byte[] value={(byte)132,(byte)221,(byte)223,(byte)25};
|
||||
interest.payload.setValue(value);
|
||||
interest.congestionMark.setCongestionLevel(Long.MAX_VALUE);
|
||||
Identifier name=new Identifier("/wefree/王");
|
||||
interest.setName(name);
|
||||
Nack nack=new Nack(interest,2333);
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+nack.wireEncode(encoder));
|
||||
byte[] buf=encoder.getBuffer();
|
||||
System.out.println("buf: "+ Arrays.toString(buf));
|
||||
|
||||
Block block=new Block(buf,false);
|
||||
System.out.println("block buf: "+Arrays.toString(block.getValue()));
|
||||
Nack newNack=new Nack();
|
||||
System.out.println("decode res: "+newNack.wireDecode(block));
|
||||
encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0));
|
||||
System.out.println("encode res: "+newNack.wireEncode(encoder));
|
||||
byte[] newbuf=encoder.getBuffer();
|
||||
System.out.println("newbuf: "+ Arrays.toString(newbuf));
|
||||
System.out.println("new uri: "+newNack.interest.toUri()
|
||||
+" , ttl; "+newNack.interest.ttl.ttl()
|
||||
+" ,reason: "+newNack.getNackReason());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user