mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
69 lines
3.0 KiB
Java
69 lines
3.0 KiB
Java
package component;
|
|
|
|
import encoding.*;
|
|
import org.junit.Test;
|
|
import packet.Interest;
|
|
import packet.PacketException;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
/*
|
|
* @Author: feng Zhao
|
|
* @Description:
|
|
* @Version: 1.0.0
|
|
* @Date: 15:47 2021/3/25
|
|
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
*/
|
|
|
|
public class CongestionMarkTest {
|
|
int MaxPacketSize = 8800;
|
|
@Test
|
|
public void TestCongestionMark_GetCongestionLevel() {
|
|
CongestionMark congestionMark = new CongestionMark();
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
congestionMark.setCongestionLevel(1248355635356896986L);
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
System.out.println("interest:"+congestionMark.isInitial());
|
|
}
|
|
|
|
@Test
|
|
public void TestCongestionMark_WireEncode() throws EncoderException, ComponentException, BlockException {
|
|
CongestionMark congestionMark = new CongestionMark();
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
congestionMark.setCongestionLevel(1248355635356896986L);
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
System.out.println("interest:"+congestionMark.isInitial());
|
|
|
|
Encoder encoder = new Encoder();
|
|
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
|
congestionMark.wireEncode(encoder);
|
|
byte[] buf = encoder.getBuffer();
|
|
System.out.println("CongestionMark buf:"+ Arrays.toString(buf));
|
|
Block block = Block.createBlockByBuffer(buf, false);
|
|
System.out.println("CongestionMark block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
|
}
|
|
|
|
@Test
|
|
public void TestCongestionMark_WireDecode() throws EncoderException, ComponentException, BlockException, PacketException {
|
|
CongestionMark congestionMark = new CongestionMark();
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
congestionMark.setCongestionLevel(1248355635356896986L);
|
|
System.out.println("interest:"+congestionMark.getCongestionLevel());
|
|
System.out.println("interest:"+congestionMark.isInitial());
|
|
|
|
Encoder encoder = new Encoder();
|
|
encoder.encoderReset(new SizeT(MaxPacketSize), new SizeT(0));
|
|
congestionMark.wireEncode(encoder);
|
|
byte[] buf = encoder.getBuffer();
|
|
System.out.println("CongestionMark buf:"+ Arrays.toString(buf));
|
|
Block block = Block.createBlockByBuffer(buf, false);
|
|
System.out.println("CongestionMark block: "+block.getType()+","+block.getLength()+","+Arrays.toString(block.getValue()));
|
|
InterestLifeTime interest1 = new InterestLifeTime();
|
|
interest1.wireDecode(block);
|
|
System.out.println("interest1:" + congestionMark.getCongestionLevel());
|
|
System.out.println("interest1:" + congestionMark.isInitial());
|
|
}
|
|
}
|