This commit is contained in:
Administrator
2025-08-08 17:13:27 +08:00
parent 7267aec1fd
commit 306bfd36f7
39 changed files with 2515 additions and 355 deletions
@@ -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;