forked from KNEMC/KLALB
增加流量控制
增加自动按延迟选择线路
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.kne.cloud.network.mport.IPPort;
|
||||
|
||||
public class KLALBBlock {
|
||||
public class KLALBBlock implements Comparable<KLALBBlock>{
|
||||
private static AtomicLong sng=new AtomicLong(0);
|
||||
|
||||
public long sn;//每个数据包的唯一编号
|
||||
@@ -16,10 +16,13 @@ public class KLALBBlock {
|
||||
public byte[]data;//数据内容
|
||||
public int command;//功能标记 0=PING 1=PONG 2=SYN 3=RST
|
||||
public long pingtime;//PING计时器
|
||||
public int cacheused;
|
||||
|
||||
public String lservice;
|
||||
public IPPort lipport;
|
||||
|
||||
|
||||
public transient volatile long sendtime;
|
||||
public transient volatile int resend;
|
||||
|
||||
|
||||
public KLALBBlock() {
|
||||
@@ -34,9 +37,13 @@ public class KLALBBlock {
|
||||
sb.append(cuid);
|
||||
sb.append(' ');
|
||||
if(number>0) {
|
||||
if(data==null) {
|
||||
sb.append("DATA").append(number).append(':').append("EOF");
|
||||
}else {
|
||||
sb.append("DATA").append(number).append(':').append(data.length);
|
||||
}
|
||||
}else if(number<0) {
|
||||
sb.append("ACK").append(-number);
|
||||
sb.append("ACK").append(-number).append(':').append(cacheused);
|
||||
}else {
|
||||
switch(command) {
|
||||
case 0:
|
||||
@@ -55,5 +62,18 @@ public class KLALBBlock {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(KLALBBlock o) {
|
||||
if(o.number>number) {
|
||||
return -1;
|
||||
}else if(o.number<number){
|
||||
return 1;
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user