91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6.26 KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2024-10-16
  • 語言: Java
  • 標簽: JAVA??最短路徑??

資源簡介

Java平臺上的距離向量路由協議的模擬程序。提供給定的配置文件(ConfigA.txt,包含相鄰路由的端口號和距離)時,自動計算出網絡中到達各個路由的距離。當路由掛起或關閉時,其它路由可以檢測到路由點的消失并重新計算距離

資源截圖

代碼片段和文件信息

import?java.io.*;
import?java.net.*;

class?dv_routing{
static?int?maxNodeNumber=30;//?the?maximum?possible?node?number?in?the?network
static?int?basicPauseTime=1000;
public?static?void?main(String[]?args){

//thread?sending?part
class?sendUDP?extends?Thread{
private?int?sendCount=0;
private?int?neighborCount=0;
private?char?myName;
private?int?myPort;

private?int?sendPortList[]=new?int[maxNodeNumber];

private?char?sendNodeList[]=new?char[maxNodeNumber];
private?int?sendMinList[]=new?int[maxNodeNumber];

private?char?buffNodeList[]=new?char[maxNodeNumber];
private?int?buffMinList[]=new?int[maxNodeNumber];

private?char?sendSentence[]=new?char[1024];
private?String?sendString;
private?byte?sendByte[];

public?void?setMyName(char?name){
myName=name;
}

public?void?setMyPort(int?port){
myPort=port;
}


public?void?setCount(int?myCount){
sendCount=myCount;
//System.out.println(sendCount);
}

public?void?setNeighbor(int?myNeighbor){
neighborCount=myNeighbor;
}

public?void?setNode(char?myNodeList[]){
sendNodeList=myNodeList;
}

public?void?setPort(int?myPortList[]){
sendPortList=myPortList;
}

public?void?setMin(int?myMinList[]){
sendMinList=myMinList;
}

public?int[]?getMin(){
return?sendMinList;
}

public?void?run(){
try{
DatagramSocket?sendSocket?=?new?DatagramSocket();
while(true){
sendSentence=new?char[1024];//reset

//sendSentence:?A?2?B?0001?C?0002?z

//A
int?cursor=0;
//System.out.println(myName);
sendSentence[cursor]=myName;

//2
cursor=1;
//System.out.println(sendCount+“?“+(char)sendCount);
sendSentence[cursor]=(char)(sendCount+48);

buffNodeList=new?char[maxNodeNumber];
buffMinList=new?int[maxNodeNumber];

buffNodeList=sendNodeList;
buffMinList=sendMinList;

cursor=2;
String?hexString=null;
char?hexChar[]=new?char[4];

//B?0002
for(int?j=0;?j //B
sendSentence[cursor]=buffNodeList[j];
cursor++;

//0002
hexString=Integer.toHexString(buffMinList[j]);

//000
for(int?k=0;?k<4-hexString.length();?k++){
sendSentence[cursor]=‘0‘;
cursor++;
}

//2
for(int?k=0;k sendSentence[cursor]=hexString.charAt(k);
cursor++;
}

}

//z
sendSentence[cursor]=‘z‘;//simple?terminate?check

sendByte=null;
sendString=null;
sendString=String.valueOf(sendSentence);
sendByte=sendString.getBytes();



InetAddress?IPAddress=InetAddress.getLocalHost();

for(int?i=0;?i int?tarPort=se

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????????20??2014-05-07?20:40??configF.txt

?????文件??????25504??2014-06-05?21:54??dv_routing.java

?????文件?????????30??2014-06-04?20:06??configA.txt

?????文件?????????29??2014-06-04?20:06??configB.txt

?????文件?????????48??2014-06-04?20:06??configC.txt

?????文件?????????38??2014-06-04?20:07??configD.txt

?????文件?????????29??2014-05-07?20:40??configE.txt

-----------?---------??----------?-----??----

????????????????25698????????????????????7


評論

共有 條評論