[Javanetsim-cvs] javaNetSim/core DataLinkLayerDevice.java, 1.7, 1.8 MultilayerSwitch.java, 1.3, 1.4
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2008-10-21 11:50:36
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14781/core Modified Files: DataLinkLayerDevice.java MultilayerSwitch.java NetworkLayerDevice.java Node.java Simulation.java Switch.java Log Message: Refactoring of Simulation. Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Node.java 17 Oct 2008 09:10:16 -0000 1.28 --- Node.java 21 Oct 2008 11:50:24 -0000 1.29 *************** *** 120,127 **** */ ! ! protected java.util.Hashtable NetworkInterfacetable = null; //Hashtable of network interfaces public ProtocolStack NodeProtocolStack; protected String name; --- 120,131 ---- */ ! ! protected java.util.Hashtable NetworkInterfacetable = null; //Hashtable of network interfaces public ProtocolStack NodeProtocolStack; + + public ProtocolStack getProtocolStack(){ + return NodeProtocolStack; + } protected String name; *************** *** 557,560 **** --- 561,581 ---- } + + public Object[] getAllInterfaces(){ + + ArrayList<String> interfaceArray = new ArrayList<String>(); + Enumeration keys = NetworkInterfacetable.keys(); + while(keys.hasMoreElements()){ + String str = (String) keys.nextElement(); + NetworkInterface x = (NetworkInterface)NetworkInterfacetable.get(str); + interfaceArray.add(x.getName()); + } + + return interfaceArray.toArray(); + } + + public void execCmd(String cmd){ + System.out.println("WRANING: Cannot execute " + cmd + " for " + getName() + "."); + } Index: MultilayerSwitch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/MultilayerSwitch.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MultilayerSwitch.java 20 Oct 2008 23:46:56 -0000 1.3 --- MultilayerSwitch.java 21 Oct 2008 11:50:24 -0000 1.4 *************** *** 114,117 **** --- 114,118 ---- outInt.clear(); } + super.Reset(); } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Simulation.java 19 Oct 2008 21:40:19 -0000 1.33 --- Simulation.java 21 Oct 2008 11:50:24 -0000 1.34 *************** *** 37,100 **** import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; - /** - * <P>The Simulation is the main class in the Network Simulator system.</P> - * - * <P>It is a container class for Nodes, Links, a script and a LayerInfoHandler. The - * Simulation manages and controls all of these objects and provides public methods - * that a GUI or CLI can use to manipulate those objects and the objects contained within - * those objects (the Nodes and Links)</P> - * - * <P>Any public method in this class is to be used by a GUI or CLI. New methods - * will need to be added when a GUI or CLI requires them.</P> - * - * <P>Many of the methods in this class return an object type. When designing a GUI don't get confused by - * the fact you can simply use that object reference to directly talk with the object. - * The object references being returned were originally meant for the GUI to use to - * pass back the reference to the Simulation which can then directly (and more efficiently) - * talk with that object. For example when calling the Simulation method:</P> - * - * <BLOCKQUOTE><BLOCKQUOTE><P><I>PC addPC(String inNodeName)</I></P></BLOCKQUOTE></BLOCKQUOTE> - * - * The PC reference returned by the method can be stored by the GUI, but the GUI should - * never call methods on that PC object itself. Rather, it should pass that PC reference back - * to the Simulation when wanting to call a PC or Node method such as: - * - * <BLOCKQUOTE><BLOCKQUOTE><P><I>NetworkInterface addInterface(String inNetworkInterfaceName)</I></P></BLOCKQUOTE></BLOCKQUOTE> - * - * The GUI should instead call the Simulation method: - * - * <BLOCKQUOTE><BLOCKQUOTE><P><I>NetworkInterface addInterface(String interfaceName, String nodeName)</I></P></BLOCKQUOTE></BLOCKQUOTE> - * - * We have an overloaded method of the above in the Simulation: - * - * <BLOCKQUOTE><BLOCKQUOTE><P><I>NetworkInterface addInterface(String interfaceName, Node node)</I></P></BLOCKQUOTE></BLOCKQUOTE> - * - * <P>Note that you pass a Node object reference as opposed to a String. The latter method - * will process faster because it has a direct reference and does not need to loop through - * the Simulation's list of Nodes.</P> - * - * <P>To reiterate, the GUI should NEVER call any method on any class contained in the Network - * Simulator package except for the Simulation class. The only other classes exempt from this rule - * are the LayerInfo and IPV4Address classes. See the {@link LayerInfo LayerInfo} - * and {@link IPV4Address IPV4Address} classes for more information.</P> - * - * - * @author tristan_veness (Original Author) - * @author luke_hamilton - * @author angela_brown - * @author michael_reith - * @author robert_hulford - * @author bevan_calliess - * @since 13 June 2004 - * @version v0.20 - */ - - /* Note: Future groups might like to change the return types of some of the methods in the Simulation - * so that they do not return an object to the GUI and simply return an error code or throw - * an exception instead. You could create a more efficient method for retrieving Objects - * by replacing the Vectors with more efficient storage classes like binary trees or hash tables. - * See the java class named TreeMap. - */ - public class Simulation implements Serializable { --- 37,40 ---- *************** *** 203,207 **** **/ //TODO I think this should also throw an invalidNetInterfaceNameException. -Luke hamilton ! public String getSubnetMask(String inNodeName, String inInterface)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); --- 143,147 ---- **/ //TODO I think this should also throw an invalidNetInterfaceNameException. -Luke hamilton ! /*public String getSubnetMask(String inNodeName, String inInterface)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); *************** *** 213,223 **** } throw new InvalidNodeNameException("Node does not exist."); ! } ! public core.protocolsuite.tcp_ip.ProtocolStack getTCPProtocolStack(String inNodeName) { Node temp = (Node)nodeTable.get(inNodeName); return (core.protocolsuite.tcp_ip.ProtocolStack)temp.NodeProtocolStack; ! } /** * This method is called from the GUI. Checks to see if inNodeName is an instance of networkLayerDevice, --- 153,163 ---- } throw new InvalidNodeNameException("Node does not exist."); ! }*/ ! /* public core.protocolsuite.tcp_ip.ProtocolStack getTCPProtocolStack(String inNodeName) { Node temp = (Node)nodeTable.get(inNodeName); return (core.protocolsuite.tcp_ip.ProtocolStack)temp.NodeProtocolStack; ! }*/ /** * This method is called from the GUI. Checks to see if inNodeName is an instance of networkLayerDevice, *************** *** 231,235 **** * @version v0.20 **/ ! public String getIpAddressForInterface(String inNodeName, String inInterface) throws InvalidNetworkInterfaceNameException, InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); --- 171,175 ---- * @version v0.20 **/ ! /*public String getIpAddressForInterface(String inNodeName, String inInterface) throws InvalidNetworkInterfaceNameException, InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); *************** *** 241,245 **** } throw new InvalidNodeNameException("Node does not exist."); ! } /** --- 181,185 ---- } throw new InvalidNodeNameException("Node does not exist."); ! }*/ /** *************** *** 254,258 **** * @version v0.20 **/ ! public String getMacAddressForInterface(String inNodeName, String inInterface) throws InvalidNetworkInterfaceNameException, InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); --- 194,198 ---- * @version v0.20 **/ ! /*public String getMacAddressForInterface(String inNodeName, String inInterface) throws InvalidNetworkInterfaceNameException, InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); *************** *** 264,268 **** } throw new InvalidNodeNameException("Node does not exist."); ! } /** --- 204,208 ---- } throw new InvalidNodeNameException("Node does not exist."); ! }*/ /** *************** *** 296,300 **** //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! comment && doc this ! public Node getNode(String inNodeName) throws InvalidNodeNameException{ return (Node)nodeTable.get(inNodeName); } --- 236,240 ---- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! comment && doc this ! public Node getNode(String inNodeName){ return (Node)nodeTable.get(inNodeName); } *************** *** 312,316 **** **/ ! public String getDefaultGateway(String inNodeName)throws InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); --- 252,256 ---- **/ ! /*public String getDefaultGateway(String inNodeName)throws InvalidNodeNameException, InvalidNetworkLayerDeviceException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); *************** *** 322,370 **** } throw new InvalidNodeNameException("Node does not exist."); ! } ! /** ! * This method is called from the TEXTUI or GUI. If inNodeName is contained within the hash ! * table (nodeTable) typecast it to a Node and check if it is an instance of the NetworkLayerDevice. ! * If so, type cast node to a NetworkLayerDevice and get it details from the arp table in the ! * NetworkLayerDevice level. ! * @author bevan_calliess ! * @author robert_hulford ! * @param inNodeName - The Name of the Node eg: pc1 ! * @return arpEntries ! * @throws InvalidNetworkLayerDeviceException ! * @throws InvalidNodeNameException ! * @version v0.20 ! **/ ! public String[] getARPTable(String inNodeName) throws InvalidNetworkLayerDeviceException, InvalidNodeNameException ! { ! String[] arpEntries; ! if(nodeTable.containsKey(inNodeName)){ ! Node tempNode = (Node)nodeTable.get(inNodeName); ! if (tempNode instanceof NetworkLayerDevice)//test if device is a network layer device ! { ! NetworkLayerDevice t = (NetworkLayerDevice)tempNode; ! Vector<Vector<String>> ArpTable = t.getARPTable(); ! arpEntries = new String[ArpTable.size()+1]; ! if(ArpTable.size()>0){ ! arpEntries[0] = "Internet Address\tPhysical Address\t\tType\n"; ! for(int i=0;i<ArpTable.size();i++) ! { ! arpEntries[i+1] = ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; ! } ! } ! else{ ! arpEntries[0] = "No ARP Entries Found\n"; ! } ! }else ! { ! throw new InvalidNetworkLayerDeviceException("This device is not a network layered device"); ! } ! }else{ ! throw new InvalidNodeNameException("Node does not exist"); ! } ! ! return arpEntries; ! } /** * This method is called from the TEXTUI or GUI. if inNodeName is contained within the hash table (nodeTable) --- 262,268 ---- } throw new InvalidNodeNameException("Node does not exist."); ! }*/ ! /** * This method is called from the TEXTUI or GUI. if inNodeName is contained within the hash table (nodeTable) *************** *** 381,385 **** * @version v0.20 **/ ! public void setCustomSubnetMask(String inNodeName,String inInterface,String inCustomSubnetMask)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException, InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { if (nodeTable.containsKey(inNodeName)){ // try{ --- 279,283 ---- * @version v0.20 **/ ! /*public void setCustomSubnetMask(String inNodeName,String inInterface,String inCustomSubnetMask)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException, InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { if (nodeTable.containsKey(inNodeName)){ // try{ *************** *** 389,394 **** NetworkLayerDevice nld = (NetworkLayerDevice)temp; //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! nld.getConfig().executeCommand("interface "+inInterface+" ip address "+nld.getIPAddress(inInterface)+" "+inCustomSubnetMask); ! nld.getConfig().executeCommand("write mem"); } else --- 287,291 ---- NetworkLayerDevice nld = (NetworkLayerDevice)temp; //nld.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! } else *************** *** 402,406 **** throw new InvalidNodeNameException("Node does not exist"); } ! } /** --- 299,303 ---- throw new InvalidNodeNameException("Node does not exist"); } ! }*/ /** *************** *** 418,422 **** * @version v0.20 **/ ! public void setDefaultGateway(String inNodeName, String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException,InvalidNetworkLayerDeviceException{ if(nodeTable.containsKey(inNodeName)) --- 315,319 ---- * @version v0.20 **/ ! /*public void setDefaultGateway(String inNodeName, String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException,InvalidNetworkLayerDeviceException{ if(nodeTable.containsKey(inNodeName)) *************** *** 427,431 **** NetworkLayerDevice t = (NetworkLayerDevice)temp; //t.setDefaultGateway(inGatewayIPAddress); ! t.getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 "+inGatewayIPAddress+" eth0"); t.getConfig().executeCommand("write mem"); } --- 324,328 ---- NetworkLayerDevice t = (NetworkLayerDevice)temp; //t.setDefaultGateway(inGatewayIPAddress); ! t. t.getConfig().executeCommand("write mem"); } *************** *** 439,463 **** throw new InvalidNodeNameException("Node does not exist"); } ! } - public void execCmd(String inNodeName, String cmd) throws InvalidNodeNameException, InvalidNetworkLayerDeviceException{ - if(nodeTable.containsKey(inNodeName)) - { - Node temp = (Node)nodeTable.get(inNodeName); - if (temp instanceof NetworkLayerDevice) - { //test if device is a network layer device - NetworkLayerDevice t = (NetworkLayerDevice)temp; - t.getConfig().executeCommand(cmd); - } - else - { - throw new InvalidNetworkLayerDeviceException("This device is not a network layered device"); - } - } - else - { - throw new InvalidNodeNameException("Node does not exist"); - } - } --- 336,342 ---- throw new InvalidNodeNameException("Node does not exist"); } ! }*/ ! *************** *** 500,504 **** * @version v0.20 **/ ! public void setIPAddress(String inNodeName, String inNodeInterface, String inIPAddress) throws InvalidNodeNameException, InvalidNetworkInterfaceNameException, InvalidIPAddressException,InvalidNetworkLayerDeviceException{ String macAddress; --- 379,383 ---- * @version v0.20 **/ ! /*public void setIPAddress(String inNodeName, String inNodeInterface, String inIPAddress) throws InvalidNodeNameException, InvalidNetworkInterfaceNameException, InvalidIPAddressException,InvalidNetworkLayerDeviceException{ String macAddress; *************** *** 519,523 **** throw new InvalidNodeNameException("Node does not exist"); } ! } /** --- 398,402 ---- throw new InvalidNodeNameException("Node does not exist"); } ! }*/ /** *************** *** 535,539 **** * @version v0.20 **/ ! public void setMACAddress(String inNodeName, String inNodeInterface, String inMACAddress) throws InvalidNodeNameException, InvalidNetworkInterfaceNameException, InvalidNetworkLayerDeviceException{ if(nodeTable.containsKey(inNodeName)){ --- 414,418 ---- * @version v0.20 **/ ! /*public void setMACAddress(String inNodeName, String inNodeInterface, String inMACAddress) throws InvalidNodeNameException, InvalidNetworkInterfaceNameException, InvalidNetworkLayerDeviceException{ if(nodeTable.containsKey(inNodeName)){ *************** *** 550,554 **** throw new InvalidNodeNameException("Node does not exist"); } ! } /** --- 429,433 ---- throw new InvalidNodeNameException("Node does not exist"); } ! }*/ /** *************** *** 562,566 **** * @version v0.20 **/ ! public void updateARP(String inIPAddress, String inMACAddress, String inSkipName) { Enumeration e = nodeTable.elements(); --- 441,445 ---- * @version v0.20 **/ ! /*public void updateARP(String inIPAddress, String inMACAddress, String inSkipName) { Enumeration e = nodeTable.elements(); *************** *** 578,625 **** } ! } ! } ! public void addStaticARP(String inIPAddress, String inMACAddress, String inSkipName) ! { ! Enumeration e = nodeTable.elements(); ! while(e.hasMoreElements()) ! { ! Node temp = (Node)e.nextElement(); ! if (temp instanceof NetworkLayerDevice) ! { ! if(temp.getName().equals(inSkipName)) ! { ! NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! //tempNet.addToARPStatic(inIPAddress, inMACAddress); ! tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); ! tempNet.getConfig().executeCommand("write mem"); ! } ! ! } ! ! } ! } ! public void deleteARP(String inIPAddress, String inSkipName) ! { ! Enumeration e = nodeTable.elements(); ! while(e.hasMoreElements()) ! { ! Node temp = (Node)e.nextElement(); ! if (temp instanceof NetworkLayerDevice) ! { ! if(temp.getName().equals(inSkipName)) ! { ! NetworkLayerDevice tempNet = (NetworkLayerDevice)temp; ! //tempNet.removeARP(inIPAddress); ! tempNet.getConfig().executeCommand("no arp "+inIPAddress); ! tempNet.getConfig().executeCommand("write mem"); ! } ! ! } ! ! } ! } /** --- 457,466 ---- } ! } ! }*/ ! ! /* */ /** *************** *** 856,860 **** */ ! public int getState(String inNodeName) { if (nodeTable.containsKey(inNodeName)) { return ((Node)nodeTable.get(inNodeName)).getState(); --- 697,701 ---- */ ! /* public int getState(String inNodeName) { if (nodeTable.containsKey(inNodeName)) { return ((Node)nodeTable.get(inNodeName)).getState(); *************** *** 874,878 **** ((Node)nodeTable.get(inNodeName)).Reset(); } ! } --- 715,719 ---- ((Node)nodeTable.get(inNodeName)).Reset(); } ! }*/ *************** *** 884,888 **** */ ! public void addRoute(String inNodeName,Route_entry r){ if (nodeTable.containsKey(inNodeName)) { ((NetworkLayerDevice)nodeTable.get(inNodeName)).addRoute(r); --- 725,729 ---- */ ! /* public void addRoute(String inNodeName,Route_entry r){ if (nodeTable.containsKey(inNodeName)) { ((NetworkLayerDevice)nodeTable.get(inNodeName)).addRoute(r); *************** *** 908,912 **** } return null; ! } /** --- 749,753 ---- } return null; ! }*/ /** *************** *** 1047,1075 **** /** ! * This method is for creating router within the simulation ! * All routers are created with the default of two netork interface ! * @author luke_hamilton ! * @param inRouterName - The Router Name eg: router1 * @throws InvalidNodeNameException - * @version v0.20 **/ ! public void addRouter(String inRouterName, boolean inOn)throws InvalidNodeNameException { ! if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new Router(inRouterName, inOn)); ! } else { ! throw new InvalidNodeNameException("Node already exists with same name"); ! } ! return; ! } ! ! public void addExternalNAT(String inRouterName, boolean inOn)throws InvalidNodeNameException { ! if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new ExternalProxy(inRouterName, inOn)); ! } else { ! throw new InvalidNodeNameException("Node already exists with same name"); ! } ! return; ! } ! public void addNode(String ClassName, String inName, boolean inOn)throws InvalidNodeNameException { try{ --- 888,896 ---- /** ! * This method is for creating new node within the simulation ! * @author key * @throws InvalidNodeNameException **/ ! public void addNode(String ClassName, String inName, boolean inOn)throws InvalidNodeNameException { try{ *************** *** 1092,1103 **** /** ! * This method is for creating a PC within the simulation. ! * All PC are created by default with one network interface ! * @author luke_hamilton ! * @param inPCName - The PC Name eg: PC1 ! * @throws InvalidNodeNameException ! * @version v0.20 **/ ! public void addPC(String inPCName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inPCName)) { nodeTable.put(inPCName, new PC(inPCName, inOn)); --- 913,920 ---- /** ! * Compability methods for import old config files. Use addNode instead. **/ ! ! public void addPC(String inPCName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inPCName)) { nodeTable.put(inPCName, new PC(inPCName, inOn)); *************** *** 1107,1138 **** return; } - - public void addPrinter(String inPCName, boolean inOn) throws InvalidNodeNameException { - if (!nodeTable.containsKey(inPCName)) { - nodeTable.put(inPCName, new Printer(inPCName, inOn)); - } else { - throw new InvalidNodeNameException("Node already exists with same name"); - } - return; - } - public void addAP(String inPCName, boolean inOn) throws InvalidNodeNameException { - if (!nodeTable.containsKey(inPCName)) { - nodeTable.put(inPCName, new WirelessAP(inPCName, inOn)); - } else { - throw new InvalidNodeNameException("Node already exists with same name"); - } - return; - } - - /** - * This method will check to see if the hub name is contained within the - * hash table (nodeTable) if it is not it will create a hub object and add it to the nodetable. - * Else throw exceptions. - * @author luke_hamilton - * @param inNodeName - The Hub Name eg: Hub1 - * @throws InvalidNodeNameException - * @version v0.20 - **/ public void addHub(String inNodeName, boolean inOn) throws InvalidNodeNameException { if (!nodeTable.containsKey(inNodeName)) { --- 924,928 ---- *************** *** 1142,1162 **** } } ! ! public void addCSUDSU(String inNodeName, boolean inOn) throws InvalidNodeNameException { ! if (!nodeTable.containsKey(inNodeName)) { ! nodeTable.put(inNodeName, new CSUDSU(inNodeName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); } } ! /** ! * This method will check to see if the switch name is contained within the ! * hash table (nodeTable) if it is not it will create a switch object and add it to the nodetable. ! * Else throw exceptions. ! * @author luke_hamilton ! * @param inNodeName - The Switch Name eg: Switch1 ! * @throws InvalidNodeNameException ! * @version v0.20 ! **/ public void addSwitch(String inNodeName, boolean inOn) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ --- 932,945 ---- } } ! ! public void addRouter(String inRouterName, boolean inOn)throws InvalidNodeNameException { ! if (!nodeTable.containsKey(inRouterName)) { ! nodeTable.put(inRouterName, new Router(inRouterName, inOn)); } else { throw new InvalidNodeNameException("Node already exists with same name"); } + return; } ! public void addSwitch(String inNodeName, boolean inOn) throws InvalidNodeNameException { if(!nodeTable.containsKey(inNodeName)){ *************** *** 1239,1243 **** * @return String[] List of interface names that are not connected to a link. **/ ! public String[] getAvailableInterfaces(String inNodeName)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException { String strAvailInterfaces[]; if(nodeTable.containsKey(inNodeName)){ --- 1022,1026 ---- * @return String[] List of interface names that are not connected to a link. **/ ! /*public String[] getAvailableInterfaces(String inNodeName)throws InvalidNetworkLayerDeviceException, InvalidNodeNameException { String strAvailInterfaces[]; if(nodeTable.containsKey(inNodeName)){ *************** *** 1248,1252 **** } return strAvailInterfaces; ! } /** --- 1031,1035 ---- } return strAvailInterfaces; ! }*/ /** *************** *** 1256,1260 **** * @throws InvalidNodeNameException */ ! public Object[] getAllInterfaces(String inNodeName)throws InvalidNodeNameException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); --- 1039,1043 ---- * @throws InvalidNodeNameException */ ! /* public Object[] getAllInterfaces(String inNodeName)throws InvalidNodeNameException { if(nodeTable.containsKey(inNodeName)){ Node temp = (Node)nodeTable.get(inNodeName); *************** *** 1271,1275 **** } throw new InvalidNodeNameException("Node does not exist."); ! } /** --- 1054,1058 ---- } throw new InvalidNodeNameException("Node does not exist."); ! }*/ /** *************** *** 1280,1286 **** * @return */ ! public static boolean validateDecIP(String inDecIPAddress){ return IPV4Address.validateDecIP(inDecIPAddress); ! } /** --- 1063,1069 ---- * @return */ ! /*public static boolean validateDecIP(String inDecIPAddress){ return IPV4Address.validateDecIP(inDecIPAddress); ! }*/ /** *************** *** 1291,1297 **** * @return */ ! public static boolean validateDecSubnetMask(String inDecSubnetMask){ return IPV4Address.validateDecSubnetMask(inDecSubnetMask); ! } /** --- 1074,1080 ---- * @return */ ! /*public static boolean validateDecSubnetMask(String inDecSubnetMask){ return IPV4Address.validateDecSubnetMask(inDecSubnetMask); ! }*/ /** *************** *** 1301,1307 **** * @return */ ! public static String getDefaultSubnetMask(String inDecimalIp){ return IPV4Address.getDefaultSubnetMask(inDecimalIp); ! } public Vector getAllNodeInformation(String inNodeName) throws InvalidNodeNameException --- 1084,1090 ---- * @return */ ! /*public static String getDefaultSubnetMask(String inDecimalIp){ return IPV4Address.getDefaultSubnetMask(inDecimalIp); ! }*/ public Vector getAllNodeInformation(String inNodeName) throws InvalidNodeNameException Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NetworkLayerDevice.java 17 Oct 2008 09:10:16 -0000 1.26 --- NetworkLayerDevice.java 21 Oct 2008 11:50:24 -0000 1.27 *************** *** 381,400 **** NodeProtocolStack.removeARP(inIPAddress); } ! ! /** ! * ! * @return ! */ ! public Object[] getAllInterfaces(){ ! ArrayList<String> interfaceArray = new ArrayList<String>(); ! Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()){ ! String str = (String) keys.nextElement(); ! NetworkInterface x = (NetworkInterface)NetworkInterfacetable.get(str); ! interfaceArray.add(x.getName()); ! } ! return interfaceArray.toArray(); } --- 381,408 ---- NodeProtocolStack.removeARP(inIPAddress); } ! ! public void setTCPIPSettings(String inInterface, String inIP, String inMask, String inGateway){ ! getConfig().executeCommand("interface "+inInterface+" ip address "+ inIP + " " + inMask); ! if(inGateway != null) ! getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 " + inGateway + " " + inInterface); ! getConfig().executeCommand("write mem"); ! } ! ! public void setTCPIPSettings(String inGateway){ ! getConfig().executeCommand("ip route 0.0.0.0 0.0.0.0 " + inGateway + " eth0"); ! ! getConfig().executeCommand("write mem"); ! } ! ! public void setTCPIPSettings(String inInterface, String inIP, String inMask){ ! getConfig().executeCommand("interface "+inInterface+" ip address "+ inIP + " " + inMask); ! ! getConfig().executeCommand("write mem"); ! } ! ! public void execCmd(String cmd){ ! getConfig().executeCommand(cmd); } *************** *** 474,476 **** --- 482,522 ---- return nat; } + + + public String[] getFormattedARPTable() + { + String[] arpEntries; + Vector<Vector<String>> ArpTable = getARPTable(); + arpEntries = new String[ArpTable.size()+1]; + + if(ArpTable.size()>0){ + arpEntries[0] = "Internet Address\tPhysical Address\t\tType\n"; + for(int i=0;i<ArpTable.size();i++) + { + arpEntries[i+1] = ArpTable.get(i).get(0) + "\t\t" + ArpTable.get(i).get(1) + "\t\t" + ArpTable.get(i).get(2) + "\n"; + } + }else{ + arpEntries[0] = "No ARP Entries Found\n"; + } + + return arpEntries; + } + + public void addStaticARP(String inIPAddress, String inMACAddress) + { + NetworkLayerDevice tempNet = this; + + tempNet.getConfig().executeCommand("arp "+inIPAddress+" "+inMACAddress); + tempNet.getConfig().executeCommand("write mem"); + + } + + public void deleteARPRecord(String inIPAddress) + { + NetworkLayerDevice tempNet = this; + + tempNet.getConfig().executeCommand("no arp "+inIPAddress); + tempNet.getConfig().executeCommand("write mem"); + + } }//EOF Index: DataLinkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DataLinkLayerDevice.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DataLinkLayerDevice.java 5 Oct 2008 19:12:30 -0000 1.7 --- DataLinkLayerDevice.java 21 Oct 2008 11:50:24 -0000 1.8 *************** *** 64,78 **** } ! public Object[] getAllInterfaces(){ ! ! ArrayList<String> interfaceArray = new ArrayList<String>(); ! Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()){ ! String str = (String) keys.nextElement(); ! NetworkInterface x = (NetworkInterface)NetworkInterfacetable.get(str); ! interfaceArray.add(x.getName()); ! } ! ! return interfaceArray.toArray(); ! } } --- 64,67 ---- } ! } Index: Switch.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Switch.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Switch.java 26 Sep 2008 17:53:49 -0000 1.10 --- Switch.java 21 Oct 2008 11:50:24 -0000 1.11 *************** *** 79,86 **** while(it.hasMoreElements()){ NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! nic = tempInterface.getName(); Hashtable outInt = (Hashtable) IntCaches.get(nic); outInt.clear(); } } --- 79,87 ---- while(it.hasMoreElements()){ NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! nic = tempInterface.getName(); Hashtable outInt = (Hashtable) IntCaches.get(nic); outInt.clear(); } + super.Reset(); } |