正式版V1.0

This commit is contained in:
Administrator
2023-01-07 07:04:09 +08:00
parent ea97e3891f
commit a9a4ad7c21
7 changed files with 65 additions and 60 deletions
+6 -17
View File
@@ -14,24 +14,13 @@
"localaddress" : "127.0.0.1:3389" "localaddress" : "127.0.0.1:3389"
} ], } ],
"tunnels" : [ { "tunnels" : [ {
"name" : "Openfrp-直连线路",
"remoteaddress" : "127.0.0.1:4566"
}, {
"name" : "Openfrp-直连线路", "name" : "Openfrp-直连线路",
"remoteaddress" : "127.0.0.1:4566", "remoteaddress" : "127.0.0.1:4566",
"frpc":[ "[common]", "frpc" : [ "[common]", "server_addr = 180.76.147.250", "server_port = 8120", "tcp_mux = true", "protocol = tcp", "dns_server = 223.5.5.5", "user = bb28264e0abf3bcbec3a2180c5a279b8", "token = I2KMo1HvRxuvurv2", "[ts1xx]", "type = xtcp", "role = visitor", "server_name = zl1", "bind_addr = 127.0.0.1", "bind_port = 4566", "sk = knecloud" ]
"server_addr = 180.76.147.250", }, {
"server_port = 8120",
"tcp_mux = true",
"protocol = tcp",
"dns_server = 223.5.5.5",
"user = bb28264e0abf3bcbec3a2180c5a279b8",
"token = I2KMo1HvRxuvurv2",
"[ts1xx]",
"type = xtcp",
"role = visitor",
"server_name = zl1",
"bind_addr = 127.0.0.1",
"bind_port = 4566",
"sk = knecloud"]
},{
"name" : "NULL-宿迁联通", "name" : "NULL-宿迁联通",
"remoteaddress" : "153.36.240.12:65529" "remoteaddress" : "153.36.240.12:65529"
}, { }, {
@@ -61,5 +50,5 @@
}, { }, {
"name" : "HYHBX-上海腾讯-2", "name" : "HYHBX-上海腾讯-2",
"remoteaddress" : "43.143.109.64:49965" "remoteaddress" : "43.143.109.64:49965"
}] } ]
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package org.kne.cloud.network.klalb;
public class Consts { public class Consts {
public static final int BLOCKSIZE=8192; public static final int BLOCKSIZE=8192;
public static final long PINGTIMENS=1000000000L; public static final long PINGTIMENS=1000000000L;
public static final int SO_TIMEOUT = 20000; public static final int SO_TIMEOUT = 10000;
public static final long SN_KEEP = 60000000000L; public static final long SN_KEEP = 60000000000L;
public static final int MAX_RESEND = 100; public static final int MAX_RESEND = 100;
public static final long UACK_TIME = 10000000000L; public static final long UACK_TIME = 10000000000L;
@@ -22,7 +22,7 @@ import org.kne.cloud.network.mport.ServiceElement;
import org.kne.cloud.network.mport.ThreadTool; import org.kne.cloud.network.mport.ThreadTool;
public class IOThreadManager { public class IOThreadManager {
private KLALBCore klc = new KLALBCore(2000); private KLALBCore klc = new KLALBCore(5000);
private volatile boolean isopen = true; private volatile boolean isopen = true;
public IOThreadManager() { public IOThreadManager() {
@@ -247,7 +247,7 @@ public class KLALBClientGUI extends XFrame {
} }
}); });
panel_1.add(btnNewButton_1, BorderLayout.EAST); panel_1.add(btnNewButton_1, BorderLayout.EAST);
setTitle("KNE云网络负载均衡客户端"); setTitle("KNE云网络负载均衡客户端V1.0");
setSize(600, 370); setSize(600, 370);
setLocationRelativeTo(null); setLocationRelativeTo(null);
+32 -32
View File
@@ -109,7 +109,7 @@ public class KLALBCore {
pdb.pingtime=System.nanoTime(); pdb.pingtime=System.nanoTime();
tc.sendBlock(pdb); tc.sendBlock(pdb);
} }
if(!tc.getNDSendDeque().isEmpty()||!tc.getSendDeque().isEmpty()||!tc.getReSendDeque().isEmpty()) if(!tc.getNDSendDeque().isEmpty()||!tc.getSendDeque().isEmpty())
break; break;
synchronized (tc.getSendDeque()) { synchronized (tc.getSendDeque()) {
tc.getSendDeque().wait(10); tc.getSendDeque().wait(10);
@@ -122,16 +122,13 @@ public class KLALBCore {
} }
tc.sendBlock(k0); tc.sendBlock(k0);
}else { }else {
KLALBBlock k1=tc.getReSendDeque().poll();
if(k1!=null) {
tc.sendBlock(k1);
}else {
KLALBBlock k=tc.getSendDeque().poll(); KLALBBlock k=tc.getSendDeque().poll();
if(k!=null) { if(k!=null) {
//if(localtcps.containsKey(k.cuid)||k.cuid.equals(ZERO_UUID)) //if(localtcps.containsKey(k.cuid)||k.cuid.equals(ZERO_UUID))
tc.sendBlock(k); tc.sendBlock(k);
} }
}
} }
} }
public void remoteReceive(RemoteTCPConnection tc) throws IOException { public void remoteReceive(RemoteTCPConnection tc) throws IOException {
@@ -224,7 +221,7 @@ public class KLALBCore {
ack.cuid=brc.cuid; ack.cuid=brc.cuid;
ack.number=-brc.number; ack.number=-brc.number;
ack.cacheused=ltcs.getSendDeque().size(); ack.cacheused=ltcs.getSendDeque().size();
submitAckBlockNoDelay(ack,3); submitAckBlockNoDelay(ack,5);
} }
@@ -246,6 +243,16 @@ public class KLALBCore {
} }
} }
} }
synchronized (remotetcps) {
for (Iterator<RemoteTCPConnection> iterator = remotetcps.iterator(); iterator.hasNext();) {
RemoteTCPConnection remoteTCPConnection = (RemoteTCPConnection) iterator.next();
Queue<KLALBBlock>sq=remoteTCPConnection.getSendDeque();
sq.removeIf((vb)->{
return vb.number==nx;
});
}
}
/*ltc.getOutputcache().removeIf((b) -> { /*ltc.getOutputcache().removeIf((b) -> {
return b.number == nx; return b.number == nx;
});*/ });*/
@@ -265,7 +272,7 @@ public class KLALBCore {
for (Iterator<RemoteTCPConnection> iterator = remotetcps.iterator(); iterator.hasNext();) { for (Iterator<RemoteTCPConnection> iterator = remotetcps.iterator(); iterator.hasNext();) {
RemoteTCPConnection remoteTCPConnection = (RemoteTCPConnection) iterator.next(); RemoteTCPConnection remoteTCPConnection = (RemoteTCPConnection) iterator.next();
Queue<KLALBBlock> bdq=remoteTCPConnection.getSendDeque(); Queue<KLALBBlock> bdq=remoteTCPConnection.getSendDeque();
if(bdq.size()<1) { if(bdq.size()<2) {
bdq.add(kb); bdq.add(kb);
synchronized (bdq) { synchronized (bdq) {
bdq.notifyAll(); bdq.notifyAll();
@@ -279,25 +286,6 @@ public class KLALBCore {
Thread.sleep(1); Thread.sleep(1);
} }
}
public void submitReDataBlock(KLALBBlock kb) throws InterruptedException {
while(true) {
synchronized (remotetcps) {
for (Iterator<RemoteTCPConnection> iterator = remotetcps.iterator(); iterator.hasNext();) {
RemoteTCPConnection remoteTCPConnection = (RemoteTCPConnection) iterator.next();
Queue<KLALBBlock> bdq=remoteTCPConnection.getReSendDeque();
if(bdq.size()<1) {
bdq.add(kb);
synchronized (bdq) {
bdq.notifyAll();
}
return;
}
}
}
Thread.sleep(1);
}
} }
public void submitDataBlockNoDelay(KLALBBlock kb) { public void submitDataBlockNoDelay(KLALBBlock kb) {
synchronized (remotetcps) { synchronized (remotetcps) {
@@ -368,17 +356,29 @@ public class KLALBCore {
synchronized( l) { synchronized( l) {
for (int i = 0; i < l.size(); i++) { for (int i = 0; i < l.size(); i++) {
KLALBBlock block=l.get(i); KLALBBlock block=l.get(i);
long timex = (System.nanoTime() - block.sendtime) / 1000000; long timex = System.nanoTime() - block.sendtime;
if ((i==0&&timex>100)||timex > (RTO/1000000)*(1<<Math.min(8,block.resend))+2000*i) { if(i<10) {
submitReDataBlock(block); if(timex > Math.min(RTO,1000000000L )*(1<<Math.min(8,block.resend))+200*i) {
submitDataBlock(block);
block.sendtime = System.nanoTime();
System.out.println("超时重传:"+block+" 位置:"+i);
block.resend++;
if(block.resend>=Consts.MAX_RESEND) {
l.remove(i);
i--;
}
}
}
/*if ((i<=10&&timex>500)||timex > (RTO/1000000)*(1<<Math.min(8,block.resend))+2000*i) {
submitDataBlock(block);
block.sendtime = System.nanoTime(); block.sendtime = System.nanoTime();
System.out.println("超时重传:"+block+" 位置:"+i);
block.resend++; block.resend++;
if(block.resend>=Consts.MAX_RESEND) { if(block.resend>=Consts.MAX_RESEND) {
l.remove(i); l.remove(i);
i--; i--;
} }
System.out.println("超时重传:"+block+" 位置:"+i); }*/
}
} }
} }
long curr=System.nanoTime(); long curr=System.nanoTime();
+1 -1
View File
@@ -17,7 +17,7 @@ import org.kne.cloud.network.mport.ServiceElement;
public class KLALBSM { public class KLALBSM {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
System.out.println("KNE云负载均衡调度软件服务端V0.1"); System.out.println("KNE云负载均衡调度软件服务端V1.0");
ServerPropties sp=new ServerPropties(); ServerPropties sp=new ServerPropties();
int remp=sp.getPort(); int remp=sp.getPort();
@@ -11,6 +11,7 @@ import java.io.StreamCorruptedException;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.Queue; import java.util.Queue;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@@ -19,6 +20,7 @@ import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.zip.DataFormatException; import java.util.zip.DataFormatException;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@@ -243,17 +245,31 @@ public class RemoteTCPConnection extends TCPConnection {
} }
} }
private Queue<KLALBBlock> NDsendDeque = new ConcurrentLinkedQueue<>(); private Queue<KLALBBlock> NDsendDeque = new ConcurrentLinkedQueue<KLALBBlock>();
public Queue<KLALBBlock> getNDSendDeque() { public Queue<KLALBBlock> getNDSendDeque() {
return NDsendDeque; return NDsendDeque;
} }
private Queue<KLALBBlock> resendDeque = new ConcurrentLinkedQueue<>();
public Queue<KLALBBlock> getReSendDeque() { private Queue<KLALBBlock> sendDeque = new PriorityBlockingQueue<KLALBBlock>(2, new Comparator<KLALBBlock>() {
return sendDeque;
} @Override
private Queue<KLALBBlock> sendDeque = new ConcurrentLinkedQueue<>(); public int compare(KLALBBlock o1, KLALBBlock o2) {
if(o1.resend>o2.resend) {
return -1;
}else if(o1.resend<o2.resend) {
return 1;
}else {
if(o1.number>o2.number) {
return 1;
}else if(o1.number<o2.number) {
return -1;
}else {
return 0;
}
}
}
});
public Queue<KLALBBlock> getSendDeque() { public Queue<KLALBBlock> getSendDeque() {
return sendDeque; return sendDeque;