mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 06:00:25 +08:00
add Packet: Nack
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package packet;
|
||||
|
||||
import component.ComponentException;
|
||||
import encoding.Block;
|
||||
import encoding.Encoder;
|
||||
import encoding.IEncodingAble;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
@@ -7,5 +12,62 @@ package packet;
|
||||
* @Date: 17:34 2021/4/2
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class Nack {
|
||||
//
|
||||
// 表示一个通用的 Nack
|
||||
//
|
||||
// @Description:
|
||||
// Nack 是一个特殊的兴趣包,其就是 Interest 中设置了 NackHeader
|
||||
// 1. 包格式如下:
|
||||
// Nack = 5 TLV-LENGTH
|
||||
// { InterestIdentifier } => 标识区
|
||||
// { Signature } => 签名区
|
||||
// { => 只读区
|
||||
// [NackHeader]
|
||||
// ...
|
||||
// }
|
||||
// { => 可变区
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
public class Nack implements IEncodingAble {
|
||||
public Interest interest=new Interest();
|
||||
|
||||
/**
|
||||
* 设置 Nack 的原因
|
||||
*/
|
||||
public void setNackReason(long reason){
|
||||
this.interest.nackHeader.setNackReason(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Nack 的原因
|
||||
* @return
|
||||
*/
|
||||
public long getNackReason(){
|
||||
return this.interest.nackHeader.getNackReason();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Nack 线速编码为一个 TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
* @throws PacketException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws PacketException {
|
||||
return this.interest.wireEncode(encoder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 Nack
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
* @throws PacketException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws PacketException {
|
||||
return this.interest.wireDecode(block);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user