UI改进
This commit is contained in:
@@ -69,7 +69,7 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
|
||||
public static final long HOTSOPT_TIMEOUT = 1000000000;
|
||||
|
||||
public static final int HOTSOPT_REPORT_INTERVAL = 100000000;
|
||||
public static final int HOTSOPT_REPORT_INTERVAL = 50000000;
|
||||
private SRv6Router router;
|
||||
public SRv6Router getRouter() {
|
||||
return router;
|
||||
@@ -83,14 +83,13 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
private long floodTimer=System.nanoTime();
|
||||
private long floodTimer2=System.nanoTime();
|
||||
private long requestTimer=System.nanoTime();
|
||||
KLALBVirtualRawSocket ds = null;
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setName("KLALB路由协议接收线程");
|
||||
getSelfRouterInfo();
|
||||
KLALBVirtualRawSocket ds = null;
|
||||
try{
|
||||
ds=new KLALBVirtualRawSocket(router,router.getLocator().getAddress(), DEFAULT_PROTOCOL_NUMBER);
|
||||
KLALBVirtualRawSocket ds2=ds;
|
||||
new Thread(()->{
|
||||
Thread.currentThread().setName("KLALB路由协议接收线程");
|
||||
|
||||
@@ -120,14 +119,14 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
if(debug)
|
||||
System.out.println("update60");
|
||||
floodTimer=cur;
|
||||
floodPacket(ds2, null, new RouterInfoPacket(selfRouterInfo,true,-1));
|
||||
floodPacket(ds, null, new RouterInfoPacket(selfRouterInfo,true,-1));
|
||||
}
|
||||
|
||||
if(cur-floodTimer2>1000000000L) {
|
||||
if(debug)
|
||||
System.out.println("update1");
|
||||
floodTimer2=cur;
|
||||
floodPacket(ds2, null, new RouterInfoPacket(selfRouterInfo,true,router.getASN()));
|
||||
floodPacket(ds, null, new RouterInfoPacket(selfRouterInfo,true,router.getASN()));
|
||||
}
|
||||
|
||||
//Set<Inet6Address> requestSet=new HashSet<>();
|
||||
@@ -174,10 +173,10 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
|
||||
for (Iterator<Entry<Inet6Address, HotspotAddressTimer>> iterator = hotspots.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry<Inet6Address, HotspotAddressTimer> type = (Entry<Inet6Address, HotspotAddressTimer>) iterator.next();
|
||||
if(type.getValue().checkReportTime()) {
|
||||
//if(type.getValue().checkReportTime()) {
|
||||
//System.out.println("hotspot address:"+type.getKey());
|
||||
writePacket(ds2, new RouterInfoPacket( netmap.get(router.getLocator().getAddress()),false,-1), new InetSocketAddress(type.getKey(), DEFAULT_PORT));
|
||||
}
|
||||
//writePacket(ds2, new RouterInfoPacket( netmap.get(router.getLocator().getAddress()),false,-1), new InetSocketAddress(type.getKey(), DEFAULT_PORT));
|
||||
//}
|
||||
if(type.getValue().checkTimeOut()) {
|
||||
iterator.remove();
|
||||
}
|
||||
@@ -358,7 +357,7 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
return;
|
||||
}
|
||||
Set<Entry<Inet6Address, RouterInfo>> s=netmap.entrySet();
|
||||
Map<Inet6Address,Long>airs=new HashMap<>(netmap.size()+1);
|
||||
Map<Inet6Address,Long>airs=new HashMap<>(netmap.size()*2,0.4f);
|
||||
|
||||
List<Inet6Address>rias=new ArrayList<>(netmap.size()+1);
|
||||
|
||||
@@ -620,10 +619,18 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
if(true) {
|
||||
HotspotAddressTimer hat=hotspots.get(sourceAddress);
|
||||
if(hat==null) {
|
||||
hotspots.put(sourceAddress, new HotspotAddressTimer());
|
||||
hotspots.put(sourceAddress,hat= new HotspotAddressTimer());
|
||||
}else {
|
||||
hat.refreshTimeout();
|
||||
}
|
||||
if(hat.checkReportTime()) {
|
||||
System.out.println("hotspot address:"+sourceAddress);
|
||||
try {
|
||||
writePacket(ds, new RouterInfoPacket( netmap.get(router.getLocator().getAddress()),false,-1), new InetSocketAddress(sourceAddress, DEFAULT_PORT));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private Map<Inet6Address,Long> toIpBandwidth=new ConcurrentHashMap<Inet6Address,Long>();
|
||||
@@ -646,7 +653,10 @@ public class KLALBRoutingProtocol extends Thread{
|
||||
NetmapDirections directionsx=directions;
|
||||
if(directionsx==null)
|
||||
return null;
|
||||
long number= directionsx.getDirection_airs().get(text);
|
||||
Long l=directionsx.getDirection_airs().get(text);
|
||||
if(l==null)
|
||||
return null;
|
||||
long number= l;
|
||||
long prev= directionsx.getDirection()[(int)number];
|
||||
if(prev==-1) {
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.kne.cloud.network.srv6;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -17,9 +18,23 @@ public class SRv6PacketReorder {
|
||||
this.packetConsumer=packetConsumer;
|
||||
}
|
||||
|
||||
private long jumpTime=500000000L;
|
||||
private long jumpTime=400000000L;
|
||||
|
||||
private Map<Long,IPv6Packet>map=new ConcurrentHashMap<>();
|
||||
|
||||
private long maxCacheingTime=5000000000L;
|
||||
|
||||
private class PacketTimeEntry{
|
||||
private IPv6Packet packet;
|
||||
private long addTime;
|
||||
public PacketTimeEntry(IPv6Packet packet) {
|
||||
super();
|
||||
this.packet = packet;
|
||||
this.addTime = System.nanoTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Map<Long,PacketTimeEntry>map=new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
private long orderTime=System.nanoTime();
|
||||
@@ -27,7 +42,7 @@ public class SRv6PacketReorder {
|
||||
|
||||
public void put(IPv6Packet pack, long sequence) throws IOException {
|
||||
//System.out.println(pack.getFlowLabel()+" "+sequence);
|
||||
map.put(sequence,pack);
|
||||
map.put(sequence,new PacketTimeEntry(pack));
|
||||
runOrdering();
|
||||
}
|
||||
private ReentrantLock orderLock=new ReentrantLock();
|
||||
@@ -39,13 +54,13 @@ public class SRv6PacketReorder {
|
||||
whi=false;
|
||||
|
||||
while(true) {
|
||||
IPv6Packet i6p=map.remove(seqptr.get());
|
||||
PacketTimeEntry i6p=map.remove(seqptr.get());
|
||||
if(i6p!=null) {
|
||||
//System.out.println("Ord:"+i6p.getFlowLabel()+" "+seqptr.get());
|
||||
seqptr.getAndIncrement();
|
||||
orderTime=System.nanoTime();
|
||||
if(packetConsumer!=null) {
|
||||
packetConsumer.accept(i6p);
|
||||
packetConsumer.accept(i6p.packet);
|
||||
}
|
||||
}else {
|
||||
break;
|
||||
@@ -69,6 +84,12 @@ public class SRv6PacketReorder {
|
||||
}finally {
|
||||
orderLock.unlock();
|
||||
}
|
||||
for (Iterator<PacketTimeEntry> iterator = map.values().iterator(); iterator.hasNext();) {
|
||||
PacketTimeEntry type = (PacketTimeEntry) iterator.next();
|
||||
if(System.nanoTime()-type.addTime>maxCacheingTime) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ import com.google.gson.internal.Pair;
|
||||
public class SRv6Router {
|
||||
private static final boolean debug = false;
|
||||
|
||||
public static final int MTU = 8192;
|
||||
public static final int MTU = 16384;
|
||||
|
||||
public static final int MAX_REROUTE_COUNT=2;//1
|
||||
|
||||
@@ -417,7 +417,7 @@ public class SRv6Router {
|
||||
segmentsLeft--;
|
||||
}
|
||||
List<Inet6Address> repairSegments= klalbRouteProtol.createSegmentList(srh.getAddresses().get(segmentsLeft));
|
||||
if(repairSegments ==null) {
|
||||
if(repairSegments ==null||repairSegments.isEmpty()) {
|
||||
System.out.println("FRR保护失败");
|
||||
return;
|
||||
}
|
||||
@@ -589,15 +589,15 @@ public class SRv6Router {
|
||||
|
||||
}
|
||||
if(retry) {
|
||||
if(System.nanoTime()-start>200000000L) {
|
||||
if(System.nanoTime()-start>1000000L) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
/*try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//Thread.yield();
|
||||
}*/
|
||||
Thread.yield();
|
||||
//短暂挂起当前线程,待链路速度未超限时重试发送数据包
|
||||
}
|
||||
}while((!routes.isEmpty())&&retry);
|
||||
@@ -713,6 +713,7 @@ public class SRv6Router {
|
||||
srhh.setSegmentsLeft(newSL);
|
||||
iPv6Packet.setDestinationAddress(srhh.getAddresses().get(newSL));
|
||||
}
|
||||
if(iPv6Packet.getPayload().getProtocolNumber()!=KLALBRoutingProtocol.DEFAULT_PROTOCOL_NUMBER)
|
||||
klalbRouteProtol.putHotspotAddress(iPv6Packet.getSourceAddress());
|
||||
routePacket(iPv6Packet,reroute);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user