forked from KNEMC/KLALB
KLALB3.2
This commit is contained in:
@@ -56,14 +56,18 @@ import org.kne.cloud.network.ipv6.IPv6TUNLoopbackNetworkLink;
|
||||
import org.kne.cloud.network.ipv6.Inet6AddressGroup;
|
||||
import org.kne.cloud.network.monitor.MonitorData;
|
||||
import org.kne.cloud.network.monitor.SpeedAndTrafficMonitorDataImpl;
|
||||
import org.kne.cloud.network.srv6.KLALBRoutingProtocol;
|
||||
import org.kne.cloud.network.srv6.PacketConsumer;
|
||||
import org.kne.cloud.network.srv6.SRv6Router;
|
||||
import org.kne.cloud.network.te.BandwidthDistributer;
|
||||
import org.kne.cloud.network.te.DWRRLoadingBalanceAlgorithm;
|
||||
import org.kne.concurrent.DisruptorExecutor;
|
||||
import org.kne.concurrent.HighPerformanceExecutor;
|
||||
import org.kne.io.KNEChannels;
|
||||
import org.pcap4j.packet.IpV6Packet.IpV6Header;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public class KLALBController {
|
||||
|
||||
|
||||
@@ -80,6 +84,12 @@ public class KLALBController {
|
||||
|
||||
private static List<IPMulticastDiscovery> ipmd=new ArrayList<>();
|
||||
|
||||
private List<InetAddress>dnsAddresses=new ArrayList<>();
|
||||
|
||||
public List<InetAddress> getDnsAddresses() {
|
||||
return dnsAddresses;
|
||||
}
|
||||
|
||||
private Timer twk=new Timer("网卡检测扫描计时器", true);
|
||||
{
|
||||
|
||||
@@ -210,48 +220,49 @@ public class KLALBController {
|
||||
continue;
|
||||
}
|
||||
if(networkInterface.isUp()) {
|
||||
boolean b=true;
|
||||
|
||||
Enumeration<InetAddress>ei= networkInterface.getInetAddresses();
|
||||
loop:while (ei.hasMoreElements()) {
|
||||
InetAddress bidr = (InetAddress) ei.nextElement();
|
||||
|
||||
for (Iterator<IPMulticastDiscovery> iterator = ipmd.iterator(); iterator.hasNext();) {
|
||||
IPMulticastDiscovery ipMulticastDiscovery = (IPMulticastDiscovery) iterator.next();
|
||||
if(networkInterface.equals(ipMulticastDiscovery.getNinterface())) {
|
||||
b=false;
|
||||
break;
|
||||
if(networkInterface.equals(ipMulticastDiscovery.getNinterface())&&bidr.equals(ipMulticastDiscovery.getBind().getAddress())) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
if(b) {
|
||||
/*InetAddress bidr=null;
|
||||
Enumeration<InetAddress>ei= networkInterface.getInetAddresses();
|
||||
while (ei.hasMoreElements()) {
|
||||
InetAddress inetAddress = (InetAddress) ei.nextElement();
|
||||
if(inetAddress instanceof Inet6Address) {
|
||||
Inet6Address i6=(Inet6Address) inetAddress;
|
||||
if(i6.getHostAddress().startsWith("fe80")) {
|
||||
bidr=i6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(bidr!=null)*/
|
||||
|
||||
|
||||
|
||||
try {
|
||||
InetAddress bidr=InetAddress.getByName("::0");
|
||||
IPMulticastDiscovery ipd=new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT), new InetSocketAddress(InetAddress.getByName("ff02::2486"),DISCOVERY_PORT), networkInterface,selflineTable);
|
||||
//InetAddress bidr=InetAddress.getByName("::0");
|
||||
|
||||
if(bidr instanceof Inet6Address) {
|
||||
IPMulticastDiscovery ipd=new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT), new InetSocketAddress(InetAddress.getByName("ff02::2486"),DISCOVERY_PORT), networkInterface,selflineTable,10000L);
|
||||
ipd.setCon((mpa)->{
|
||||
//System.out.println("添加本地IPv6链路:"+mpa);
|
||||
addRemoteLines(mpa);
|
||||
try {
|
||||
if(!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd.start();
|
||||
ipmd.add(ipd);
|
||||
|
||||
bidr=InetAddress.getByName("0.0.0.0");
|
||||
IPMulticastDiscovery ipd2=new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT), new InetSocketAddress(InetAddress.getByName("224.0.0.86"),DISCOVERY_PORT), networkInterface,selflineTable);
|
||||
}else if(bidr instanceof Inet4Address) {
|
||||
//bidr=InetAddress.getByName("0.0.0.0");
|
||||
IPMulticastDiscovery ipd2=new IPMulticastDiscovery(new InetSocketAddress(bidr,DISCOVERY_PORT), new InetSocketAddress(InetAddress.getByName("224.0.0.86"),DISCOVERY_PORT), networkInterface,selflineTable,10000L);
|
||||
ipd2.setCon((mpa)->{
|
||||
//System.out.println("添加本地IPv4链路:"+mpa);
|
||||
addRemoteLines(mpa);
|
||||
try {
|
||||
if(!checkIsSelf(mpa))
|
||||
addRemoteLines(mpa);
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
});
|
||||
ipd2.start();
|
||||
ipmd.add(ipd2);
|
||||
|
||||
}
|
||||
System.out.println("添加网卡:"+networkInterface);
|
||||
}catch(BindException e) {
|
||||
//e.printStackTrace();
|
||||
@@ -259,8 +270,11 @@ public class KLALBController {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +284,11 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkIsSelf(MultipurposeSocketAddress inetAddress) throws UnknownHostException {
|
||||
|
||||
return inetAddress.getInetAddress().isAnyLocalAddress()||inetAddress.getInetAddress().isLoopbackAddress()||selflineTable.contains(inetAddress);
|
||||
}
|
||||
}, 2000, 2000);
|
||||
}
|
||||
public SpeedAndTrafficMonitorDataImpl getLinkMonitor() {
|
||||
@@ -326,10 +345,10 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
|
||||
private Inet6AddressGroup self;
|
||||
//private Inet6AddressGroup self;
|
||||
|
||||
public Inet6Address getSelf() {
|
||||
return self.getAddress();
|
||||
public Inet6AddressGroup getSelf() {
|
||||
return srv6Router.getLocator();
|
||||
}
|
||||
private List<KLALBRemoteLine> lines=new CopyOnWriteArrayList<>();
|
||||
private ReadWriteLock lineslock=new ReentrantReadWriteLock();
|
||||
@@ -339,11 +358,16 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
private PortBinder streamPortBinder=new PortBinder(this);
|
||||
|
||||
private PortBinder rawPortBinder=new PortBinder(this);
|
||||
|
||||
protected PortBinder getStreamPortBinder() {
|
||||
return streamPortBinder;
|
||||
}
|
||||
|
||||
|
||||
public PortBinder getRawPortBinder() {
|
||||
return rawPortBinder;
|
||||
}
|
||||
|
||||
public void reconnectImmediately() {
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
@@ -380,7 +404,8 @@ public class KLALBController {
|
||||
|
||||
}
|
||||
|
||||
public List<KLALBRemoteLine> addRemoteLines(MultipurposeSocketAddress target) {
|
||||
public List<KLALBRemoteLine> addRemoteLines(MultipurposeSocketAddress target) {lineslock.writeLock().lock();
|
||||
try {
|
||||
List<KLALBRemoteLine>added=new ArrayList<>();
|
||||
try {
|
||||
Enumeration<NetworkInterface>eu= NetworkInterface.getNetworkInterfaces();
|
||||
@@ -419,6 +444,9 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
return added;
|
||||
}finally {
|
||||
lineslock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
public List<KLALBRemoteLine> removeRemoteLines(MultipurposeSocketAddress mpsa) {
|
||||
|
||||
@@ -477,15 +505,15 @@ public class KLALBController {
|
||||
}
|
||||
|
||||
public void addRemoteLine(KLALBRemoteLine krs) {
|
||||
lineslock.writeLock().lock();
|
||||
try {
|
||||
krs.setPacketReceiver(prc);
|
||||
krs.setKlalbController(this);
|
||||
krs.setLocalVaddrSupplier(()->{return self;});
|
||||
krs.setLocalVaddrSupplier(()->{return getSelf();});
|
||||
krs.startIO();
|
||||
String selflineTable=generateSelfLineTable();
|
||||
if(selflineTable!=null&&!selflineTable.equals(""))
|
||||
krs.sendPacket(new ADDLINESPacket(selflineTable));
|
||||
lineslock.writeLock().lock();
|
||||
try {
|
||||
lines.add(krs);
|
||||
}finally {
|
||||
lineslock.writeLock().unlock();
|
||||
@@ -502,16 +530,12 @@ public class KLALBController {
|
||||
}
|
||||
return sbd.toString();
|
||||
}
|
||||
|
||||
public KLALBController(Inet6Address self) {
|
||||
this.self =new Inet6AddressGroup(self, PREFIX);
|
||||
loadSRv6ProtocolStack();
|
||||
}
|
||||
|
||||
private class KLALBProtocolPacketConsumer implements PacketConsumer{
|
||||
|
||||
@Override
|
||||
public void accept(IPv6Packet packx) throws IOException {
|
||||
HighPerformanceExecutor.defaultExecutor.execute(()->{
|
||||
//HighPerformanceExecutor.defaultExecutor.execute(()->{
|
||||
|
||||
/*System.out.println("RCV:"+packx.getPayload().getData());
|
||||
byte[]b=new byte[packx.getPayload().getData().limit()];
|
||||
@@ -539,18 +563,18 @@ public class KLALBController {
|
||||
}
|
||||
}
|
||||
}
|
||||
packx.dispose();
|
||||
});
|
||||
//packx.dispose();
|
||||
//});
|
||||
}
|
||||
|
||||
}
|
||||
private void loadSRv6ProtocolStack() {
|
||||
srv6Router=new SRv6Router(self);
|
||||
private void loadSRv6ProtocolStack(Inet6AddressGroup selfx,boolean enableVirtualAdapter) {
|
||||
srv6Router=new SRv6Router(selfx);
|
||||
if(enableVirtualAdapter)
|
||||
try {
|
||||
IPv6TUNLoopbackNetworkLink tunlink=new IPv6TUNLoopbackNetworkLink(new Inet6AddressGroup( srv6Router.getLocator().getAddress(),32),SRv6Router.MTU);
|
||||
IPv6TUNLoopbackNetworkLink tunlink=new IPv6TUNLoopbackNetworkLink(new Inet6AddressGroup( srv6Router.getLocator().getAddress(),32),SRv6Router.MTU, dnsAddresses);
|
||||
tunlink.setMonitor(datatMonitor);
|
||||
srv6Router.getLinkTabel().add(tunlink);
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -558,8 +582,19 @@ public class KLALBController {
|
||||
srv6Router.getProtocolNumberRegister().put(KLALBPacket.KLALB_PROTOCOL_NUMBER,new KLALBProtocolPacketConsumer());
|
||||
System.out.println("SRv6协议栈已加载");
|
||||
}
|
||||
|
||||
public KLALBController() {
|
||||
this(true,null);
|
||||
}
|
||||
public KLALBController (Inet6Address self) {
|
||||
this(self,true,null);
|
||||
}
|
||||
public KLALBController(Inet6Address self,boolean enableVirtualAdapter,List<InetAddress> dnsaddr) {
|
||||
this.dnsAddresses=dnsaddr;
|
||||
Inet6AddressGroup selfg =new Inet6AddressGroup(self, PREFIX);
|
||||
loadSRv6ProtocolStack(selfg,enableVirtualAdapter);
|
||||
}
|
||||
public KLALBController(boolean enableVirtualAdapter,List<InetAddress> dnsaddr) {
|
||||
this.dnsAddresses=dnsaddr;
|
||||
SecureRandom sc=new SecureRandom();
|
||||
byte[]v=new byte[16];
|
||||
sc.nextBytes(v);
|
||||
@@ -569,27 +604,31 @@ public class KLALBController {
|
||||
v[3]=1;
|
||||
v[14]=0;
|
||||
v[15]=1;
|
||||
Inet6AddressGroup selfx=null;
|
||||
try {
|
||||
this.self=new Inet6AddressGroup( (Inet6Address) InetAddress.getByAddress(v),PREFIX);
|
||||
selfx=new Inet6AddressGroup( (Inet6Address) InetAddress.getByAddress(v),PREFIX);
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
loadSRv6ProtocolStack();
|
||||
loadSRv6ProtocolStack(selfx,enableVirtualAdapter);
|
||||
}
|
||||
|
||||
public KLALBController(List<InetAddress> daddr) {
|
||||
this(true,daddr);
|
||||
}
|
||||
|
||||
public KLALBController(Inet6Address self, List<InetAddress> daddr) {
|
||||
this(self,true,daddr);
|
||||
}
|
||||
|
||||
public KLALBController(boolean enableVirtualAdapter) {
|
||||
this(enableVirtualAdapter,null);
|
||||
}
|
||||
|
||||
protected KLALBVirtualSocketImpl createVirtualImpl() {
|
||||
return new KLALBVirtualSocketImpl(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected void sendPacketToLinkAddress(Inet6Address addr, KLALBPacket packet)
|
||||
throws IOException {
|
||||
sendPacketToLinkAddress(addr, packet, 1);
|
||||
}
|
||||
|
||||
private SRv6Router srv6Router;
|
||||
|
||||
|
||||
@@ -603,7 +642,7 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Map<Inet6Address,DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>> lines2 =new ConcurrentHashMap<>();
|
||||
//Map<Inet6Address,DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>> lines2 =new ConcurrentHashMap<>();
|
||||
for (Iterator<KLALBRemoteLine> iterator = lines.iterator(); iterator.hasNext();) {
|
||||
KLALBRemoteLine klalbRemoteLine = (KLALBRemoteLine) iterator.next();
|
||||
if(klalbRemoteLine.isClosed()) {
|
||||
@@ -615,20 +654,20 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
}
|
||||
}else {
|
||||
if(klalbRemoteLine.getRemoteVaddr()!=null&&klalbRemoteLine.getMonitor().getState()==MonitorData.ONLINE) {
|
||||
if(lines2.containsKey(klalbRemoteLine.getRemoteVaddr())) {
|
||||
/* if(lines2.containsKey(klalbRemoteLine.getRemoteVaddr())) {
|
||||
lines2.get(klalbRemoteLine.getRemoteVaddr()).getEntries().add(klalbRemoteLine);
|
||||
}else {
|
||||
ArrayList<KLALBRemoteLine>al1=new ArrayList<>();
|
||||
al1.add(klalbRemoteLine);
|
||||
lines2.put(klalbRemoteLine.getRemoteVaddr().getAddress(), new DWRRLoadingBalanceAlgorithm<>(al1));
|
||||
}
|
||||
}*/
|
||||
if(!srv6Router.getLinkTabel().contains(klalbRemoteLine)) {
|
||||
srv6Router.getLinkTabel().add(klalbRemoteLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>>> iterator = lines2.entrySet().iterator(); iterator.hasNext();) {
|
||||
/*for (Iterator<Entry<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>>> iterator = lines2.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>> klalbRemoteLine = (Entry<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>>) iterator.next();
|
||||
List<KLALBRemoteLine> lineList=klalbRemoteLine.getValue().getEntries();
|
||||
lineList.forEach((r)->{
|
||||
@@ -641,7 +680,7 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
}
|
||||
|
||||
}
|
||||
KLALBController.this.lines2=lines2;
|
||||
KLALBController.this.lines2=lines2;*/
|
||||
if(srv6Router!=null) {
|
||||
srv6Router.getLinkTabel().removeIf((v)->{
|
||||
return (v instanceof KLALBRemoteLine)&&(!v.isUp());
|
||||
@@ -649,7 +688,7 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
srv6Router.updateRouteTabel();
|
||||
}
|
||||
}
|
||||
}, 1, 1);
|
||||
}, 2, 2);
|
||||
}
|
||||
/*private void updateLines2(Inet6Address addr) throws SocketTimeoutException {
|
||||
List<KLALBRemoteLine> l=new ArrayList();
|
||||
@@ -675,122 +714,7 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
lines2.put(addr, l);
|
||||
}
|
||||
}*/
|
||||
private Map<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>> lines2 = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
protected void sendPacketToLinkAddress(Inet6Address addr, KLALBPacket packet, int count)
|
||||
throws IOException {
|
||||
if(packet==null)
|
||||
throw new NullPointerException("packet is null!");
|
||||
//TimeDebugger tdb=new TimeDebugger();
|
||||
|
||||
|
||||
//tdb.putTime("start");
|
||||
packet.genseq();
|
||||
/*loop:while(true) {
|
||||
if(packet.isDisposed())
|
||||
return;
|
||||
List<KLALBRemoteLine> lines2x;
|
||||
|
||||
lines2x=lines2.get(addr);
|
||||
|
||||
if (lines2x == null || lines2x.isEmpty()) {
|
||||
throw new NoRouteToHostException("address unreachable: " + addr);
|
||||
}
|
||||
|
||||
int count0 = Math.min(count, lines2x.size());
|
||||
|
||||
for (int i = 0; i < lines2x.size(); i++) {
|
||||
KLALBRemoteLine krst =lines2x.get(i);
|
||||
if(krst.getMonitor().getState()==MonitorData.ONLINE)
|
||||
if(!packet.getSendRecord().contains(krst)) {
|
||||
if(krst.getQueue().size()<10) {
|
||||
packet.getSendRecord().add(krst);
|
||||
//System.out.println(krst);
|
||||
krst.sendPacket(packet);
|
||||
count0--;
|
||||
if (count0 <= 0)
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < lines2x.size(); i++) {
|
||||
KLALBRemoteLine krst =lines2x.get(i);
|
||||
if(krst.getMonitor().getState()==MonitorData.ONLINE)
|
||||
if(packet.getSendRecord().contains(krst)) {
|
||||
if(krst.getQueue().size()<10) {
|
||||
packet.getSendRecord().add(krst);
|
||||
//System.out.println(krst);
|
||||
krst.sendPacket(packet);
|
||||
count0--;
|
||||
if (count0 <= 0)
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
LockSupport.parkNanos(50000);
|
||||
//tdb.putTime("sendfailed");
|
||||
}*/
|
||||
//tdb.putTime("sendsuccess");
|
||||
//tdb.print();
|
||||
|
||||
/* List<KLALBRemoteLine> lines2x;
|
||||
lines2x=lines2.get(addr);
|
||||
|
||||
if (lines2x == null || lines2x.isEmpty()) {
|
||||
throw new NoRouteToHostException("address unreachable: " + addr);
|
||||
}
|
||||
KLALBRemoteLine kr= lines2x.get(0);
|
||||
kr.sendPacket(packet);
|
||||
packet.getSendRecord().add(kr);*/
|
||||
|
||||
/*loop:while(true) {
|
||||
if(packet.isDisposed())
|
||||
return;
|
||||
DWRRLoadingBalanceAlgorithm<KLALBRemoteLine> dwrlines2x;
|
||||
|
||||
dwrlines2x=lines2.get(addr);
|
||||
|
||||
if (dwrlines2x == null || dwrlines2x.getEntries().isEmpty()) {
|
||||
throw new NoRouteToHostException("address unreachable: " + addr);
|
||||
}
|
||||
|
||||
List<KLALBRemoteLine>lines2x=dwrlines2x.roundEntriesList();
|
||||
|
||||
int count0 = Math.min(count, lines2x.size());
|
||||
|
||||
for (int i = 0; i < lines2x.size(); i++) {
|
||||
KLALBRemoteLine krst =lines2x.get(i);
|
||||
if(krst.getMonitor().getState()==MonitorData.ONLINE)
|
||||
if(!packet.getSendRecord().contains(krst)) {
|
||||
if(krst.getQueue().size()<5) {
|
||||
packet.getSendRecord().add(krst);
|
||||
//System.out.println(krst);
|
||||
krst.sendPacket(packet);
|
||||
count0--;
|
||||
if (count0 <= 0)
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < lines2x.size(); i++) {
|
||||
KLALBRemoteLine krst =lines2x.get(i);
|
||||
if(krst.getMonitor().getState()==MonitorData.ONLINE)
|
||||
if(packet.getSendRecord().contains(krst)) {
|
||||
if(krst.getQueue().size()<5) {
|
||||
packet.getSendRecord().add(krst);
|
||||
//System.out.println(krst);
|
||||
krst.sendPacket(packet);
|
||||
count0--;
|
||||
if (count0 <= 0)
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
LockSupport.parkNanos(50000);
|
||||
//tdb.putTime("sendfailed");
|
||||
}*/
|
||||
}
|
||||
//private Map<Inet6Address, DWRRLoadingBalanceAlgorithm<KLALBRemoteLine>> lines2 = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
|
||||
@@ -804,11 +728,8 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
HighPerformanceExecutor.defaultExecutor.execute(()->{
|
||||
|
||||
IPv6Packet ipv=new IPv6Packet();
|
||||
packet.getDisposeLock().lock();
|
||||
try {
|
||||
if(packet.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(showpacket)
|
||||
System.out.println("KLALB_TX:"+packet);
|
||||
|
||||
@@ -816,10 +737,15 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
ipv.setTrafficClass(0);
|
||||
ipv.setFlowLabel(flowlabel);
|
||||
ipv.setHopLimit(255);
|
||||
ipv.setSourceAddress(self.getAddress());
|
||||
ipv.setSourceAddress(getSelf().getAddress());
|
||||
ipv.setDestinationAddress(addr);
|
||||
ipv.setPriority(packet.getPriority());
|
||||
if(packet instanceof DATATPacket) {
|
||||
ipv.setPromise(true);
|
||||
}
|
||||
ipv.enableECN();
|
||||
/* if(b)
|
||||
ipv.markCE();*/
|
||||
ipv.setPayload(packet);
|
||||
//System.out.println(ipv.getPayload().getProtocolNumber());
|
||||
/*System.out.println("SND:"+ipv.getPayload().getData());
|
||||
@@ -828,13 +754,12 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
System.out.println(Arrays.toString(b));*/
|
||||
//packet.getSendRecord().add(null);
|
||||
packet.incSendCounter();
|
||||
}finally {
|
||||
packet.getDisposeLock().unlock();
|
||||
}
|
||||
|
||||
packet.putTimePassport("packedInIPv6");
|
||||
packet.printPassport();
|
||||
ipv.putTimePassport("packed");
|
||||
srv6Router.putProtocolNumberPacketAndInsertSRH(ipv);
|
||||
srv6Router.insertSRHandRoutePacket(ipv);
|
||||
//srv6Router.putProtocolNumberPacketAndInsertSRHAsync(ipv);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -869,7 +794,11 @@ private Timer trtr=new Timer("路由表刷新计时器", true);
|
||||
try {
|
||||
BandwidthDistributer<PortPair> bdr= bandwidthDistrmap.get(targetaAddress);
|
||||
if(bdr==null) {
|
||||
bandwidthDistrmap.put(targetaAddress, bdr=new BandwidthDistributer<>(1024*20000L*1024));
|
||||
bdr=new BandwidthDistributer<>(1024*20000L*1024);
|
||||
bdr.setTotalRequestUpdateConsumer((treq)->{
|
||||
KLALBRoutingProtocol krp= srv6Router.getKlalbRouteProtol();
|
||||
krp.updateTotalRequestBandwidth(targetaAddress,treq);});
|
||||
bandwidthDistrmap.put(targetaAddress, bdr);
|
||||
}
|
||||
|
||||
bdr.setDistrUpdateConsumer(portp, updateConsumer);
|
||||
@@ -920,7 +849,6 @@ private List<MultipurposeSocketAddress> listens=new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*@Override
|
||||
public void listen(MultipurposeSocketAddress msa) {
|
||||
// TODO 自动生成的方法存根
|
||||
|
||||
Reference in New Issue
Block a user