[Javanetsim-cvs] javaNetSim/guiUI MainScreen.java,1.7,1.8
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-11-20 14:22:07
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5202/guiUI Modified Files: MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MainScreen.java 20 Nov 2005 07:55:48 -0000 1.7 --- MainScreen.java 20 Nov 2005 14:21:58 -0000 1.8 *************** *** 477,484 **** try{ ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("Starting network transfer... \n"); ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("\n"); String strDestinationIP = dlgSendPing.getDestinationIPAddress(); Sim.sendPing(inNodeName, strDestinationIP); --- 477,481 ---- try{ ! String strDestinationIP = dlgSendPing.getDestinationIPAddress(); Sim.sendPing(inNodeName, strDestinationIP); *************** *** 499,502 **** --- 496,514 ---- pnlConsole.append(e.toString()+"\n"); } + + // Ok button was pressed. + } + dlgSendPing.dispose(); + } + + + public void printNetworkStart(){ + pnlConsole.append("**************************************************************************************************************** \n"); + pnlConsole.append("Starting network transfer... \n"); + pnlConsole.append("**************************************************************************************************************** \n"); + pnlConsole.append("\n"); + } + + public void printLayerInfo(){ pnlConsole.append("\n"); Vector vecRecordedInfo = Sim.getRecordedInfo(); *************** *** 515,523 **** Sim.clearLayerInfo(); } ! // Ok button was pressed. ! } ! dlgSendPing.dispose(); ! } ! /** * Creates a Properties Dialog on the specific Node --- 527,532 ---- Sim.clearLayerInfo(); } ! } ! /** * Creates a Properties Dialog on the specific Node *************** *** 1278,1639 **** - // Presaved Simulations. - - /** - * Creates presaved simulation 1. - */ - - public void createTest1() - { - - - String strPC1Name = "PC1"; - String strPC2Name = "PC2"; - String strLinkName = "PC1-TO-PC2"; - - Point pntPC1 = new Point(100,100); - Point pntPC2 = new Point(400, 200); - - - if(refreshMainScreen()) - { - try{ - // Create the PC's - this.refreshMainScreen(); - isDirty = true; - Sim.addPC(strPC1Name); - GuiPC tempPC = new GuiPC(strPC1Name,this); - tempPC.setNodeLocation(pntPC1); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC1Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.1"); - - Sim.addPC(strPC2Name); - tempPC = new GuiPC(strPC2Name,this); - tempPC.setNodeLocation(pntPC2); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC2Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.2"); - - Sim.addEthernetLink(strLinkName, strPC1Name, "eth0", strPC2Name, "eth0"); - this.createLink(strLinkName, strPC1Name, strPC2Name); - this.refreshNodeInformationTab(); - this.addToConsole("Simulation 1 Created Sucessfully \n"); - - } - catch(Exception e) - { - // Should never get here if i do everything right. - } - } - - } - - - /** - * Creates presaved simulation 2. - */ - - public void createTest2() - { - String strPC1Name = "PC1"; - String strPC2Name = "PC2"; - String strRouter1Name = "Router1"; - String strLink1Name = "PC1-TO-Router1"; - String strLink2Name = "Router1-TO-PC2"; - - Point pntPC1 = new Point(100,100); - Point pntPC2 = new Point(400, 100); - Point pntRouter1 = new Point(200,300); - - - if(refreshMainScreen()) - { - try - { - this.refreshMainScreen(); - isDirty = true; - Sim.addPC(strPC1Name); - GuiPC tempPC = new GuiPC(strPC1Name,this); - tempPC.setNodeLocation(pntPC1); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC1Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.1"); - Sim.setDefaultGateway(tempPC.getName(), "192.168.0.100"); - - Sim.addPC(strPC2Name); - tempPC = new GuiPC(strPC2Name,this); - tempPC.setNodeLocation(pntPC2); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC2Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "203.168.0.1"); - Sim.setDefaultGateway(tempPC.getName(), "203.168.0.100"); - - Sim.addRouter(strRouter1Name); - GuiRouter tempRouter = new GuiRouter(strRouter1Name, this); - tempRouter.setLocation(pntRouter1); - Sandbox.add(tempRouter); - Sandbox.setLayer(tempRouter, 3, 0); - GUInodeTable.put(strRouter1Name, tempRouter); - Sim.setIPAddress(tempRouter.getName(), "eth0", "192.168.0.100"); - Sim.setIPAddress(tempRouter.getName(), "eth1", "203.168.0.100"); - - Sim.addEthernetLink(strLink1Name, strPC1Name, "eth0", strRouter1Name, "eth0"); - Sim.addEthernetLink(strLink2Name, strPC2Name, "eth0", strRouter1Name, "eth1"); - this.createLink(strLink1Name, strPC1Name, strRouter1Name); - this.createLink(strLink2Name, strPC2Name, strRouter1Name); - - this.refreshNodeInformationTab(); - this.addToConsole("Simulation 2 Created Sucessfully \n"); - } - catch(Exception e) - { - // Should never get here if I do everything right. - } - - } - } - - - /** - * Creates presaved simulation 3. - */ - - public void createTest3() - { - String strPC1Name = "PC1"; - String strPC2Name = "PC2"; - String strRouter1Name = "Router1"; - String strRouter2Name = "Router2"; - - String strLink1Name = "PC1-TO-Router1"; - String strLink2Name = "Router1-TO-Router2"; - String strLink3Name = "Router2-TO-PC2"; - - Point pntPC1 = new Point(100,100); - Point pntPC2 = new Point(400, 100); - Point pntRouter1 = new Point(250,250); - Point pntRouter2 = new Point(320,250); - - if(refreshMainScreen()) - { - try - { - this.refreshMainScreen(); - isDirty = true; - Sim.addPC(strPC1Name); - GuiPC tempPC = new GuiPC(strPC1Name,this); - tempPC.setNodeLocation(pntPC1); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC1Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.2"); - Sim.setDefaultGateway(tempPC.getName(), "192.168.0.1"); - - Sim.addPC(strPC2Name); - tempPC = new GuiPC(strPC2Name,this); - tempPC.setNodeLocation(pntPC2); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC2Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "10.0.0.2"); - Sim.setDefaultGateway(tempPC.getName(), "10.0.0.1"); - - Sim.addRouter(strRouter1Name); - GuiRouter tempRouter = new GuiRouter(strRouter1Name, this); - tempRouter.setLocation(pntRouter1); - Sandbox.add(tempRouter); - Sandbox.setLayer(tempRouter, 3, 0); - GUInodeTable.put(strRouter1Name, tempRouter); - Sim.setIPAddress(tempRouter.getName(), "eth0", "192.168.0.1"); - Sim.setIPAddress(tempRouter.getName(), "eth1", "127.10.0.1"); - Sim.setDefaultGateway(tempRouter.getName(),"127.10.0.2"); - - Sim.addRouter(strRouter2Name); - tempRouter = new GuiRouter(strRouter2Name, this); - tempRouter.setLocation(pntRouter2); - Sandbox.add(tempRouter); - Sandbox.setLayer(tempRouter, 3, 0); - GUInodeTable.put(strRouter2Name, tempRouter); - Sim.setIPAddress(tempRouter.getName(), "eth0", "127.10.0.2"); - Sim.setIPAddress(tempRouter.getName(), "eth1", "10.0.0.1"); - Sim.setDefaultGateway(tempRouter.getName(),"127.10.0.1"); - - Sim.addEthernetLink(strLink1Name, strPC1Name, "eth0", strRouter1Name, "eth0"); - Sim.addEthernetLink(strLink2Name, strRouter1Name, "eth1", strRouter2Name, "eth0"); - Sim.addEthernetLink(strLink3Name, strRouter2Name, "eth1", strPC2Name, "eth0"); - - this.createLink(strLink1Name, strPC1Name, strRouter1Name); - this.createLink(strLink2Name, strRouter1Name, strRouter2Name); - this.createLink(strLink3Name, strRouter2Name, strPC2Name); - - this.refreshNodeInformationTab(); - this.addToConsole("Simulation 3 Created Sucessfully \n"); - } - catch(Exception e) - { - // Never get here (I hope...) - } - } - } - - /** - * Creates presaved simulation 4. - */ - public void createTest4() - { - String strPC1Name = "PC1"; - String strPC2Name = "PC2"; - String strPC3Name = "PC3"; - String strPC4Name = "PC4"; - String strPC5Name = "PC5"; - String strPC6Name = "PC6"; - - String strHub1Name = "Hub1"; - String strHub2Name = "Hub2"; - - String strRouter1Name = "Router1"; - - String strLink1Name = "PC1-TO-Hub1"; - String strLink2Name = "PC2-TO-Hub1"; - String strLink3Name = "PC3-TO-Hub1"; - String strLink4Name = "Hub1-TO-Router1"; - String strLink5Name = "Router1-TO-Hub2"; - String strLink6Name = "Hub2-TO-PC4"; - String strLink7Name = "Hub2-TO-PC5"; - String strLink8Name = "Hub2-TO-PC6"; - - - Point pntPC1 = new Point(100,100); - Point pntPC2 = new Point(100,200); - Point pntPC3 = new Point(100,300); - Point pntPC4 = new Point(600,100); - Point pntPC5 = new Point(600,200); - Point pntPC6 = new Point(600,300); - - Point pntHub1 = new Point(250,200); - Point pntHub2 = new Point(450,200); - - Point pntRouter1 = new Point(350,200); - - if(refreshMainScreen()) - { - try - { - this.refreshMainScreen(); - isDirty = true; - - Sim.addPC(strPC1Name); - GuiPC tempPC = new GuiPC(strPC1Name,this); - tempPC.setNodeLocation(pntPC1); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC1Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.2"); - Sim.setDefaultGateway(tempPC.getName(), "192.168.0.1"); - - Sim.addPC(strPC2Name); - tempPC = new GuiPC(strPC2Name,this); - tempPC.setNodeLocation(pntPC2); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC2Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "192.168.0.3"); - Sim.setDefaultGateway(tempPC.getName(), "192.168.0.1"); - - Sim.addPC(strPC3Name); - tempPC = new GuiPC(strPC3Name, this); - tempPC.setLocation(pntPC3); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC, 3, 0); - GUInodeTable.put(strPC3Name, tempPC); - Sim.setIPAddress(tempPC.getName(), "eth0", "192.168.0.4"); - Sim.setDefaultGateway(tempPC.getName(),"192.168.0.1"); - - Sim.addHub(strHub1Name); - GuiHub tempHub = new GuiHub(strHub1Name, this); - tempHub.setLocation(pntHub1); - Sandbox.add(tempHub); - Sandbox.setLayer(tempHub, 3, 0); - GUInodeTable.put(strHub1Name, tempHub); - - Sim.addRouter(strRouter1Name); - GuiRouter tempRouter = new GuiRouter(strRouter1Name, this); - tempRouter.setLocation(pntRouter1); - Sandbox.add(tempRouter); - Sandbox.setLayer(tempRouter, 3, 0); - GUInodeTable.put(strRouter1Name, tempRouter); - Sim.setIPAddress(tempRouter.getName(), "eth0", "192.168.0.1"); - Sim.setIPAddress(tempRouter.getName(), "eth1", "10.0.0.1"); - Sim.setDefaultGateway(tempRouter.getName(),"192.168.0.1"); - - Sim.addHub(strHub2Name); - tempHub = new GuiHub(strHub2Name, this); - tempHub.setLocation(pntHub2); - Sandbox.add(tempHub); - Sandbox.setLayer(tempHub, 3, 0); - GUInodeTable.put(strHub2Name, tempHub); - - Sim.addPC(strPC4Name); - tempPC = new GuiPC(strPC4Name,this); - tempPC.setNodeLocation(pntPC4); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC4Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "10.0.0.2"); - Sim.setDefaultGateway(tempPC.getName(), "10.0.0.1"); - - Sim.addPC(strPC5Name); - tempPC = new GuiPC(strPC5Name,this); - tempPC.setNodeLocation(pntPC5); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC,3,0); - GUInodeTable.put(strPC5Name,tempPC); - Sim.setIPAddress(tempPC.getName(),"eth0", "10.0.0.3"); - Sim.setDefaultGateway(tempPC.getName(), "10.0.0.1"); - - Sim.addPC(strPC6Name); - tempPC = new GuiPC(strPC6Name, this); - tempPC.setLocation(pntPC6); - Sandbox.add(tempPC); - Sandbox.setLayer(tempPC, 3, 0); - GUInodeTable.put(strPC6Name, tempPC); - Sim.setIPAddress(tempPC.getName(), "eth0", "10.0.0.4"); - Sim.setDefaultGateway(tempPC.getName(),"10.0.0.1"); - - Sim.addEthernetLink(strLink1Name, strPC1Name, "eth0", strHub1Name, "eth0"); - Sim.addEthernetLink(strLink2Name, strPC2Name, "eth0", strHub1Name, "eth1"); - Sim.addEthernetLink(strLink3Name, strPC3Name, "eth0", strHub1Name, "eth2"); - - Sim.addEthernetLink(strLink4Name, strHub1Name, "eth3", strRouter1Name, "eth0"); - Sim.addEthernetLink(strLink5Name, strRouter1Name, "eth1", strHub2Name, "eth0"); - - Sim.addEthernetLink(strLink6Name, strHub2Name, "eth1", strPC4Name, "eth0"); - Sim.addEthernetLink(strLink7Name, strHub2Name, "eth2", strPC5Name, "eth0"); - Sim.addEthernetLink(strLink8Name, strHub2Name, "eth3", strPC6Name, "eth0"); - - this.createLink(strLink1Name, strPC1Name, strHub1Name); - this.createLink(strLink2Name, strPC2Name, strHub1Name); - this.createLink(strLink3Name, strPC3Name, strHub1Name); - this.createLink(strLink4Name, strHub1Name, strRouter1Name); - this.createLink(strLink5Name, strRouter1Name, strHub2Name); - this.createLink(strLink6Name, strHub2Name, strPC4Name); - this.createLink(strLink7Name, strHub2Name, strPC5Name); - this.createLink(strLink8Name, strHub2Name, strPC6Name); - - this.refreshNodeInformationTab(); - this.addToConsole("Simulation 4 Created Sucessfully \n"); - } - catch(Exception e) - { - // Never get here (I hope...) - } - } - } // Invokes the help menu. /** --- 1287,1291 ---- *************** *** 1771,1776 **** public void EchoServerListen(String inNodeName){ ! //String port = JOptionPane.showInputDialog(this, "Port:", "Set Echo Server listening on port.", JOptionPane.QUESTION_MESSAGE); ! String port = "7"; if(port!=null){ try{ --- 1423,1427 ---- public void EchoServerListen(String inNodeName){ ! String port = JOptionPane.showInputDialog(this, "Port:", "Set Echo Server listening on port.", JOptionPane.QUESTION_MESSAGE); if(port!=null){ try{ *************** *** 1793,1810 **** public void EchoSend(String inNodeName){ ! //String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! //String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! //String msg = JOptionPane.showInputDialog(this, "Message:", "Message.", JOptionPane.QUESTION_MESSAGE); ! String ip = "192.168.0.1"; ! String port = "7"; ! String msg = "!!!"; if(port!=null && ip!=null && msg!=null){ try{ ! ((Echo)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(7)).SendEcho(msg, ip, Integer.valueOf(port).intValue()); this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); }catch(Exception e){ ! addToConsole(e.toString()); } ! } } --- 1444,1460 ---- public void EchoSend(String inNodeName){ ! String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! String msg = JOptionPane.showInputDialog(this, "Message:", "Message.", JOptionPane.QUESTION_MESSAGE); if(port!=null && ip!=null && msg!=null){ try{ ! printNetworkStart(); ! ((Echo)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(0)).SendEcho(msg, ip, Integer.valueOf(port).intValue()); this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); }catch(Exception e){ ! addToConsole(e.toString()); } ! printLayerInfo(); ! } } |