[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ARP.java, 1.8, 1.9 ProtocolStack.java, 1.59,
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26945/core/protocolsuite/tcp_ip Modified Files: ARP.java ProtocolStack.java SNMP.java TCP_session.java Tcp.java Telnet_server.java Udp.java Log Message: Some console commands was corrected Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Udp.java 14 Oct 2007 17:19:07 -0000 1.41 --- Udp.java 14 Oct 2007 22:14:52 -0000 1.42 *************** *** 225,229 **** String sessionID; boolean Found=false; ! Enumeration LocalSessions = getSessionKeys(); --- 225,229 ---- String sessionID; boolean Found=false; ! Enumeration<String> LocalSessions = getSessionKeys(); *************** *** 233,237 **** while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = (String)LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && Elm.sock >=0 ) --- 233,237 ---- while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && Elm.sock >=0 ) *************** *** 372,376 **** } ! private UDP_session getSession(String key){ UDP_session udps; synchronized(sessionTable_lock){ --- 372,376 ---- } ! public UDP_session getSession(String key){ UDP_session udps; synchronized(sessionTable_lock){ *************** *** 380,385 **** } ! private Enumeration getSessionKeys(){ ! Enumeration keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); --- 380,385 ---- } ! public Enumeration<String> getSessionKeys(){ ! Enumeration<String> keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Telnet_server.java 1 Oct 2007 04:58:12 -0000 1.17 --- Telnet_server.java 14 Oct 2007 22:14:52 -0000 1.18 *************** *** 379,386 **** if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! String ArpTable[] = mParentStack.getARPTable(); ! for(int i=0;i<ArpTable.length;i++) ! { ! out += ArpTable[i] + "\r\n"; } } --- 379,392 ---- if((m=Pattern.compile(" +-a$").matcher(cmd)).find()) { try{ ! Vector<Vector<String>> ArpTable = mParentStack.getARPTable(); ! if(ArpTable.size()>0){ ! out += "Internet Address\tPhysical Address\t\tType\r\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! out += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\r\n"; ! } ! } ! else{ ! out += "No ARP Entries Found\r\n"; } } Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** ProtocolStack.java 14 Oct 2007 17:19:07 -0000 1.59 --- ProtocolStack.java 14 Oct 2007 22:14:52 -0000 1.60 *************** *** 61,66 **** import java.io.Serializable; - import core.protocolsuite.tcp_ip.ICMP_packet; - import core.InvalidNetworkInterfaceNameException; --- 61,64 ---- *************** *** 73,83 **** import core.*; - import java.util.Timer; - - import java.util.TimerTask; - import java.util.ArrayList; ! ! import core.Error; --- 71,76 ---- import core.*; import java.util.ArrayList; ! import java.util.Vector; *************** *** 638,642 **** * @author robert_hulford ! * @return String[] - The arp table entries * @version v0.20 --- 631,635 ---- * @author robert_hulford ! * @return Vector<Vector<String>> - The arp table entries * @version v0.20 *************** *** 644,648 **** */ ! public String[] getARPTable() { return mARPprotocol.getARPTable(); --- 637,641 ---- */ ! public Vector<Vector<String>> getARPTable() { return mARPprotocol.getARPTable(); Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** Tcp.java 14 Oct 2007 17:19:07 -0000 1.100 --- Tcp.java 14 Oct 2007 22:14:52 -0000 1.101 *************** *** 241,244 **** --- 241,245 ---- private Timer timer; private PriorityQueue tcp_timers = new PriorityQueue(); + private int window_size = 10; //tcp window-size for new sessions private Object tcp_timers_lock = new Object(); //for locking queue tcp_timers private int current_time = 0; *************** *** 333,337 **** String sessionID; boolean Found=false; ! Enumeration LocalSessions = getSessionKeys(); TCP_session Elm; --- 334,338 ---- String sessionID; boolean Found=false; ! Enumeration<String> LocalSessions = getSessionKeys(); TCP_session Elm; *************** *** 339,343 **** while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = (String)LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && mSL.get_socket(Elm.sock).open_state ) --- 340,344 ---- while ( (LocalSessions.hasMoreElements()) && !(Found) ) { ! sessionID = LocalSessions.nextElement(); Elm = getSession(sessionID); if ( sock == Elm.sock && mSL.get_socket(Elm.sock).open_state ) *************** *** 794,797 **** --- 795,813 ---- } + public int getWindowSize(){ + return window_size; + } + + public void setWindowSize(int windowSize){ + if(windowSize>0){ + window_size = windowSize; + Enumeration<String> keys = getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + getSession(key).setWindowSize(windowSize); + } + } + } + private void recv_CLOSED(TCP_session Elm, TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { *************** *** 1037,1040 **** --- 1053,1057 ---- private TCP_session addSession(String key, int sock){ TCP_session tcps = new TCP_session(sock); + tcps.setWindowSize(window_size); synchronized(sessionTable_lock){ sessionTable.put(key, tcps); *************** *** 1053,1057 **** } ! private TCP_session getSession(String key){ TCP_session tcps; synchronized(sessionTable_lock){ --- 1070,1074 ---- } ! public TCP_session getSession(String key){ TCP_session tcps; synchronized(sessionTable_lock){ *************** *** 1061,1066 **** } ! private Enumeration getSessionKeys(){ ! Enumeration keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); --- 1078,1083 ---- } ! public Enumeration<String> getSessionKeys(){ ! Enumeration<String> keys; synchronized(sessionTable_lock){ keys = sessionTable.keys(); Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ARP.java 13 Oct 2007 12:57:00 -0000 1.8 --- ARP.java 14 Oct 2007 22:14:52 -0000 1.9 *************** *** 233,237 **** * @author bevan_calliess ! * @return String Array - An array of strings that can be used to display the ARP table. * @version v0.20 --- 233,237 ---- * @author bevan_calliess ! * @return Vector<Vector<String>> - An array of strings that can be used to display the ARP table. Format (Internet Address,Physical Address,Type) * @version v0.20 *************** *** 239,243 **** */ ! public String[] getARPTable() { --- 239,243 ---- */ ! public Vector<Vector<String>> getARPTable() { *************** *** 246,292 **** cleanARPTable(); - ! ! String output[] = new String[ARPTable.size()+1]; ! int counter = 0; - String ipAddress; - char padding = ' '; - - if(ARPTable.size()>0){ - - output[0] = "Internet Address Physical Address Type"; - - - Iterator it = ARPTable.iterator(); - while(it.hasNext()) { - counter++; - ARPTableEntry currEnt = (ARPTableEntry)it.next(); - ipAddress = pad(currEnt.getIPAddress(),20,padding); ! ! output[counter] = ipAddress + currEnt.getMACAddress() + " " + currEnt.getEntryType(); ! } - }else{ ! ! output[0] = "No ARP Entries Found"; ! } - - return output; --- 246,273 ---- cleanARPTable(); ! Vector<Vector<String>> output = new Vector<Vector<String>>(0); int counter = 0; String ipAddress; char padding = ' '; if(ARPTable.size()>0){ Iterator it = ARPTable.iterator(); while(it.hasNext()) { counter++; ARPTableEntry currEnt = (ARPTableEntry)it.next(); ipAddress = pad(currEnt.getIPAddress(),20,padding); ! Vector<String> outrecord = new Vector<String>(3); ! output.add(outrecord); ! outrecord.add(ipAddress); ! outrecord.add(currEnt.getMACAddress()); ! outrecord.add(currEnt.getEntryType()); } }else{ ! //output.size() == 0 -- arp table is empty } return output; Index: TCP_session.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_session.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TCP_session.java 1 Oct 2007 04:58:12 -0000 1.9 --- TCP_session.java 14 Oct 2007 22:14:52 -0000 1.10 *************** *** 253,256 **** --- 253,275 ---- } + public String getStateString(){ + String out; + switch(getState()){ + case CLOSED: out = "CLOSED"; break; + case LISTEN: out = "LISTEN"; break; + case SYN_SENT: out = "SYN_SENT"; break; + case SYN_RCVD: out = "SYN_RCVD"; break; + case ESTABLISHED: out = "ESTABLISHED"; break; + case FIN_WAIT_1: out = "FIN_WAIT_1"; break; + case FIN_WAIT_2: out = "FIN_WAIT_2"; break; + case CLOSING: out = "CLOSING"; break; + case TIME_WAIT: out = "TIME_WAIT"; break; + case CLOSE_WAIT: out = "CLOSE_WAIT"; break; + case LAST_ACK: out = "LAST_ACK"; break; + default: out = ""; + } + return out; + } + public void setState(int stt){ if(stt >=0 && stt <= 10) Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SNMP.java 12 Oct 2007 21:06:39 -0000 1.22 --- SNMP.java 14 Oct 2007 22:14:52 -0000 1.23 *************** *** 1175,1182 **** //"IP.ARPTable" str=""; ! stra = ((NetworkLayerDevice)current_device).getARPTable(); ! for(int i=1;i<stra.length;i++) { ! if(i!=1) str+=", "; ! str+=stra[i]; } getIDbyName("IP", "ARPTable"); --- 1175,1182 ---- //"IP.ARPTable" str=""; ! Vector<Vector<String>> ArpTable = ((NetworkLayerDevice)current_device).getARPTable(); ! for(int i=0;i<ArpTable.size();i++) { ! if(i!=0) str+=", "; ! str += ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2); } getIDbyName("IP", "ARPTable"); |