[Javanetsim-cvs] javaNetSim/core ApplicationLayerDevice.java, 1.2, 1.3 CommandProcessor.java, 1.2,
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26945/core Modified Files: ApplicationLayerDevice.java CommandProcessor.java DeviceConfig.java NetworkLayerDevice.java Node.java Simulation.java Log Message: Some console commands was corrected Index: DeviceConfig.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/DeviceConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DeviceConfig.java 14 Oct 2007 00:22:14 -0000 1.2 --- DeviceConfig.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 81,99 **** } ! /** Add 'command', which contain parameters after 'paramc' argument * @return false if 'command' already exists */ public boolean add(String command, Vector<String> params){ - boolean result = false; - String fullcmd = createCommand(command, params); LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); boolean found = false; while(it.hasNext() && !found){ ! found = (fullcmd.compareToIgnoreCase(it.next())==0); } if(!found){ ! config.add(createCommand(command, params)); result = true; } --- 81,105 ---- } ! /** Add 'command', which contain parameters 'params' * @return false if 'command' already exists */ public boolean add(String command, Vector<String> params){ String fullcmd = createCommand(command, params); + return add(fullcmd); + } + + /** Add full 'command' + * @return false if 'command' already exists + */ + public boolean add(String command){ + boolean result = false; LinkedList config = getConfig(working_config); Iterator<String> it = config.iterator(); boolean found = false; while(it.hasNext() && !found){ ! found = (command.compareToIgnoreCase(it.next())==0); } if(!found){ ! config.add(command); result = true; } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Simulation.java 14 Oct 2007 17:19:07 -0000 1.15 --- Simulation.java 14 Oct 2007 22:14:52 -0000 1.16 *************** *** 305,309 **** { NetworkLayerDevice t = (NetworkLayerDevice)tempNode; ! arpEntries = t.getARPTable(); }else { --- 305,320 ---- { 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 { Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NetworkLayerDevice.java 13 Oct 2007 12:57:00 -0000 1.9 --- NetworkLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.10 *************** *** 60,64 **** --- 60,80 ---- public NetworkLayerDevice(String inName, int inProtocolStackLayers) { super(inName, inProtocolStackLayers); + //set default startup-config + config.working_config = DeviceConfig.STARTUP_CONFIG; + //config.add("ip telnet 21"); + //end set default startup-config + config.working_config = DeviceConfig.RUNNING_CONFIG; + config.load(); } + + public void turnOn(){ + super.turnOn(); + config.load(); + } + + public void turnOff(){ + config.clear(DeviceConfig.RUNNING_CONFIG); + super.turnOff(); + } /** *************** *** 164,170 **** * @author robert_hulford * @author bevan_calliess ! * @return String[] - The arp table entries */ ! public String[] getARPTable() { return NodeProtocolStack.getARPTable(); } --- 180,186 ---- * @author robert_hulford * @author bevan_calliess ! * @return Vector<Vector<String>> - The arp table entries */ ! public Vector<Vector<String>> getARPTable() { return NodeProtocolStack.getARPTable(); } Index: CommandProcessor.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommandProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CommandProcessor.java 14 Oct 2007 00:22:14 -0000 1.2 --- CommandProcessor.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 13,16 **** --- 13,20 ---- import core.protocolsuite.tcp_ip.Route_entry; import core.protocolsuite.tcp_ip.SNMP; + import core.protocolsuite.tcp_ip.TCP_session; + import core.protocolsuite.tcp_ip.UDP_session; + import core.protocolsuite.tcp_ip.jnSocket; + import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; *************** *** 49,52 **** --- 53,57 ---- private ip_route_CommandClass ip_route_Command = new ip_route_CommandClass(); private no_ip_route_CommandClass no_ip_route_Command = new no_ip_route_CommandClass(); + private ip_tcp_window_size_CommandClass ip_tcp_window_size_Command = new ip_tcp_window_size_CommandClass(); private show_access_lists_CommandClass show_access_lists_Command = new show_access_lists_CommandClass(); private show_arp_CommandClass show_arp_Command = new show_arp_CommandClass(); *************** *** 59,67 **** private show_interfaces_CommandClass show_interfaces_Command = new show_interfaces_CommandClass(); private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); private show_logging_CommandClass show_logging_Command = new show_logging_CommandClass(); private show_ntp_CommandClass show_ntp_Command = new show_ntp_CommandClass(); - private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); private show_running_config_CommandClass show_running_config_Command = new show_running_config_CommandClass(); private show_sessions_CommandClass show_sessions_Command = new show_sessions_CommandClass(); --- 64,72 ---- private show_interfaces_CommandClass show_interfaces_Command = new show_interfaces_CommandClass(); private show_ip_CommandClass show_ip_Command = new show_ip_CommandClass(); + private show_ip_route_CommandClass show_ip_route_Command = new show_ip_route_CommandClass(); private show_kron_CommandClass show_kron_Command = new show_kron_CommandClass(); private show_location_CommandClass show_location_Command = new show_location_CommandClass(); private show_logging_CommandClass show_logging_Command = new show_logging_CommandClass(); private show_ntp_CommandClass show_ntp_Command = new show_ntp_CommandClass(); private show_running_config_CommandClass show_running_config_Command = new show_running_config_CommandClass(); private show_sessions_CommandClass show_sessions_Command = new show_sessions_CommandClass(); *************** *** 70,75 **** --- 75,89 ---- private show_snmp_version_CommandClass show_snmp_version_Command = new show_snmp_version_CommandClass(); private show_startup_config_CommandClass show_startup_config_Command = new show_startup_config_CommandClass(); + private show_tcp_sessions_CommandClass show_tcp_sessions_Command = new show_tcp_sessions_CommandClass(); + private show_tcp_statistics_CommandClass show_tcp_statistics_Command = new show_tcp_statistics_CommandClass(); + private show_tcp_window_size_CommandClass show_tcp_window_size_Command = new show_tcp_window_size_CommandClass(); + private show_udp_sessions_CommandClass show_udp_sessions_Command = new show_udp_sessions_CommandClass(); + private show_udp_statistics_CommandClass show_udp_statistics_Command = new show_udp_statistics_CommandClass(); private show_version_CommandClass show_version_Command = new show_version_CommandClass(); + private snmp_server_community_CommandClass snmp_server_community_Command = new snmp_server_community_CommandClass(); + private no_snmp_server_community_CommandClass no_snmp_server_community_Command = new no_snmp_server_community_CommandClass(); + private snmp_server_port_CommandClass snmp_server_port_Command = new snmp_server_port_CommandClass(); private telnet_CommandClass telnet_Command = new telnet_CommandClass(); + private telnet_server_CommandClass telnet_server_Command = new telnet_server_CommandClass(); private traceroute_CommandClass traceroute_Command = new traceroute_CommandClass(); private write_memory_CommandClass write_memory_Command = new write_memory_CommandClass(); *************** *** 99,102 **** --- 113,118 ---- commands.add("ip route", ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>) <netmask> <gateway> <target interface>", "Add route record"); commands.add("no ip route", no_ip_route_Command, CONF_MODE | NETWORK_LAYER, "(<host ip>|<network ip>)", "Delete route record"); + commands.addDescription("ip tcp","Global TCP parameters"); + commands.add("ip tcp window-size", ip_tcp_window_size_Command, CONF_MODE | TRANSPORT_LAYER, "<window-size>", "TCP window size"); commands.addDescription("show","Show running system information"); commands.add("show access-lists", show_access_lists_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<1-2699 | WORD>", "List access lists"); *************** *** 118,128 **** commands.add("show running-config", show_running_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Current operating configuration"); commands.add("show sessions", show_sessions_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "Information about Telnet connections"); ! commands.addDescription("show snmp","snmp statistics"); commands.add("show snmp community", show_snmp_community_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp community"); commands.add("show snmp mib", show_snmp_mib_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show mib objects"); commands.add("show snmp version", show_snmp_version_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp version"); commands.add("show startup-config", show_startup_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Contents of startup configuration"); commands.add("show version", show_version_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "System hardware and software status"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); --- 134,156 ---- commands.add("show running-config", show_running_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Current operating configuration"); commands.add("show sessions", show_sessions_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "Information about Telnet connections"); ! commands.addDescription("show snmp","SNMP statistics"); commands.add("show snmp community", show_snmp_community_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp community"); commands.add("show snmp mib", show_snmp_mib_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show mib objects"); commands.add("show snmp version", show_snmp_version_Command, STD_CONF_MODE | APPLICATION_LAYER, "<cr>", "show snmp version"); commands.add("show startup-config", show_startup_config_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "Contents of startup configuration"); + commands.addDescription("show tcp","TCP information"); + commands.add("show tcp sessions", show_tcp_sessions_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "Print all TCP sessions"); + commands.add("show tcp statistics", show_tcp_statistics_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "TCP statistics"); + commands.add("show tcp window-size", show_tcp_window_size_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "TCP window-size"); + commands.addDescription("show udp","TCP information"); + commands.add("show udp sessions", show_udp_sessions_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "Print all UDP sessions"); + commands.add("show udp statistics", show_udp_statistics_Command, STD_CONF_MODE | TRANSPORT_LAYER, "<cr>", "UDP statistics"); commands.add("show version", show_version_Command, STD_CONF_MODE | NO_LAYER, "<cr>", "System hardware and software status"); + commands.addDescription("snmp-server","Modify SNMP engine parameters"); + commands.add("snmp-server community", snmp_server_community_Command, CONF_MODE | APPLICATION_LAYER, "<community>", "Enable SNMP; set community string"); + commands.add("no snmp-server community", no_snmp_server_community_Command, CONF_MODE | APPLICATION_LAYER, "<cr>", "Disable SNMP"); + commands.add("snmp-server port", snmp_server_port_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Specify server port"); commands.add("telnet", telnet_Command, STD_CONF_MODE | APPLICATION_LAYER, "<IP>", "Open a telnet connection"); + commands.add("telnet-server", telnet_server_Command, CONF_MODE | APPLICATION_LAYER, "<port>", "Enable TELNET; Specify server port"); commands.add("traceroute", traceroute_Command, STD_CONF_MODE | NETWORK_LAYER, "<IP>", "Trace route to destination"); commands.addDescription("write","Write running configuration to memory or terminal"); *************** *** 195,201 **** public String call(Vector<String> params){ String out = ""; ! String arps[] = device.NodeProtocolStack.getARPTable(); ! for(int i=1; i<arps.length; i++){ ! device.NodeProtocolStack.removeARP(arps[i].split(" ")[0]); } out += "ARP table have been cleared\n"; --- 223,229 ---- public String call(Vector<String> params){ String out = ""; ! Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); ! for(int i=1; i<ArpTable.size(); i++){ ! device.NodeProtocolStack.removeARP(ArpTable.get(i).get(0)); } out += "ARP table have been cleared\n"; *************** *** 283,289 **** class reload_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! //device.cold_restart(); ! device.getConfig().load(); ! return ""; } }; --- 311,316 ---- class reload_CommandClass implements CommandInterface{ public String call(Vector<String> params){ ! device.Reset(); ! return "Device reloaded\n"; } }; *************** *** 292,295 **** --- 319,324 ---- String out = ""; if(params.size()==4){ + device.getConfig().remove("^ip route "+params.get(0)+" "+params.get(1)); + device.getConfig().add("ip route", params); device.NodeProtocolStack.addRoute(new Route_entry(params.get(0), params.get(2), params.get(1), params.get(3), 0)); out+="Route added.\n"; *************** *** 305,308 **** --- 334,338 ---- String out = ""; if(params.size()==1){ + device.getConfig().remove("^ip route "+params.get(0)+" "+params.get(1)); device.NodeProtocolStack.removeRoute(params.get(0)); out+="Route to " + params.get(0) + " removed.\n"; *************** *** 314,317 **** --- 344,366 ---- } }; + class ip_tcp_window_size_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(params.size()==1){ + try{ + int ws = Integer.parseInt(params.get(0)); + device.NodeProtocolStack.TCP().getWindowSize(); + out += "TCP window size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; + } + catch(NumberFormatException e){ + out += "Invalid window size\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class show_access_lists_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 323,330 **** String out = ""; try{ ! String ArpTable[] = device.NodeProtocolStack.getARPTable(); ! for(int i=0;i<ArpTable.length;i++) ! { ! out += ArpTable[i] + "\n"; } } --- 372,385 ---- String out = ""; try{ ! Vector<Vector<String>> ArpTable = device.NodeProtocolStack.getARPTable(); ! if(ArpTable.size()>0){ ! out += "Internet Address\tPhysical Address\t\tType\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) + "\n"; ! } ! } ! else{ ! out += "No ARP Entries Found\n"; } } *************** *** 398,414 **** "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString(); - if(device.getClass().equals(ApplicationLayerDevice.class)){ - out += "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + - "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + - "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + - "\n Sent TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPSDCount()).toString() + - "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + - "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + - "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString(); - } out += "\n"; return out; } }; class show_kron_CommandClass implements CommandInterface{ public String call(Vector<String> params){ --- 453,477 ---- "\n Sent IP Packets: " + Integer.valueOf(device.NodeProtocolStack.getoutputIPCount()).toString() + "\n ARP Packets: " + Integer.valueOf(device.NodeProtocolStack.getARPCount()).toString(); out += "\n"; return out; } }; + class show_ip_route_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(params.size()==0){ + String routes[] = device.NodeProtocolStack.getRouteTableEntries(); + out += "IP routing table:\n" + "Destination" + "\t" + "Genmask" + "\t" + "Gateway" + "\t" + "Type" + "\t" + "Iface\n"; + for(int i=0; i<routes.length - 1; i++){ + Route_entry r = device.NodeProtocolStack.getRouteTableEntry(routes[i]); + out += routes[i] + "\t" + r.genMask + "\t" + r.gateway + "\t" + r.Type + "\t" + r.iFace + "\n"; + } + } + else{ + out += "Invalid parameters\n"; + } + return out; + } + }; class show_kron_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 431,451 **** } }; - class show_ip_route_CommandClass implements CommandInterface{ - public String call(Vector<String> params){ - String out = ""; - if(params.size()==0){ - String routes[] = device.NodeProtocolStack.getRouteTableEntries(); - out += "IP routing table:\n" + "Destination" + "\t" + "Genmask" + "\t" + "Gateway" + "\t" + "Type" + "\t" + "Iface\n"; - for(int i=0; i<routes.length - 1; i++){ - Route_entry r = device.NodeProtocolStack.getRouteTableEntry(routes[i]); - out += routes[i] + "\t" + r.genMask + "\t" + r.gateway + "\t" + r.Type + "\t" + r.iFace + "\n"; - } - } - else{ - out += "Invalid parameters\n"; - } - return out; - } - }; class show_running_config_CommandClass implements CommandInterface{ public String call(Vector<String> params){ --- 494,497 ---- *************** *** 506,509 **** --- 552,623 ---- } }; + class show_tcp_sessions_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Source\tDestination\tState\n"; + Enumeration<String> keys = device.NodeProtocolStack.TCP().getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + TCP_session tcps = device.NodeProtocolStack.TCP().getSession(key); + jnSocket jnsock = device.NodeProtocolStack.SL().get_socket(tcps.getSocket()); + out += jnsock.src_IP+":"+jnsock.src_port+"\t"+jnsock.dst_IP+":"+jnsock.src_port+"\t"+tcps.getState()+"\n"; + } + out += ""; + } + return out; + } + }; + class show_tcp_statistics_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "\n Recieved TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPinputCount()).toString() + + "\n Sent TCP segments: " + Integer.valueOf(device.NodeProtocolStack.getTCPoutputCount()).toString() + + "\n Sent TCP ACK's: " + Integer.valueOf(device.NodeProtocolStack.getTCPACKCount()).toString() + + "\n Sent TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPSDCount()).toString() + + "\n Recieved TCP Dublicates: " + Integer.valueOf(device.NodeProtocolStack.getTCPRDCount()).toString() + + "\n"; + } + return out; + } + }; + class show_tcp_window_size_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Windows size is " + device.NodeProtocolStack.TCP().getWindowSize() + " segments"; + } + return out; + } + }; + class show_udp_sessions_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "Source\tDestination\tState\n"; + Enumeration<String> keys = device.NodeProtocolStack.UDP().getSessionKeys(); + while(keys.hasMoreElements()){ + String key = keys.nextElement(); + UDP_session udps = device.NodeProtocolStack.UDP().getSession(key); + jnSocket jnsock = device.NodeProtocolStack.SL().get_socket(udps.getSocket()); + out += jnsock.src_IP+":"+jnsock.src_port+"\t"+jnsock.dst_IP+":"+jnsock.src_port+"\n"; + } + out += ""; + } + return out; + } + }; + class show_udp_statistics_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + String out = ""; + if(device instanceof ApplicationLayerDevice){ + out += "\n Recieved UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPinputCount()).toString() + + "\n Sent UDP segments: " + Integer.valueOf(device.NodeProtocolStack.getUDPoutputCount()).toString() + + "\n"; + } + return out; + } + }; class show_version_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 513,516 **** --- 627,645 ---- } }; + class snmp_server_community_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; + class no_snmp_server_community_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; + class snmp_server_port_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; class telnet_CommandClass implements CommandInterface{ public String call(Vector<String> params){ *************** *** 518,521 **** --- 647,655 ---- } }; + class telnet_server_CommandClass implements CommandInterface{ + public String call(Vector<String> params){ + return "Command not supported yet.\n"; + } + }; class traceroute_CommandClass implements CommandInterface{ public String call(Vector<String> params){ Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Node.java 14 Oct 2007 17:19:07 -0000 1.10 --- Node.java 14 Oct 2007 22:14:52 -0000 1.11 *************** *** 128,131 **** --- 128,133 ---- public boolean On; + + private int ProtocolStackLayers; *************** *** 155,193 **** name=inName; ! On = true; ! ! if(inProtocolStackLayers != 1){ ! ! //This test the current simulation object for the type of protocol that is being used and then ! ! //Creates a protocolstack of that type. ! ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! ! } ! ! }else{ ! ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! ! } } ! /** --- 157,184 ---- name=inName; ! ProtocolStackLayers = inProtocolStackLayers; ! ! init(inProtocolStackLayers); } ! private void init(int inProtocolStackLayers){ ! On = true; ! if(inProtocolStackLayers != 1){ ! //This test the current simulation object for the type of protocol that is being used and then ! //Creates a protocolstack of that type. ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! } ! }else{ ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! } ! } /** *************** *** 341,345 **** public int getState() { return 0; } ! public void Reset() {} --- 332,348 ---- public int getState() { return 0; } ! public void Reset() { ! turnOff(); ! turnOn(); ! } ! ! public void turnOn() { ! init(ProtocolStackLayers); ! } ! ! public void turnOff() { ! On = false; ! NodeProtocolStack = null; ! } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ApplicationLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ApplicationLayerDevice.java 3 Dec 2005 19:23:19 -0000 1.2 --- ApplicationLayerDevice.java 14 Oct 2007 22:14:52 -0000 1.3 *************** *** 8,11 **** --- 8,13 ---- package core; + import core.protocolsuite.tcp_ip.Application; + import java.util.Enumeration; import java.util.Hashtable; *************** *** 23,31 **** public void addApp(Object app, int code){ ! Apps.put(code, app); } public Object getApp(int code){ ! return Apps.get(code); } } --- 25,49 ---- public void addApp(Object app, int code){ ! Apps.put(code, app); } public Object getApp(int code){ ! return Apps.get(code); ! } ! ! public void turnOn(){ ! super.turnOn(); ! } ! ! public void turnOff(){ ! Enumeration<Application> ap = Apps.elements(); ! // while(ap.hasMoreElements()){ ! // try{ ! // ap.nextElement().Free(); ! // }catch(TransportLayerException e){ ! // e.printStackTrace(); ! // } ! // } ! super.turnOn(); } } |