javanetsim-cvs Mailing List for javaNetSim (Page 34)
Status: Beta
Brought to you by:
darkkey
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(120) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(1) |
Feb
(69) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(76) |
Oct
(28) |
Nov
(77) |
Dec
(186) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(36) |
Oct
(61) |
Nov
(23) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(17) |
Oct
(105) |
Nov
(5) |
Dec
(1) |
2009 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(9) |
Nov
|
Dec
|
From: Alexander B. <da...@us...> - 2005-11-20 15:17:46
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17983/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Udp.java 20 Nov 2005 14:26:59 -0000 1.15 --- Udp.java 20 Nov 2005 15:17:35 -0000 1.16 *************** *** 632,633 **** --- 632,634 ---- } //EOF + |
From: Alouette <alo...@us...> - 2005-11-20 14:31:24
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7648/core/protocolsuite/tcp_ip/ospf Modified Files: OSPFhello_packet.java ospf_packetheader.java Log Message: Index: OSPFhello_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFhello_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OSPFhello_packet.java 20 Nov 2005 11:09:42 -0000 1.2 --- OSPFhello_packet.java 20 Nov 2005 14:31:16 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- package core.protocolsuite.tcp_ip.ospf; + import core.protocolsuite.tcp_ip.ospf.ospf_packetheader; /** *************** *** 15,23 **** * @author Alouette */ ! public class OSPFhello_packet { ! /** Creates a new instance of OSPFhello_packet */ ! public OSPFhello_packet() { } } --- 16,106 ---- * @author Alouette */ ! public class OSPFhello_packet extends ospf_packetheader { ! ! private int[] Options; ! ! private String Networkmask; //do not forget to correct field type ! /* TODO */ ! private static final int Interval=30; // period of sending packets ??! ! private int Priority; ! private int DeadInterval; ! private String DesignatedRouter; // 0 - not chosen yet ! ! private String BackupDesignatedRouter; //0 - not chosen yet ! /* todo */ /* need to be list*/ ! private String[] Neighbor; ! /** Creates a new instance of OSPFhello_packet */ ! public OSPFhello_packet(int NeighborCount) ! { ! super(1); ! int i; ! Options=new int[8]; ! for (i=0; i<8; i++) ! { ! Options[i]=0; ! } ! BackupDesignatedRouter=""; ! DesignatedRouter=""; ! if (NeighborCount>0) ! { ! Neighbor = new String[NeighborCount]; ! } ! } + + /* + *This method set desR + *@author Alouette + *returns nothing + *v1.0 + */ + public void SetDesignatedRouter(String inDesignatedRouter) + { + DesignatedRouter=inDesignatedRouter; + } + + /* + *This method set BackupdesR + *@author Alouette + *returns nothing + *v1.0 + */ + public void SetBackupDesignatedRouter(String inBackupDesignatedRouter) + { + BackupDesignatedRouter=inBackupDesignatedRouter; + } + + /* + *This method set priority + *@author Alouette + *returns nothing + *v1.0 + */ + public void Setpriority(int inpri) + { + Priority=inpri; + } + + /* + *This method get priority + *@author Alouette + *returns nothing + *v1.0 + */ + public int GetPriority() + { + return Priority; + } + + /*TODO + /* + *This method add neighbor to the neighbor table in hello message + *This message is for another router, in the start time this is empty table + *@author Alouette + *returns nothing + *v1.0 + */ } + Index: ospf_packetheader.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/ospf_packetheader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ospf_packetheader.java 20 Nov 2005 11:09:42 -0000 1.2 --- ospf_packetheader.java 20 Nov 2005 14:31:16 -0000 1.3 *************** *** 43,46 **** --- 43,60 ---- } + + /** + * this method parametred constructor + * @author alouette (sourceforge.net user) + * @returns Cheksum + * @version 1.0 + */ + + public ospf_packetheader(int inType) + { + Checksum=1; + Type=inType; + Authentication=""; + } /** * this method returns checksum |
From: gift <gi...@us...> - 2005-11-20 14:27:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6250/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Udp.java 20 Nov 2005 14:21:58 -0000 1.14 --- Udp.java 20 Nov 2005 14:26:59 -0000 1.15 *************** *** 394,409 **** Elm.connectedtoIP=inDestIPAddress; Elm.connectedtoPort=indestPort; - /*<<<<<<< Udp.java - Elm.application = application; //GIFT: UGLY BUG!!!! - //PortTable.remove(new Integer(number+PORT_START_NUMBER)); //delete old element - //PortTable.put(new Integer(number+PORT_START_NUMBER),Elm); //hash table update - try{ - UDP_HashTableElement Elm1 = null; - Elm1 = (UDP_HashTableElement) PortTable.get(new Integer(number+PORT_START_NUMBER)); - System.out.println(Elm1.PortStatus); - }catch(Exception e){System.out.println("!!!");} - =======*/ Elm.application = application; - //>>>>>>> 1.9 } if (!Reserved) number++; --- 394,398 ---- *************** *** 527,533 **** UDP_HashTableElement Elm = null; ! if ( ((UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { ! Elm =(UDP_HashTableElement)PortTable.get(inPort); switch(Elm.PortStatus) { --- 516,521 ---- UDP_HashTableElement Elm = null; ! if ( (Elm =(UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { switch(Elm.PortStatus) { *************** *** 586,605 **** public String getApplicationDestIP(int inSrcPort) throws TransportLayerException { ! String dIP=null;/* ! <<<<<<< Udp.java ! boolean Found=false; ! Set set = PortTable.keySet(); ! Iterator itr = set.iterator(); ! ! UDP_HashTableElement ElmDBG = (UDP_HashTableElement)PortTable.get(new Integer(3000)); ! ! System.out.println(ElmDBG.PortStatus); ! Enumeration keys = PortTable.elements(); ! ! //Integer key = Integer.valueOf(keys.nextElement()); ! ! //System.out.println(key); ! ======= ! >>>>>>> 1.12*/ UDP_HashTableElement Elm = null; --- 574,578 ---- public String getApplicationDestIP(int inSrcPort) throws TransportLayerException { ! String dIP=null; UDP_HashTableElement Elm = null; |
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(); ! } } |
From: Alexander B. <da...@us...> - 2005-11-20 14:22:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5202/core/protocolsuite/tcp_ip Modified Files: Echo.java Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Udp.java 20 Nov 2005 14:07:13 -0000 1.13 --- Udp.java 20 Nov 2005 14:21:58 -0000 1.14 *************** *** 394,398 **** --- 394,409 ---- Elm.connectedtoIP=inDestIPAddress; Elm.connectedtoPort=indestPort; + /*<<<<<<< Udp.java + Elm.application = application; //GIFT: UGLY BUG!!!! + //PortTable.remove(new Integer(number+PORT_START_NUMBER)); //delete old element + //PortTable.put(new Integer(number+PORT_START_NUMBER),Elm); //hash table update + try{ + UDP_HashTableElement Elm1 = null; + Elm1 = (UDP_HashTableElement) PortTable.get(new Integer(number+PORT_START_NUMBER)); + System.out.println(Elm1.PortStatus); + }catch(Exception e){System.out.println("!!!");} + =======*/ Elm.application = application; + //>>>>>>> 1.9 } if (!Reserved) number++; *************** *** 516,521 **** UDP_HashTableElement Elm = null; ! if ( (Elm =(UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { switch(Elm.PortStatus) { --- 527,533 ---- UDP_HashTableElement Elm = null; ! if ( ((UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { ! Elm =(UDP_HashTableElement)PortTable.get(inPort); switch(Elm.PortStatus) { *************** *** 557,561 **** newElm.connectedtoPort=0; ! PortTable.put(inPort,Elm); //hash table update } } else throw new TransportLayerException("UDP Error: can not listen to port "+ inPort +"! Use port range from 0 to 10000 to listen to."); --- 569,573 ---- newElm.connectedtoPort=0; ! PortTable.put(inPort,newElm); //hash table update } } else throw new TransportLayerException("UDP Error: can not listen to port "+ inPort +"! Use port range from 0 to 10000 to listen to."); *************** *** 574,578 **** public String getApplicationDestIP(int inSrcPort) throws TransportLayerException { ! String dIP=null; UDP_HashTableElement Elm = null; --- 586,605 ---- public String getApplicationDestIP(int inSrcPort) throws TransportLayerException { ! String dIP=null;/* ! <<<<<<< Udp.java ! boolean Found=false; ! Set set = PortTable.keySet(); ! Iterator itr = set.iterator(); ! ! UDP_HashTableElement ElmDBG = (UDP_HashTableElement)PortTable.get(new Integer(3000)); ! ! System.out.println(ElmDBG.PortStatus); ! Enumeration keys = PortTable.elements(); ! ! //Integer key = Integer.valueOf(keys.nextElement()); ! ! //System.out.println(key); ! ======= ! >>>>>>> 1.12*/ UDP_HashTableElement Elm = null; Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Echo.java 19 Nov 2005 21:53:51 -0000 1.7 --- Echo.java 20 Nov 2005 14:21:58 -0000 1.8 *************** *** 113,120 **** --- 113,122 ---- //client processing recieve // printing some ... + System.out.println(Data); Disconnect(); }else{ //server processing recieve try{ + System.out.println(Data); SendData(Data); Close(); *************** *** 136,139 **** --- 138,142 ---- public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ ClientConnect(Host, port); + SendData(Data); } |
From: gift <gi...@us...> - 2005-11-20 14:07:26
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2019/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: bad style removed.... maybe bad, maybe not Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Udp.java 20 Nov 2005 13:51:31 -0000 1.12 --- Udp.java 20 Nov 2005 14:07:13 -0000 1.13 *************** *** 446,457 **** public void ClosePort(Object application) throws TransportLayerException //changes port status from 1 (listen) to 0 (free) { ! UDP_HashTableElement oldElm=null; Integer PortToClose=getApplicationLocalPortNumber(application); ! oldElm=(UDP_HashTableElement) PortTable.get((Integer)PortToClose); ! if (oldElm.PortStatus==1) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=0; Elm.application=null; --- 446,457 ---- public void ClosePort(Object application) throws TransportLayerException //changes port status from 1 (listen) to 0 (free) { ! UDP_HashTableElement Elm=null; Integer PortToClose=getApplicationLocalPortNumber(application); ! Elm=(UDP_HashTableElement) PortTable.get((Integer)PortToClose); ! if (Elm.PortStatus==1) { ! //UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=0; Elm.application=null; *************** *** 459,464 **** Elm.connectedtoPort=0; ! PortTable.remove(PortToClose); //delete old element ! PortTable.put(PortToClose,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } --- 459,464 ---- Elm.connectedtoPort=0; ! //PortTable.remove(PortToClose); //delete old element ! //PortTable.put(PortToClose,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } *************** *** 475,486 **** public void FreePort(Object application) throws TransportLayerException //changes port status from 3 (listen) to 0 (free) { ! UDP_HashTableElement oldElm=null; Integer PortToFree=getApplicationLocalPortNumber(application); ! oldElm=(UDP_HashTableElement) PortTable.get((Integer)PortToFree); ! if (oldElm.PortStatus==2) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=0; Elm.application=null; --- 475,486 ---- public void FreePort(Object application) throws TransportLayerException //changes port status from 3 (listen) to 0 (free) { ! UDP_HashTableElement Elm=null; Integer PortToFree=getApplicationLocalPortNumber(application); ! Elm=(UDP_HashTableElement) PortTable.get((Integer)PortToFree); ! if (Elm.PortStatus==2) { ! //UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=0; Elm.application=null; *************** *** 488,493 **** Elm.connectedtoPort=0; ! PortTable.remove(PortToFree); //delete old element ! PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } --- 488,493 ---- Elm.connectedtoPort=0; ! //PortTable.remove(PortToFree); //delete old element ! //PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } *************** *** 513,527 **** if (inPort>=0 && inPort<=10000) { ! UDP_HashTableElement oldElm = null; ! ! if ( (UDP_HashTableElement)PortTable.get(inPort) !=null ) ! { ! oldElm = (UDP_HashTableElement)PortTable.get(inPort); ! switch(oldElm.PortStatus) { case 0: //port is free => update such a record in hashtable ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=1; Elm.application=application; --- 513,526 ---- if (inPort>=0 && inPort<=10000) { ! //UDP_HashTableElement oldElm = null; ! UDP_HashTableElement Elm = null; ! if ( (Elm =(UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { ! switch(Elm.PortStatus) { case 0: //port is free => update such a record in hashtable ! //UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=1; Elm.application=application; *************** *** 529,539 **** Elm.connectedtoPort=0; ! PortTable.remove(inPort); //delete old element ! PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? int UID1=-2; int UID2=-1; ! UID1=((Application)oldElm.application).getUID(); UID2=((Application)application).getUID(); --- 528,538 ---- Elm.connectedtoPort=0; ! //PortTable.remove(inPort); //delete old element ! //PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? int UID1=-2; int UID2=-1; ! UID1=((Application)Elm.application).getUID(); UID2=((Application)application).getUID(); *************** *** 552,560 **** { //create such a record in hashtable ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! Elm.PortStatus=1; ! Elm.application=application; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; PortTable.put(inPort,Elm); //hash table update --- 551,559 ---- { //create such a record in hashtable ! UDP_HashTableElement newElm = new UDP_HashTableElement(); ! newElm.PortStatus=1; ! newElm.application=application; ! newElm.connectedtoIP=""; ! newElm.connectedtoPort=0; PortTable.put(inPort,Elm); //hash table update |
From: gift <gi...@us...> - 2005-11-20 13:51:41
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30333/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: 1 comment deleted :) Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Udp.java 20 Nov 2005 13:49:29 -0000 1.11 --- Udp.java 20 Nov 2005 13:51:31 -0000 1.12 *************** *** 538,542 **** UID2=((Application)application).getUID(); ! if (UID1==UID2) //no UID required here :) check before update! { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); --- 538,542 ---- UID2=((Application)application).getUID(); ! if (UID1==UID2) { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); |
From: gift <gi...@us...> - 2005-11-20 13:49:37
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29914/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: UID added Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Udp.java 20 Nov 2005 13:43:57 -0000 1.10 --- Udp.java 20 Nov 2005 13:49:29 -0000 1.11 *************** *** 533,537 **** break; case 1: // port is being listened to by whom? ! if (oldElm.application==application) //no UID required here :) check before update! { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); --- 533,542 ---- break; case 1: // port is being listened to by whom? ! int UID1=-2; ! int UID2=-1; ! UID1=((Application)oldElm.application).getUID(); ! UID2=((Application)application).getUID(); ! ! if (UID1==UID2) //no UID required here :) check before update! { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); |
From: gift <gi...@us...> - 2005-11-20 13:44:06
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28544/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Udp.java Log Message: Now it's working pretty good! Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ProtocolStack.java 20 Nov 2005 10:25:26 -0000 1.9 --- ProtocolStack.java 20 Nov 2005 13:43:57 -0000 1.10 *************** *** 748,752 **** UDP_packet temp = (UDP_packet)inPacket; ! System.out.println("UDP packet here trying to pass up!!!!"); try{ mUDPprotocol.receiveUDPPacket(temp); --- 748,752 ---- UDP_packet temp = (UDP_packet)inPacket; ! System.out.println("UDP packet here Receiving!!!! Message from ProtocolStack."); try{ mUDPprotocol.receiveUDPPacket(temp); *************** *** 1298,1331 **** * @exception CommunicationException * @exception LowLinkException ! * @exception InvalidNetworkLayerDeviceException ! * @exception TransportLayerException ! * @version v0.30 * @see CommunicationException * @see LowLinkException - * @see InvalidNetworkLayerDeviceException - * @see TransportLayerException */ public void sendUDP(Object application, String inUDPMessage) throws LowLinkException, CommunicationException ! { ! ! //lets get first network interface name ! //will be used when resolving source IP of UDP sender String FirstInterfaceName; String DestIPAddress; int destPort; Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); ! try{ ! System.out.println("Trying to send!!!!!!!"); ! DestIPAddress=mUDPprotocol.getApplicationDestIP(application); ! destPort=mUDPprotocol.getApplicationDestPortNumber(application); if (FirstInterfaceName!=null) { if(IPV4Address.validateDecIP(DestIPAddress)) ! { ! UDP_packet tosend = mUDPprotocol.sendUDPPacket(application, DestIPAddress,FirstInterfaceName,destPort,inUDPMessage); sendPacket(tosend); }else --- 1298,1334 ---- * @exception CommunicationException * @exception LowLinkException ! * @version v0.40 * @see CommunicationException * @see LowLinkException */ public void sendUDP(Object application, String inUDPMessage) throws LowLinkException, CommunicationException ! { String FirstInterfaceName; String DestIPAddress; + String SourceIPAddress; + int srcPort; int destPort; + + //lets get first network interface name Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); ! try{ ! //let's get a reserved local port number for this application ! srcPort=mUDPprotocol.getApplicationLocalPortNumber(application); ! //and destination IP of the other host ! DestIPAddress=mUDPprotocol.getApplicationDestIP(srcPort); ! //and destination port of the other host ! destPort=mUDPprotocol.getApplicationDestPortNumber(srcPort); if (FirstInterfaceName!=null) { if(IPV4Address.validateDecIP(DestIPAddress)) ! { ! //let's get first interface IP address ! SourceIPAddress=getIPAddress(FirstInterfaceName); ! ! UDP_packet tosend = mUDPprotocol.sendUDPPacket(DestIPAddress,SourceIPAddress,destPort,srcPort,inUDPMessage); sendPacket(tosend); }else Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Udp.java 20 Nov 2005 10:25:26 -0000 1.9 --- Udp.java 20 Nov 2005 13:43:57 -0000 1.10 *************** *** 149,153 **** --- 149,158 ---- public Udp(ProtocolStack inParentStack) { + //String i; //String is port number :( such a pity but we use hash tables + //int j; //port number int i; + + for(i=0;i<PORT_QUANT;i++) + { UDP_HashTableElement Elm = new UDP_HashTableElement(); *************** *** 158,163 **** mParentStack = inParentStack; ! for(i=0;i<PORT_QUANT;i++) ! { PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // CHECK HERE } --- 163,167 ---- mParentStack = inParentStack; ! PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // CHECK HERE } *************** *** 194,198 **** //let's check all the things dealing with destination port number ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm=(UDP_HashTableElement)PortTable.get(inPacket.get_destPort()); --- 198,202 ---- //let's check all the things dealing with destination port number ! UDP_HashTableElement Elm = null; Elm=(UDP_HashTableElement)PortTable.get(inPacket.get_destPort()); *************** *** 240,244 **** case 2: //busy port, let's check whether it's busy by us (sender) ;) ! if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) //temporary { //now we decompose UDP datagram --- 244,248 ---- case 2: //busy port, let's check whether it's busy by us (sender) ;) ! if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { //now we decompose UDP datagram *************** *** 287,295 **** * @author gift (sourceforge.net user) * @param inDestIPAddress destination IP address ! * @param FirstInterfaceName name of the first network intarface of the node that sends UDP e.g. "eth0" * @param indestPort destination port number ! * @param application application that uses port * @param inMessage UDP message to send ! * @return UDP_packet * @exception TransportLayerException * @version v0.30 --- 291,299 ---- * @author gift (sourceforge.net user) * @param inDestIPAddress destination IP address ! * @param inSourceIPAddress our IP address * @param indestPort destination port number ! * @param insrcPort our port number * @param inMessage UDP message to send ! * @return UDP_packet to send in Network Layer * @exception TransportLayerException * @version v0.30 *************** *** 297,328 **** */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException, LowLinkException { ! int srcPort; ! String SrcIP; ! ! //let's get first interface IP address ! SrcIP=mParentStack.getIPAddress(inFirstInterfaceName); ! ! //let's get a reserved local port number for this application ! srcPort=getApplicationLocalPortNumber(application); ! ! ! UDP_packet tosend = new UDP_packet(inDestIPAddress,SrcIP,indestPort,srcPort); tosend.setUDP_message(inMessage); //Create Layer info - LayerInfo UDP_Info = new LayerInfo(getClass().getName()); - UDP_Info.setObjectName(mParentStack.getParentNodeName()); - UDP_Info.setDataType("UDP Packet"); - UDP_Info.setLayer("Transport"); ! ! UDP_Info.setDescription("Created UDP packet to " + inDestIPAddress + ":" + srcPort +"."); ! Simulation.addLayerInfo(UDP_Info); --- 301,317 ---- */ ! public UDP_packet sendUDPPacket(String inDestIPAddress,String inSourceIPAddress, int indestPort, int insrcPort, String inMessage) throws TransportLayerException, LowLinkException { ! ! UDP_packet tosend = new UDP_packet(inDestIPAddress,inSourceIPAddress,indestPort,insrcPort); tosend.setUDP_message(inMessage); //Create Layer info LayerInfo UDP_Info = new LayerInfo(getClass().getName()); UDP_Info.setObjectName(mParentStack.getParentNodeName()); UDP_Info.setDataType("UDP Packet"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet for " + inDestIPAddress + ":" + insrcPort +"."); Simulation.addLayerInfo(UDP_Info); *************** *** 344,348 **** * @see TransportLayerException */ ! public int getDefinitePortNumber(Object application,String inDestIPAddress, int indestPort) throws TransportLayerException { Integer number = new Integer(0); --- 333,337 ---- * @see TransportLayerException */ ! public int ReservePort(Object application,String inDestIPAddress, int indestPort) throws TransportLayerException { Integer number = new Integer(0); *************** *** 394,401 **** { //lets try to reserve any free port ! number=0; ! while ( (number<PORT_QUANT) && !(Reserved) ) { ! Elm = (UDP_HashTableElement) PortTable.get(number+PORT_START_NUMBER); if (Elm.PortStatus == 0) //free port --- 383,390 ---- { //lets try to reserve any free port ! number=PORT_START_NUMBER; ! while ( (number<PORT_START_NUMBER+PORT_QUANT) && !(Reserved) ) { ! Elm = (UDP_HashTableElement) PortTable.get((Integer)number); if (Elm.PortStatus == 0) //free port *************** *** 407,411 **** Elm.application = application; } ! number++; } --- 396,400 ---- Elm.application = application; } ! if (!Reserved) number++; } *************** *** 414,483 **** throw new TransportLayerException("UDP Error: all ports are busy! Can not send UDP datagram to host " + inDestIPAddress + ":" + indestPort +"."); } ! number+=PORT_START_NUMBER; //to get the real number ! } return (number); //do not change here! if you want to change here scan again the code } ! ! /** ! * This method reserves LOCAL UDP port ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @param inDestIPAddress destination IP address ! * @param indestPort destination port number ! * @return int port number that has been reserved for application ! * @exception TransportLayerException ! * @version v0.30 ! * @see TransportLayerException ! */ ! public int ReservePort(Object application, String inDestIPAddress, int indestPort) throws TransportLayerException ! { ! //let's get a proper port number for this application ! return getDefinitePortNumber(application,inDestIPAddress,indestPort); ! } ! /** * This method finds port number for an application. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] * @author gift (sourceforge.net user) ! * @param application ! * @return int port number that has been reserved for application * @exception TransportLayerException ! * @version v0.10 * @see TransportLayerException */ ! public int getApplicationDestPortNumber(Object application) throws TransportLayerException { int number=0; ! boolean Found=false; ! Set set = PortTable.keySet(); ! Iterator itr = set.iterator(); ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! ! while ( (itr.hasNext()) && !(Found) ) ! { ! Elm = (UDP_HashTableElement) itr.next(); ! ! int UID1 = -2; ! int UID2 = -1; ! ! if(Elm.application!=null && application!=null){ ! UID1 = ((Application)Elm.application).getUID(); ! UID2 = ((Application)application).getUID(); ! } ! ! if ( UID1 == UID2 ) ! { ! Found=true; ! //we have found our application ! number=Elm.connectedtoPort; ! } ! } ! //in case we have not found our application in hash table..... ! if (!Found) ! { ! throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination port."); ! } ! return new Integer(number); } --- 403,436 ---- throw new TransportLayerException("UDP Error: all ports are busy! Can not send UDP datagram to host " + inDestIPAddress + ":" + indestPort +"."); } ! ! } ! ! //For debugging ! UDP_HashTableElement Elm2 = new UDP_HashTableElement();//For debugging ! Elm2 = (UDP_HashTableElement) PortTable.get((Integer)number+1);//For debugging return (number); //do not change here! if you want to change here scan again the code + + } ! /** * This method finds port number for an application. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] * @author gift (sourceforge.net user) ! * @param inSrcPort port number that has been reserved for the applicaion ! * @return int port number of the other host (that the application is connected to) * @exception TransportLayerException ! * @version v0.20 * @see TransportLayerException */ ! public int getApplicationDestPortNumber(int inSrcPort) throws TransportLayerException { int number=0; ! UDP_HashTableElement Elm = null; ! Elm=(UDP_HashTableElement)PortTable.get((Integer)inSrcPort); ! number=Elm.connectedtoPort; ! ! return number; } *************** *** 493,509 **** public void ClosePort(Object application) throws TransportLayerException //changes port status from 1 (listen) to 0 (free) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Integer PortToClose=getApplicationLocalPortNumber(application); ! if (Elm.PortStatus==1) { ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! //PortTable.remove(PortToClose); //delete old element ! //PortTable.put(PortToClose,Elm); //hash table update ! } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } --- 446,465 ---- public void ClosePort(Object application) throws TransportLayerException //changes port status from 1 (listen) to 0 (free) { ! UDP_HashTableElement oldElm=null; Integer PortToClose=getApplicationLocalPortNumber(application); ! oldElm=(UDP_HashTableElement) PortTable.get((Integer)PortToClose); ! ! if (oldElm.PortStatus==1) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! PortTable.remove(PortToClose); //delete old element ! PortTable.put(PortToClose,Elm); //hash table update ! } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } *************** *** 519,534 **** public void FreePort(Object application) throws TransportLayerException //changes port status from 3 (listen) to 0 (free) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Integer PortToFree=getApplicationLocalPortNumber(application); ! if (Elm.PortStatus==2) ! { ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! //PortTable.remove(PortToFree); //delete old element ! //PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } --- 475,493 ---- public void FreePort(Object application) throws TransportLayerException //changes port status from 3 (listen) to 0 (free) { ! UDP_HashTableElement oldElm=null; Integer PortToFree=getApplicationLocalPortNumber(application); ! oldElm=(UDP_HashTableElement) PortTable.get((Integer)PortToFree); ! ! if (oldElm.PortStatus==2) ! { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! PortTable.remove(PortToFree); //delete old element ! PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } *************** *** 554,567 **** if (inPort>=0 && inPort<=10000) { ! UDP_HashTableElement Elm = new UDP_HashTableElement(); if ( (UDP_HashTableElement)PortTable.get(inPort) !=null ) { ! Elm = (UDP_HashTableElement)PortTable.get(inPort); ! switch(Elm.PortStatus) { case 0: //port is free => update such a record in hashtable ! Elm.PortStatus=1; Elm.application=application; --- 513,527 ---- if (inPort>=0 && inPort<=10000) { ! UDP_HashTableElement oldElm = null; if ( (UDP_HashTableElement)PortTable.get(inPort) !=null ) { ! oldElm = (UDP_HashTableElement)PortTable.get(inPort); ! switch(oldElm.PortStatus) { case 0: //port is free => update such a record in hashtable ! ! UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=1; Elm.application=application; *************** *** 569,577 **** Elm.connectedtoPort=0; ! //PortTable.remove(inPort); //delete old element ! //PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? ! if (Elm.application==application) { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); --- 529,537 ---- Elm.connectedtoPort=0; ! PortTable.remove(inPort); //delete old element ! PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? ! if (oldElm.application==application) //no UID required here :) check before update! { throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); *************** *** 587,590 **** --- 547,551 ---- { //create such a record in hashtable + UDP_HashTableElement Elm = new UDP_HashTableElement(); Elm.PortStatus=1; Elm.application=application; *************** *** 601,653 **** * This method finds destination IP (host) for an application. * @author gift (sourceforge.net user) ! * @param application ! * @return String destination IP that has been reserved for application * @exception TransportLayerException ! * @version v0.10 * @see TransportLayerException */ ! public String getApplicationDestIP(Object application) throws TransportLayerException { String dIP=null; - boolean Found=false; - Set set = PortTable.keySet(); - Iterator itr = set.iterator(); - //Enumeration keys = PortTable.elements(); - //Integer key = null; UDP_HashTableElement Elm = null; - while ( (itr.hasNext()) && !(Found) ) //keys.hasMoreElements() - { - try{ - //key = new Integer((Integer) keys.nextElement()); - //Elm = (UDP_HashTableElement) PortTable.get(key); - System.out.println("Getting next itr!!!!!!!"); - Elm=(UDP_HashTableElement)itr.next(); - System.out.println("GOT ITR!!!!!!!"); - }catch(Exception ex){ System.out.println(ex.toString()); } - - int UID1 = -2; - int UID2 = -1; - - if(Elm!=null && application!=null){ - if(Elm.application!=null) UID1 = ((Application)Elm.application).getUID(); - UID2 = ((Application)application).getUID(); - } - - if ( UID1 == UID2 ) - { - Found=true; - //we have found our application - dIP=Elm.connectedtoIP; - } - - - } - - //in case we have not found our application in hash table..... - if (!Found) - { - throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination IP."); - } return dIP; } --- 562,579 ---- * This method finds destination IP (host) for an application. * @author gift (sourceforge.net user) ! * @param inSrcPort port number that has been reserved for the applicaion ! * @return String destination IP (other host IP that the application is connected to) * @exception TransportLayerException ! * @version v0.20 * @see TransportLayerException */ ! public String getApplicationDestIP(int inSrcPort) throws TransportLayerException { String dIP=null; UDP_HashTableElement Elm = null; + + Elm=(UDP_HashTableElement)PortTable.get((Integer)inSrcPort); + dIP=Elm.connectedtoIP; return dIP; } *************** *** 665,677 **** public int getApplicationLocalPortNumber(Object application) throws TransportLayerException { ! int number=0; boolean Found=false; boolean Reserved=false; Enumeration LocalPorts = PortTable.keys(); ! UDP_HashTableElement Elm = new UDP_HashTableElement(); while ( (LocalPorts.hasMoreElements()) && !(Found) ) { ! number = Integer.valueOf( (String)LocalPorts.nextElement() ); Elm = (UDP_HashTableElement) PortTable.get(number); --- 591,603 ---- public int getApplicationLocalPortNumber(Object application) throws TransportLayerException { ! Integer number= new Integer(0); boolean Found=false; boolean Reserved=false; Enumeration LocalPorts = PortTable.keys(); ! UDP_HashTableElement Elm = null; while ( (LocalPorts.hasMoreElements()) && !(Found) ) { ! number = (Integer)LocalPorts.nextElement(); Elm = (UDP_HashTableElement) PortTable.get(number); |
From: Alexander B. <da...@us...> - 2005-11-20 11:10:05
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28572/ospf Modified Files: OSPFhello_packet.java ospf_packetheader.java Log Message: Index: OSPFhello_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFhello_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPFhello_packet.java 19 Nov 2005 13:27:12 -0000 1.1 --- OSPFhello_packet.java 20 Nov 2005 11:09:42 -0000 1.2 *************** *** 2,6 **** * OSPFhello_packet.java * ! * Created on 19 Íîÿáðü 2005 ã., 12:57 * * To change this template, choose Tools | Options and locate the template under --- 2,6 ---- * OSPFhello_packet.java * ! * Created on 19 Nov 2005, 12:57 * * To change this template, choose Tools | Options and locate the template under Index: ospf_packetheader.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/ospf_packetheader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ospf_packetheader.java 19 Nov 2005 13:27:12 -0000 1.1 --- ospf_packetheader.java 20 Nov 2005 11:09:42 -0000 1.2 *************** *** 2,6 **** * ospf_packetheader.java * ! * Created on 19 Íîÿáðü 2005 ã., 13:03 * * To change this template, choose Tools | Options and locate the template under --- 2,6 ---- * ospf_packetheader.java * ! * Created on 19 Nov 2005, 13:03 * * To change this template, choose Tools | Options and locate the template under *************** *** 26,31 **** protected int AreaID; protected int Checksum; // for future developing ! protected int AuthenticationType; // if 0 - authentication without password, ! // if 1 - authentication with password protected String Authentication; // for development --- 26,31 ---- protected int AreaID; protected int Checksum; // for future developing ! protected boolean AuthenticationType; // if false - authentication without password, ! // if true - authentication with password protected String Authentication; // for development *************** *** 77,81 **** * @version 1.0 */ ! protected int GetAuthenticationType() { return AuthenticationType; --- 77,81 ---- * @version 1.0 */ ! protected boolean GetAuthenticationType() { return AuthenticationType; |
From: gift <gi...@us...> - 2005-11-20 10:25:33
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19822/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Udp.java Log Message: Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ProtocolStack.java 19 Nov 2005 21:53:51 -0000 1.8 --- ProtocolStack.java 20 Nov 2005 10:25:26 -0000 1.9 *************** *** 748,752 **** UDP_packet temp = (UDP_packet)inPacket; ! try{ mUDPprotocol.receiveUDPPacket(temp); --- 748,752 ---- UDP_packet temp = (UDP_packet)inPacket; ! System.out.println("UDP packet here trying to pass up!!!!"); try{ mUDPprotocol.receiveUDPPacket(temp); *************** *** 1319,1322 **** --- 1319,1323 ---- try{ + System.out.println("Trying to send!!!!!!!"); DestIPAddress=mUDPprotocol.getApplicationDestIP(application); destPort=mUDPprotocol.getApplicationDestPortNumber(application); Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Udp.java 20 Nov 2005 07:55:48 -0000 1.8 --- Udp.java 20 Nov 2005 10:25:26 -0000 1.9 *************** *** 207,212 **** Elm.connectedtoPort=inPacket.get_srcPort(); ! PortTable.remove(inPacket.get_destPort()); //delete old element ! PortTable.put(new Integer(inPacket.get_destPort()),Elm); //hash table update //now we decompose UDP datagram --- 207,212 ---- Elm.connectedtoPort=inPacket.get_srcPort(); ! //PortTable.remove(inPacket.get_destPort()); //delete old element ! //PortTable.put(new Integer(inPacket.get_destPort()),Elm); //hash table update //now we decompose UDP datagram *************** *** 405,411 **** Elm.connectedtoIP=inDestIPAddress; Elm.connectedtoPort=indestPort; ! Elm.application = application; //GIFT: UGLY BUG!!!! ! PortTable.remove(new Integer(number+PORT_START_NUMBER)); //delete old element ! PortTable.put(new Integer(number+PORT_START_NUMBER),Elm); //hash table update } number++; --- 405,409 ---- Elm.connectedtoIP=inDestIPAddress; Elm.connectedtoPort=indestPort; ! Elm.application = application; } number++; *************** *** 505,510 **** Elm.connectedtoPort=0; ! PortTable.remove(PortToClose); //delete old element ! PortTable.put(PortToClose,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } --- 503,508 ---- Elm.connectedtoPort=0; ! //PortTable.remove(PortToClose); //delete old element ! //PortTable.put(PortToClose,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); } *************** *** 531,536 **** Elm.connectedtoPort=0; ! PortTable.remove(PortToFree); //delete old element ! PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } --- 529,534 ---- Elm.connectedtoPort=0; ! //PortTable.remove(PortToFree); //delete old element ! //PortTable.put(PortToFree,Elm); //hash table update } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); } *************** *** 571,576 **** Elm.connectedtoPort=0; ! PortTable.remove(inPort); //delete old element ! PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? --- 569,574 ---- Elm.connectedtoPort=0; ! //PortTable.remove(inPort); //delete old element ! //PortTable.put(inPort,Elm); //hash table update break; case 1: // port is being listened to by whom? *************** *** 624,628 **** //key = new Integer((Integer) keys.nextElement()); //Elm = (UDP_HashTableElement) PortTable.get(key); ! Elm = (UDP_HashTableElement) itr.next(); }catch(Exception ex){ System.out.println(ex.toString()); } --- 622,628 ---- //key = new Integer((Integer) keys.nextElement()); //Elm = (UDP_HashTableElement) PortTable.get(key); ! System.out.println("Getting next itr!!!!!!!"); ! Elm=(UDP_HashTableElement)itr.next(); ! System.out.println("GOT ITR!!!!!!!"); }catch(Exception ex){ System.out.println(ex.toString()); } |
From: Alexander B. <da...@us...> - 2005-11-20 07:55:56
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24230/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Udp.java 19 Nov 2005 21:53:51 -0000 1.7 --- Udp.java 20 Nov 2005 07:55:48 -0000 1.8 *************** *** 138,142 **** private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private static final int PORT_QUANT=100; private static final int PORT_START_NUMBER=3000; --- 138,142 ---- private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private static final int PORT_QUANT=2; //should be 100, only for dbg purposes private static final int PORT_START_NUMBER=3000; *************** *** 160,164 **** for(i=0;i<PORT_QUANT;i++) { ! PortTable.put((PORT_START_NUMBER+i),Elm); // CHECK HERE } } --- 160,164 ---- for(i=0;i<PORT_QUANT;i++) { ! PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // CHECK HERE } } *************** *** 208,212 **** PortTable.remove(inPacket.get_destPort()); //delete old element ! PortTable.put((inPacket.get_destPort()),Elm); //hash table update //now we decompose UDP datagram --- 208,212 ---- PortTable.remove(inPacket.get_destPort()); //delete old element ! PortTable.put(new Integer(inPacket.get_destPort()),Elm); //hash table update //now we decompose UDP datagram *************** *** 346,350 **** public int getDefinitePortNumber(Object application,String inDestIPAddress, int indestPort) throws TransportLayerException { ! int number=0; boolean Found=false; boolean Reserved=false; --- 346,350 ---- public int getDefinitePortNumber(Object application,String inDestIPAddress, int indestPort) throws TransportLayerException { ! Integer number = new Integer(0); boolean Found=false; boolean Reserved=false; *************** *** 355,364 **** while ( (LocalPorts.hasMoreElements()) && !(Found) ) ! { ! number = Integer.valueOf( (String)LocalPorts.nextElement() ); Elm = (UDP_HashTableElement) PortTable.get(number); ! if (Elm.application == application) { Found=true; --- 355,373 ---- while ( (LocalPorts.hasMoreElements()) && !(Found) ) ! { ! number = (Integer) LocalPorts.nextElement(); ! Elm = (UDP_HashTableElement) PortTable.get(number); ! int UID1 = -2; ! int UID2 = -1; ! ! if(Elm.application!=null && application!=null){ ! UID1 = ((Application)Elm.application).getUID(); ! UID2 = ((Application)application).getUID(); ! } ! ! if ( UID1 == UID2) { Found=true; *************** *** 392,401 **** if (Elm.PortStatus == 0) //free port { ! Reserved=true; Elm.PortStatus=2; //port will be busy from now Elm.connectedtoIP=inDestIPAddress; ! Elm.connectedtoPort=indestPort; ! PortTable.remove(number+PORT_START_NUMBER); //delete old element ! PortTable.put(number+PORT_START_NUMBER,Elm); //hash table update } number++; --- 401,411 ---- if (Elm.PortStatus == 0) //free port { ! Reserved=true; Elm.PortStatus=2; //port will be busy from now Elm.connectedtoIP=inDestIPAddress; ! Elm.connectedtoPort=indestPort; ! Elm.application = application; //GIFT: UGLY BUG!!!! ! PortTable.remove(new Integer(number+PORT_START_NUMBER)); //delete old element ! PortTable.put(new Integer(number+PORT_START_NUMBER),Elm); //hash table update } number++; *************** *** 450,454 **** Elm = (UDP_HashTableElement) itr.next(); ! if (Elm.application == application) { Found=true; --- 460,472 ---- Elm = (UDP_HashTableElement) itr.next(); ! int UID1 = -2; ! int UID2 = -1; ! ! if(Elm.application!=null && application!=null){ ! UID1 = ((Application)Elm.application).getUID(); ! UID2 = ((Application)application).getUID(); ! } ! ! if ( UID1 == UID2 ) { Found=true; *************** *** 463,467 **** throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination port."); } ! return number; } --- 481,485 ---- throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination port."); } ! return new Integer(number); } *************** *** 478,482 **** { UDP_HashTableElement Elm = new UDP_HashTableElement(); ! int PortToClose=getApplicationLocalPortNumber(application); if (Elm.PortStatus==1) --- 496,500 ---- { UDP_HashTableElement Elm = new UDP_HashTableElement(); ! Integer PortToClose=getApplicationLocalPortNumber(application); if (Elm.PortStatus==1) *************** *** 504,508 **** { UDP_HashTableElement Elm = new UDP_HashTableElement(); ! int PortToFree=getApplicationLocalPortNumber(application); if (Elm.PortStatus==2) --- 522,526 ---- { UDP_HashTableElement Elm = new UDP_HashTableElement(); ! Integer PortToFree=getApplicationLocalPortNumber(application); if (Elm.PortStatus==2) *************** *** 524,528 **** * @author gift (sourceforge.net user) * @param application application that uses port ! * @param inPort port that the application want to listen to * @return Nothing * @exception TransportLayerException --- 542,546 ---- * @author gift (sourceforge.net user) * @param application application that uses port ! * @param in_Port port that the application want to listen to * @return Nothing * @exception TransportLayerException *************** *** 533,538 **** // else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); ! public void ListenPort(Object application, int inPort) throws TransportLayerException { if (inPort>=0 && inPort<=10000) { --- 551,557 ---- // else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); ! public void ListenPort(Object application, int in_Port) throws TransportLayerException { + Integer inPort = new Integer(in_Port); if (inPort>=0 && inPort<=10000) { *************** *** 596,606 **** Set set = PortTable.keySet(); Iterator itr = set.iterator(); ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! while ( (itr.hasNext()) && !(Found) ) { ! Elm = (UDP_HashTableElement) itr.next(); ! if (Elm.application == application) { Found=true; --- 615,639 ---- Set set = PortTable.keySet(); Iterator itr = set.iterator(); ! //Enumeration keys = PortTable.elements(); ! //Integer key = null; ! UDP_HashTableElement Elm = null; ! while ( (itr.hasNext()) && !(Found) ) //keys.hasMoreElements() { ! try{ ! //key = new Integer((Integer) keys.nextElement()); ! //Elm = (UDP_HashTableElement) PortTable.get(key); ! Elm = (UDP_HashTableElement) itr.next(); ! }catch(Exception ex){ System.out.println(ex.toString()); } ! int UID1 = -2; ! int UID2 = -1; ! ! if(Elm!=null && application!=null){ ! if(Elm.application!=null) UID1 = ((Application)Elm.application).getUID(); ! UID2 = ((Application)application).getUID(); ! } ! ! if ( UID1 == UID2 ) { Found=true; *************** *** 608,611 **** --- 641,646 ---- dIP=Elm.connectedtoIP; } + + } *************** *** 641,645 **** Elm = (UDP_HashTableElement) PortTable.get(number); ! if (Elm.application == application) { Found=true; --- 676,688 ---- Elm = (UDP_HashTableElement) PortTable.get(number); ! int UID1 = -2; ! int UID2 = -1; ! ! if(Elm.application!=null && application!=null){ ! UID1 = ((Application)Elm.application).getUID(); ! UID2 = ((Application)application).getUID(); ! } ! ! if ( UID1 == UID2 ) { Found=true; |
From: Alexander B. <da...@us...> - 2005-11-20 07:55:55
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24230/guiUI Modified Files: MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MainScreen.java 19 Nov 2005 21:53:51 -0000 1.6 --- MainScreen.java 20 Nov 2005 07:55:48 -0000 1.7 *************** *** 1771,1775 **** public void EchoServerListen(String inNodeName){ ! String port = JOptionPane.showInputDialog(this, "Port:", "Set Echo Server listening on port.", JOptionPane.QUESTION_MESSAGE); if(port!=null){ try{ --- 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{ *************** *** 1792,1798 **** 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{ --- 1793,1802 ---- 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{ |
From: Alexander B. <da...@us...> - 2005-11-19 21:53:58
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5833/core/protocolsuite/tcp_ip Modified Files: ARP.java Application.java Echo.java ICMP.java ProtocolStack.java Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Udp.java 19 Nov 2005 20:13:07 -0000 1.6 --- Udp.java 19 Nov 2005 21:53:51 -0000 1.7 *************** *** 182,186 **** */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 182,186 ---- */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException, LowLinkException { *************** *** 297,301 **** */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException { int srcPort; --- 297,301 ---- */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException, LowLinkException { int srcPort; *************** *** 327,331 **** Simulation.addLayerInfo(UDP_Info); ! return tosend; } --- 327,332 ---- Simulation.addLayerInfo(UDP_Info); ! return tosend; ! } *************** *** 538,543 **** UDP_HashTableElement Elm = new UDP_HashTableElement(); ! if ( (Elm = (UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { switch(Elm.PortStatus) { --- 539,546 ---- UDP_HashTableElement Elm = new UDP_HashTableElement(); ! ! if ( (UDP_HashTableElement)PortTable.get(inPort) !=null ) ! { ! Elm = (UDP_HashTableElement)PortTable.get(inPort); switch(Elm.PortStatus) { Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ProtocolStack.java 19 Nov 2005 20:13:07 -0000 1.7 --- ProtocolStack.java 19 Nov 2005 21:53:51 -0000 1.8 *************** *** 191,195 **** */ ! public void sendPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; --- 191,195 ---- */ ! public void sendPacket(IP_packet inPacket) throws LowLinkException, CommunicationException{ String destMAC = null; *************** *** 289,299 **** }catch(LowLinkException ex){ throw new LowLinkException(ex.toString()); - - - }catch(CommunicationException ex){ - throw ex; - } --- 289,294 ---- *************** *** 324,328 **** */ ! public void forwardPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; --- 319,323 ---- */ ! public void forwardPacket(IP_packet inPacket) throws CommunicationException, LowLinkException{ String destMAC = null; *************** *** 416,420 **** */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = "FF:FF:FF:FF:FF:FF"; --- 411,415 ---- */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws CommunicationException, LowLinkException{ String destMAC = "FF:FF:FF:FF:FF:FF"; *************** *** 530,534 **** */ ! public void sendPing(String inDestIPAddress) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { if(IPV4Address.validateDecIP(inDestIPAddress)){ --- 525,529 ---- */ ! public void sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException { if(IPV4Address.validateDecIP(inDestIPAddress)){ *************** *** 686,690 **** */ ! public void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ --- 681,685 ---- */ ! public void receivePacket(Packet inPacket) throws LowLinkException{ *************** *** 740,746 **** if (ipPacket instanceof ICMP_packet){ ! ICMP_packet temp = (ICMP_packet)inPacket; ! mICMPprotocol.receiveICMPPacket(temp); }else if(ipPacket instanceof ARP_packet){ --- 735,741 ---- if (ipPacket instanceof ICMP_packet){ ! ICMP_packet temp = (ICMP_packet)inPacket; ! mICMPprotocol.receiveICMPPacket(temp); }else if(ipPacket instanceof ARP_packet){ *************** *** 754,758 **** UDP_packet temp = (UDP_packet)inPacket; ! mUDPprotocol.receiveUDPPacket(temp); }else{ --- 749,757 ---- UDP_packet temp = (UDP_packet)inPacket; ! try{ ! mUDPprotocol.receiveUDPPacket(temp); ! }catch(TransportLayerException e){ ! //here *TODO*: insert catcher here ! } }else{ *************** *** 1308,1312 **** */ ! public void sendUDP(Object application, String inUDPMessage) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { --- 1307,1311 ---- */ ! public void sendUDP(Object application, String inUDPMessage) throws LowLinkException, CommunicationException { *************** *** 1318,1325 **** Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); - - DestIPAddress=mUDPprotocol.getApplicationDestIP(application); - destPort=mUDPprotocol.getApplicationDestPortNumber(application); if (FirstInterfaceName!=null) { --- 1317,1325 ---- Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); + try{ + DestIPAddress=mUDPprotocol.getApplicationDestIP(application); + destPort=mUDPprotocol.getApplicationDestPortNumber(application); + if (FirstInterfaceName!=null) { *************** *** 1330,1336 **** }else throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); ! } else ! throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! } --- 1330,1338 ---- }else throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); ! } //else ! //throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! }catch(Exception e){ ! //*TODO*: here we shall put some layerinfo for TransportException ! } } Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ARP.java 19 Nov 2005 20:13:07 -0000 1.3 --- ARP.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 75,82 **** import core.LayerInfo; - import core.TransportLayerException; - - import core.InvalidNetworkLayerDeviceException; - --- 75,78 ---- *************** *** 321,325 **** */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 317,321 ---- */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws LowLinkException { *************** *** 429,433 **** ! public void receiveARPPacket(ARP_packet inARPpacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ // test if this packet is for a local Address. --- 425,429 ---- ! public void receiveARPPacket(ARP_packet inARPpacket) throws LowLinkException{ // test if this packet is for a local Address. Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Application.java 19 Nov 2005 20:13:07 -0000 1.7 --- Application.java 19 Nov 2005 21:53:51 -0000 1.8 *************** *** 19,23 **** * @author key */ ! public class Application { protected String protocolName; --- 19,23 ---- * @author key */ ! public abstract class Application { protected String protocolName; *************** *** 32,40 **** --- 32,44 ---- protected int UID; /** Creates a new instance of ApplicationProtocol */ + public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ this.listenPort = listenPort; this.mParentStack = inParentStack; + this.appType = appType; + this.UID = UID; } + /** * This method start to listen on application port *************** *** 42,48 **** * @version v0.01 */ ! public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! } /** --- 46,50 ---- * @version v0.01 */ ! public abstract void Listen() throws TransportLayerException; /** *************** *** 53,57 **** * @version v0.01 */ ! public void Close() throws TransportLayerException{} /** --- 55,59 ---- * @version v0.01 */ ! public abstract void Close() throws TransportLayerException; /** *************** *** 63,67 **** */ ! public void Connect(String Host, int port) throws TransportLayerException {} /** --- 65,69 ---- */ ! public abstract void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException; /** *************** *** 71,75 **** */ ! public void Disconnect()throws TransportLayerException{} /** --- 73,77 ---- */ ! public abstract void Disconnect()throws TransportLayerException; /** *************** *** 80,84 **** */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} /** --- 82,86 ---- */ ! public abstract void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException; /** *************** *** 88,93 **** * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} public void setPort(int port){ this.listenPort = port; --- 90,96 ---- * @version v0.01 */ ! public abstract void RecvData(String Data) throws LowLinkException, TransportLayerException; + public void setPort(int port){ this.listenPort = port; Index: ICMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICMP.java 19 Nov 2005 20:13:07 -0000 1.3 --- ICMP.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 73,82 **** import core.Simulation; - import core.TransportLayerException; - - import core.InvalidNetworkLayerDeviceException; - - - --- 73,76 ---- *************** *** 149,153 **** */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 143,147 ---- */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws LowLinkException { *************** *** 201,205 **** */ ! private void echoRequest(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destIPAddress = inPacket.getSourceIPAddress(); --- 195,199 ---- */ ! private void echoRequest(ICMP_packet inPacket) throws LowLinkException{ String destIPAddress = inPacket.getSourceIPAddress(); *************** *** 239,243 **** //TODO Once the recording of a sim process is implemented this should record the error. ! }//catch(LowLinkException e){ //This exception is caught but not acted upon as the --- 233,238 ---- //TODO Once the recording of a sim process is implemented this should record the error. ! } ! //catch(LowLinkException e){ //This exception is caught but not acted upon as the Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Echo.java 19 Nov 2005 20:13:07 -0000 1.6 --- Echo.java 19 Nov 2005 21:53:51 -0000 1.7 *************** *** 25,29 **** /** Creates a new instance of Echo */ public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); } --- 25,29 ---- /** Creates a new instance of Echo */ public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); } *************** *** 92,98 **** */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { ! mParentStack.sendUDP(this, Data); //processing the protocol doings. } --- 92,100 ---- */ ! public void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException { ! ! mParentStack.sendUDP(this, Data); ! //processing the protocol doings. } *************** *** 106,110 **** * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { //processing the protocol doings. if(appType == 0){ --- 108,112 ---- * @version v0.01 */ ! public void RecvData(String Data) throws LowLinkException, TransportLayerException { //processing the protocol doings. if(appType == 0){ *************** *** 114,120 **** --- 116,126 ---- }else{ //server processing recieve + try{ SendData(Data); Close(); Listen(); + }catch(Exception e){ + ///*TODO*: here to catch + } } } *************** *** 132,134 **** --- 138,142 ---- SendData(Data); } + + } |
From: Alexander B. <da...@us...> - 2005-11-19 21:53:58
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5833/guiUI Modified Files: MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MainScreen.java 19 Nov 2005 17:54:33 -0000 1.5 --- MainScreen.java 19 Nov 2005 21:53:51 -0000 1.6 *************** *** 1774,1779 **** if(port!=null){ try{ ! ((Echo)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(7)).setPort(Integer.valueOf(port).intValue()); ! ((Echo)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(7)).Listen(); this.addToConsole("Echo server now listening on " + inNodeName + " on port " + port + "\n"); }catch(Exception e){ --- 1774,1781 ---- if(port!=null){ try{ ! ! Echo echo1 = ((Echo)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(7)); ! echo1.setPort(Integer.valueOf(port).intValue()); ! echo1.Listen(); this.addToConsole("Echo server now listening on " + inNodeName + " on port " + port + "\n"); }catch(Exception e){ |
From: Alexander B. <da...@us...> - 2005-11-19 21:53:58
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5833/core Modified Files: EthernetNetworkInterface.java NetworkInterface.java NetworkInterfacePort.java NetworkLayerDevice.java Node.java ProtocolStack.java Log Message: Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Node.java 19 Nov 2005 20:13:07 -0000 1.4 --- Node.java 19 Nov 2005 21:53:51 -0000 1.5 *************** *** 233,237 **** */ ! protected void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { return; --- 233,237 ---- */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { return; Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EthernetNetworkInterface.java 19 Nov 2005 17:54:33 -0000 1.2 --- EthernetNetworkInterface.java 19 Nov 2005 21:53:51 -0000 1.3 *************** *** 148,152 **** frameErrInfo.setDescription(ex.toString()); Simulation.addLayerInfo(frameErrInfo); - System.out.println("!!!"); //throw new LowLinkException(ex.toString()); } --- 148,151 ---- Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProtocolStack.java 19 Nov 2005 20:13:07 -0000 1.3 --- ProtocolStack.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 1,154 **** ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! ! ! /** ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public abstract class ProtocolStack { ! ! public static final int TCP_IP = 0; ! ! public static final int IPX_SPX = 1; ! ! public static final int IBM_SNA = 2; ! ! public static final int APPLETALK = 3; ! ! ! ! public static int UIDGen; ! ! /** ! ! * Future use. All protocol stacks regardless of type must implement ! ! * recievepacket! ! ! * @author bevan_calliess ! ! * @param inPacket ! ! */ ! ! public abstract void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException; ! ! ! ! }//EOF ! --- 1,77 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! ! /** ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! ! public abstract class ProtocolStack { ! public static final int TCP_IP = 0; ! public static final int IPX_SPX = 1; ! public static final int IBM_SNA = 2; ! public static final int APPLETALK = 3; ! ! public static int UIDGen; ! /** ! * Future use. All protocol stacks regardless of type must implement ! * recievepacket! ! * @author bevan_calliess ! * @param inPacket ! */ ! public abstract void receivePacket(Packet inPacket) throws LowLinkException; ! ! }//EOF Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NetworkInterfacePort.java 19 Nov 2005 20:13:07 -0000 1.2 --- NetworkInterfacePort.java 19 Nov 2005 21:53:51 -0000 1.3 *************** *** 1,206 **** ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! import java.io.Serializable; ! ! /** ! ! * A NetworkInterfacePort represents the physical interface between ! ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! ! * ! ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! ! * ! ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! ! * ! ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! ! * the Link object they are connected to.</P> ! ! * ! ! * @author bevan_valliess ! ! * @since 13 Nov 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! ! ! /** ! ! * Constructs a NetworkInterfacePort object with the name inName ! ! * and a reference to it's parent Node. ! ! * @author baven_calliess ! ! * @param inName - The name to give the NetworkInterface eg: eth0 ! ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! ! * @version v0.20 ! ! */ ! ! protected NetworkInterfacePort(String inName, Node inParent) { ! ! super(inName,inParent); ! ! } ! ! ! ! ! ! /** ! ! * This method recevie a packet from a connected link and then pass it ! ! * to the node's protocolstack. Depending on the network any ! ! * testing of the packets headers may need to be inserted here. ! ! * @author bevan_calliess ! ! * @param inPacket - The packet being recived by this port ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! ! parentNode.receivePacket(inPacket, name); ! ! return; ! ! } ! ! ! ! /** ! ! * This method sends a packet to a connected link Depending ! ! * it is used by the datalinkLayer devices to tansport ! ! * packets without any validation or data checking. ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param outPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! protected void sendPacket(Packet outPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! ! EthernetLink temp = (EthernetLink)connectedLink; ! ! ! ! if(temp!=null){ ! ! temp.transportPacket(tempPacket,getSourceName()); ! ! } ! ! } ! ! ! ! /** ! ! * This method returns information about this InterfacePort ! ! * @author bevan_calliess ! ! * @return String - The details of Interface name Mac and Links ! ! * @version v0.20 ! ! */ ! ! protected String getDetails(){ ! ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! ! } ! ! }//EOF ! --- 1,103 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterfacePort represents the physical interface between ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! * ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! * ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author bevan_valliess ! * @since 13 Nov 2004 ! * @version v0.20 ! */ ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! /** ! * Constructs a NetworkInterfacePort object with the name inName ! * and a reference to it's parent Node. ! * @author baven_calliess ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.20 ! */ ! protected NetworkInterfacePort(String inName, Node inParent) { ! super(inName,inParent); ! } ! ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * @author bevan_calliess ! * @param inPacket - The packet being recived by this port ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! parentNode.receivePacket(inPacket, name); ! return; ! } ! ! /** ! * This method sends a packet to a connected link Depending ! * it is used by the datalinkLayer devices to tansport ! * packets without any validation or data checking. ! * @author bevan_calliess ! * @author angela_brown ! * @param outPacket - A Packet ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException{ ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! EthernetLink temp = (EthernetLink)connectedLink; ! ! if(temp!=null){ ! temp.transportPacket(tempPacket,getSourceName()); ! } ! } ! ! /** ! * This method returns information about this InterfacePort ! * @author bevan_calliess ! * @return String - The details of Interface name Mac and Links ! * @version v0.20 ! */ ! protected String getDetails(){ ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! } ! }//EOF Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NetworkInterface.java 19 Nov 2005 20:13:07 -0000 1.2 --- NetworkInterface.java 19 Nov 2005 21:53:51 -0000 1.3 *************** *** 1,400 **** ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! import java.io.Serializable; ! ! /** ! ! * A NetworkInterface represents the physical interface between ! ! * a Node and a physical Link (network cable). Think of it as the NIC ! ! * (Network Interface Card) of a Node. ! ! * ! ! * <P>Different Nodes can contain different numbers of NetworkInterfaces. ! ! * A client PC usually only has one NetworkInterface, whereas a Router contains ! ! * at least two. A Hub or a Switch often has 8 or 16.</P> ! ! * ! ! * <P>In order for a Node to be able to send or receive network information (packets), ! ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! ! * ! ! * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and ! ! * the Link object they are connected to.</P> ! ! * ! ! * @author tristan_veness (Original Author) ! ! * @author bevan_calliess ! ! * @author luke_hamilton ! ! * @since 19 September 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! abstract class NetworkInterface implements Serializable{ ! ! /** The NetworkInterface's name, eg "eth0" */ ! ! protected String name; ! ! /** The Link that this NetworkInterface is connected to */ ! ! protected Link connectedLink; ! ! protected Node parentNode; ! ! ! ! /** ! ! * Constructs a NetworkInterface object with the name inName and a reference to it's parent Node. ! ! * @author tristan_veness ! ! * @param inName - The name to give the NetworkInterface eg: eth0 ! ! * @param parent - The Node that the NetworkInterface is to be added to, it's parent. ! ! * @version v0.10 ! ! */ ! ! protected NetworkInterface(String inName, Node inParent) { ! ! name = inName; ! ! parentNode = inParent; ! ! } ! ! ! ! /** ! ! * This method reset the connected link to null ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void resetConnectedLink() { ! ! connectedLink = null; ! ! } ! ! ! ! /** ! ! * This method will call the disconnectLink method on the ! ! * Connected link, and then set the connected link to null ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void removeConnectedLink() { ! ! if(connectedLink != null){ ! ! connectedLink.disconnectLink(); ! ! connectedLink = null; ! ! } ! ! } ! ! ! ! /** ! ! * This method recevie a packet from a connected link and then pass it ! ! * to the node's protocolstack. Depending on the network any ! ! * testing of the packets headers may need to be inserted here. ! ! * This method is overridded by the subclasses on interface to suite ! ! * there requirements ! ! * @author baven_calliess ! ! * @param inPacket - A packet ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException {} ! ! ! ! /** ! ! * This method sends a packet to a connected link Depending on ! ! * @author bevan_calliess ! ! * @param inPacket ! ! * @version v0.20 ! ! */ ! ! protected void sendPacket(Packet outPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException {} ! ! ! ! /** ! ! * Returns the NetworkInterface's name. ! ! * @author bevan_calliess ! ! * @return Name - The NetworkInterface's name ! ! * @version v0.20 ! ! */ ! ! ! ! protected String getName() { ! ! return name; ! ! } ! ! ! ! /** ! ! * This method is used by interfaces to uniquely identify themselves ! ! * in the simulation it will return a combination of the ! ! * Parent naodes name and the Interfaces name ! ! * eg. Node name PC1 interface eth0 will return "PC1eth0" ! ! * @author bevan_calliess ! ! * @return Name - The Source name of this Node Interface ! ! * @version v0.20 ! ! */ ! ! protected String getSourceName() { ! ! return parentNode.getName()+name; ! ! } ! ! ! ! /** ! ! * Sets the connectedLink attribute of the NetworkInterface with Link l. ! ! * ! ! * <P>This method should only be called by the Link class when an Interface is added or removed from the Link.</P> ! ! * @author tristan_veness ! ! * @param l - The Link connected with this NetworkInterface. ! ! * @version v0.10 ! ! */ ! ! protected void setConnectedLink(Link l)throws InvalidLinkConnectionException { ! ! if(connectedLink == null){ ! ! connectedLink = l; ! ! }else ! ! throw new InvalidLinkConnectionException("Network Interface is already connected. Delete Connected link first"); ! ! ! ! } ! ! ! ! /** ! ! * Returns the Link that this NetworkInterface is connected to. ! ! * @author tristan_veness ! ! * @return The Link object that this NetworkInterface is connected to. null if it is not connected. ! ! * @version v0.10 ! ! */ ! ! protected Link getConnectedLink() { ! ! return connectedLink; ! ! } ! ! ! ! protected String getConnectedLinkName() { ! ! if(connectedLink!=null) return connectedLink.getName(); ! ! else return null; ! ! } ! ! ! ! /** ! ! * This method returns the name of the network interface ! ! * @author tristan_veness ! ! * @return Name ! ! * @version v0.10 ! ! */ ! ! protected String getDetails(){ ! ! return name; ! ! } ! ! ! ! /** ! ! * This method returns a string of information about if the network interface is connected of not. ! ! * <P>This method is useful for a CLI or for debugging.</P> ! ! * @author tristan_veness ! ! * @return Name - Connection: link1 ! ! * @version v0.10 ! ! */ ! ! protected String getConnectLinkDetails(){ ! ! if(connectedLink != null){ ! ! return "Connection: "+ connectedLink.getName(); ! ! } ! ! return "Connection: Not connected"; ! ! } ! ! ! ! protected String getConnectLinkName() ! ! { ! ! if(connectedLink !=null) ! ! { ! ! return (String)connectedLink.getName(); ! ! } ! ! return "Not Connected"; ! ! } ! ! }//EOF ! --- 1,200 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterface represents the physical interface between ! * a Node and a physical Link (network cable). Think of it as the NIC ! * (Network Interface Card) of a Node. ! * ! * <P>Different Nodes can contain different numbers of NetworkInterfaces. ! * A client PC usually only has one NetworkInterface, whereas a Router contains ! * at least two. A Hub or a Switch often has 8 or 16.</P> ! * ! * <P>In order for a Node to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author tristan_veness (Original Author) ! * @author bevan_calliess ! * @author luke_hamilton ! * @since 19 September 2004 ! * @version v0.20 ! */ ! ! abstract class NetworkInterface implements Serializable{ ! /** The NetworkInterface's name, eg "eth0" */ ! protected String name; ! /** The Link that this NetworkInterface is connected to */ ! protected Link connectedLink; ! protected Node parentNode; ! ! /** ! * Constructs a NetworkInterface object with the name inName and a reference to it's parent Node. ! * @author tristan_veness ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param parent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.10 ! */ ! protected NetworkInterface(String inName, Node inParent) { ! name = inName; ! parentNode = inParent; ! } ! ! /** ! * This method reset the connected link to null ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void resetConnectedLink() { ! connectedLink = null; ! } ! ! /** ! * This method will call the disconnectLink method on the ! * Connected link, and then set the connected link to null ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void removeConnectedLink() { ! if(connectedLink != null){ ! connectedLink.disconnectLink(); ! connectedLink = null; ! } ! } ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * This method is overridded by the subclasses on interface to suite ! * there requirements ! * @author baven_calliess ! * @param inPacket - A packet ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException {} ! ! /** ! * This method sends a packet to a connected link Depending on ! * @author bevan_calliess ! * @param inPacket ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException {} ! ! /** ! * Returns the NetworkInterface's name. ! * @author bevan_calliess ! * @return Name - The NetworkInterface's name ! * @version v0.20 ! */ ! ! protected String getName() { ! return name; ! } ! ! /** ! * This method is used by interfaces to uniquely identify themselves ! * in the simulation it will return a combination of the ! * Parent naodes name and the Interfaces name ! * eg. Node name PC1 interface eth0 will return "PC1eth0" ! * @author bevan_calliess ! * @return Name - The Source name of this Node Interface ! * @version v0.20 ! */ ! protected String getSourceName() { ! return parentNode.getName()+name; ! } ! ! /** ! * Sets the connectedLink attribute of the NetworkInterface with Link l. ! * ! * <P>This method should only be called by the Link class when an Interface is added or removed from the Link.</P> ! * @author tristan_veness ! * @param l - The Link connected with this NetworkInterface. ! * @version v0.10 ! */ ! protected void setConnectedLink(Link l)throws InvalidLinkConnectionException { ! if(connectedLink == null){ ! connectedLink = l; ! }else ! throw new InvalidLinkConnectionException("Network Interface is already connected. Delete Connected link first"); ! ! } ! ! /** ! * Returns the Link that this NetworkInterface is connected to. ! * @author tristan_veness ! * @return The Link object that this NetworkInterface is connected to. null if it is not connected. ! * @version v0.10 ! */ ! protected Link getConnectedLink() { ! return connectedLink; ! } ! ! protected String getConnectedLinkName() { ! if(connectedLink!=null) return connectedLink.getName(); ! else return null; ! } ! ! /** ! * This method returns the name of the network interface ! * @author tristan_veness ! * @return Name ! * @version v0.10 ! */ ! protected String getDetails(){ ! return name; ! } ! ! /** ! * This method returns a string of information about if the network interface is connected of not. ! * <P>This method is useful for a CLI or for debugging.</P> ! * @author tristan_veness ! * @return Name - Connection: link1 ! * @version v0.10 ! */ ! protected String getConnectLinkDetails(){ ! if(connectedLink != null){ ! return "Connection: "+ connectedLink.getName(); ! } ! return "Connection: Not connected"; ! } ! ! protected String getConnectLinkName() ! { ! if(connectedLink !=null) ! { ! return (String)connectedLink.getName(); ! } ! return "Not Connected"; ! } ! }//EOF Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NetworkLayerDevice.java 19 Nov 2005 20:13:07 -0000 1.3 --- NetworkLayerDevice.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 1,578 **** ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! ! ! package core; ! ! import core.EthernetNetworkInterface; ! ! import core.protocolsuite.tcp_ip.InvalidIPAddressException; ! ! import core.InvalidNetworkInterfaceNameException; ! ! import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; ! ! import core.protocolsuite.tcp_ip.Route_entry; ! ! import java.util.*; ! ! ! ! /** ! ! * NetworkLayerDevice extends Node. This class adds network layer devices ! ! * sets IPAddress, defaultgateway, sends a ping and a few more options ! ! * @author luke_hamilton ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @since Oct 9, 2004 ! ! * @version v0.20 ! ! */ ! ! public abstract class NetworkLayerDevice extends Node { ! ! ! ! /** ! ! * calls the super class (Node) and passes it inName and inProtocolStack ! ! * @author luke_hamilton ! ! * @author bevan_calliess ! ! * @param inName - Node Name eg: PC1 ! ! * @param inProtocolStackLayers - ProtocolStack Layer ! ! * @version v0.20 ! ! */ ! ! public NetworkLayerDevice(String inName, int inProtocolStackLayers) { ! ! super(inName, inProtocolStackLayers); ! ! } ! ! ! ! /** ! ! * This method will get the subnetMask of the Interface that was ! ! * passed in ! ! * @author bevan_callies ! ! * @author robert_hulford ! ! * @param inInteface - The Name of the Inteface eg: eth0 ! ! * @return The subnetMask ! ! * @version v0.20 ! ! */ ! ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! ! public String getSubnetMask(String inInterface) { ! ! return NodeProtocolStack.getSubnetMask(inInterface); ! ! } ! ! ! ! /** ! ! * This method will get the ipaddress of the Interface that was passed in ! ! * ! ! * @author luke_hamilton ! ! * @param inInteface - The Name of the Inteface eg: eth0 ! ! * @return The subnetMask ! ! * @version v0.20 ! ! ! ! */ ! ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! ! public String getIPAddress(String inInterface){ ! ! return NodeProtocolStack.getIPAddress(inInterface); ! ! } ! ! ! ! /** ! ! * This method will pass in a packet and send it off to the ! ! * nodeProtocolStack ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @param inPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! public void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { ! ! NodeProtocolStack.receivePacket(inPacket); ! ! } ! ! ! ! /** ! ! * This method will send a ping to the specified Destination ! ! * Address passing it up to the NodeProtocolStack ! ! * @author angela_brown ! ! * @author bevna_calliess ! ! * @param inDestIPAddress - The Destination IP Addres eg: 192.168.0.2 ! ! * @throws CommunicationException ! ! * @version v0.20 ! ! */ ! ! public void sendPing(String inDestIPAddress) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! NodeProtocolStack.sendPing(inDestIPAddress); ! ! } ! ! ! ! ! ! /** ! ! * This method will check to see if the Interface key is contained within the ! ! * NetworkInterfacetable (hash table) if so typecast it into a EthernetNetworkInterface Object ! ! * and send the packet and Destination MAC address up to the EthernetNetworkInterface layer ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inDestMACAddress - Destination MAC address eg: AA:A1:BC:34:65 ! ! * @param inPacket - A Packet ! ! * @param inInterfaceKey - The Inteface Key ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @version v0.20 ! ! */ ! ! public void sendPacket(String inDestMACAddress, Packet inPacket, String inInterfaceKey) throws InvalidNetworkInterfaceNameException, TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! if (NetworkInterfacetable.containsKey(inInterfaceKey)) ! ! { ! ! EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); ! ! temp.sendPacket(inPacket,inDestMACAddress); ! ! } ! ! else ! ! { ! ! throw new InvalidNetworkInterfaceNameException("Inteface does not exist."); ! ! } ! ! } ! ! ! ! ! ! /** ! ! * This method will get the defaultgateway when called from the NodeProtocolStack ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @return Defaultgateway ! ! * @version v0.20 ! ! */ ! ! public String getDefaultGateway() { ! ! return NodeProtocolStack.getDefaultGateway(); ! ! } ! ! ! ! /** ! ! * gets a string array from the arp protocol and returns it ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @return String[] - The arp table entries ! ! */ ! ! public String[] getARPTable() { ! ! return NodeProtocolStack.getARPTable(); ! ! } ! ! ! ! /** ! ! * This method will pass inIterface, incustomeSubnetMask up to the NodeProtocolStack ! ! * with the aim to set the CustomSubnetMask ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inInterface ! ! * @param inCustomSubnetMask ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @throws InvalidSubnetMaskException ! ! * @version v0.20 ! ! */ ! ! ! ! public void setCustomSubnetMask(String inInterface, String inCustomSubnetMask)throws InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { ! ! if(NetworkInterfacetable.containsKey(inInterface)){ ! ! NodeProtocolStack.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! ! }else{ ! ! throw new InvalidNetworkInterfaceNameException("Interface does not exsist"); ! ! } ! ! } ! ! ! ! /** ! ! * This method will call the setDefaultgatway method within the NodeProtocolStack passing it ! ! * the inGatewayIPAddress ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @param inGatewayIPAddress ! ! * @throws InvalidNodeNameException ! ! * @throws InvalidDefaultGatewayException ! ! * @version v0.20 ! ! */ ! ! ! ! public void setDefaultGateway(String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException{ ! ! NodeProtocolStack.setDefaultGateway(inGatewayIPAddress); ! ! } ! ! ! ! /** ! ! * This method will set the ip address for a network interface. ! ! * It will test if the inInterface exists and returns the MAC address of the netwokInterface set. ! ! * @param inInterface - The Interface name eg: eth0 ! ! * @param inIPAddress - The IP address eg: 192.168.0.2 ! ! * @return macAddress - The MAC address on the Interface card that the IP address was set for. ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @throws InvalidIPAddressException ! ! */ ! ! ! ! protected String setIPAddress(String inInterface, String inIPAddress) throws InvalidNetworkInterfaceNameException,InvalidIPAddressException { ! ! String macAddress = null; ! ! if (NetworkInterfacetable.containsKey(inInterface)) { ! ! NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! ! EthernetNetworkInterface tempNic = ! ! (EthernetNetworkInterface) NetworkInterfacetable.get( ! ! inInterface); ! ! macAddress = tempNic.getMACAddress(); ! ! ! ! } else { ! ! throw new InvalidNetworkInterfaceNameException("Interface does not exist"); ! ! } ! ! return macAddress; ! ! } ! ! ! ! /** ! ! * This method will call the protocol stacks' add to ARP method ! ! * passing the ip address and the mac address ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inMACAddress - The MAC Address eg: ab:ab:ab:ab:ab:ab ! ! * @param inIPAddress - The IPAddress eg: 192.168.0.2 ! ! * @version v0.20 ! ! */ ! ! public void addToARP(String inIPAddress, String inMACAddress){ ! ! NodeProtocolStack.addToARP(inIPAddress, inMACAddress); ! ! } ! ! ! ! /** ! ! * ARP functions... ! ! * Shall be documented as well. ! ! * @author Key ! ! * @version v0.21 ! ! */ ! ! public void addToARPStatic(String inIPAddress, String inMACAddress){ ! ! NodeProtocolStack.addToARPStatic(inIPAddress, inMACAddress); ! ! } ! ! ! ! public void removeARP(String inIPAddress){ ! ! NodeProtocolStack.removeARP(inIPAddress); ! ! } ! ! ! ! /** ! ! * ! ! * @return ! ! */ ! ! public Object[] getAllInterfaces(){ ! ! ! ! ArrayList interfaceArray = new ArrayList(); ! ! 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(); ! ! } ! ! ! ! /** ! ! * Routing tables functions... Use carefully! ! ! * Shall be documented as well. ! ! * @author Key ! ! * @version v0.21 ! ! */ ! ! ! ! public void addRoute(Route_entry r){ ! ! NodeProtocolStack.addRoute(r); ! ! } ! ! ! ! public void removeRoute(String destIP){ ! ! NodeProtocolStack.removeRoute(destIP); ! ! } ! ! ! ! public String[] getRouteTableEntries(){ ! ! return NodeProtocolStack.getRouteTableEntries(); ! ! } ! ! ! ! public Route_entry getRouteTableEntry(String destIP){ ! ! return NodeProtocolStack.getRouteTableEntry(destIP); ! ! } ! ! ! ! }//EOF ! --- 1,289 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! package core; ! import core.EthernetNetworkInterface; ! import core.protocolsuite.tcp_ip.InvalidIPAddressException; ! import core.InvalidNetworkInterfaceNameException; ! import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; ! import core.protocolsuite.tcp_ip.Route_entry; ! import java.util.*; ! ! /** ! * NetworkLayerDevice extends Node. This class adds network layer devices ! * sets IPAddress, defaultgateway, sends a ping and a few more options ! * @author luke_hamilton ! * @author angela_brown ! * @author michael_reith ! * @author robert_hulford ! * @author bevan_calliess ! * @since Oct 9, 2004 ! * @version v0.20 ! */ ! public abstract class NetworkLayerDevice extends Node { ! ! /** ! * calls the super class (Node) and passes it inName and inProtocolStack ! * @author luke_hamilton ! * @author bevan_calliess ! * @param inName - Node Name eg: PC1 ! * @param inProtocolStackLayers - ProtocolStack Layer ! * @version v0.20 ! */ ! public NetworkLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); ! } ! ! /** ! * This method will get the subnetMask of the Interface that was ! * passed in ! * @author bevan_callies ! * @author robert_hulford ! * @param inInteface - The Name of the Inteface eg: eth0 ! * @return The subnetMask ! * @version v0.20 ! */ ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! public String getSubnetMask(String inInterface) { ! return NodeProtocolStack.getSubnetMask(inInterface); ! } ! ! /** ! * This method will get the ipaddress of the Interface that was passed in ! * ! * @author luke_hamilton ! * @param inInteface - The Name of the Inteface eg: eth0 ! * @return The subnetMask ! * @version v0.20 ! ! */ ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! public String getIPAddress(String inInterface){ ! return NodeProtocolStack.getIPAddress(inInterface); ! } ! ! /** ! * This method will pass in a packet and send it off to the ! * nodeProtocolStack ! * @author angela_brown ! * @author bevan_calliess ! * @param inPacket - A Packet ! * @version v0.20 ! */ ! public void receivePacket(Packet inPacket) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket); ! } ! ! /** ! * This method will send a ping to the specified Destination ! * Address passing it up to the NodeProtocolStack ! * @author angela_brown ! * @author bevna_calliess ! * @param inDestIPAddress - The Destination IP Addres eg: 192.168.0.2 ! * @throws CommunicationException ! * @version v0.20 ! */ ! public void sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException{ ! NodeProtocolStack.sendPing(inDestIPAddress); ! } ! ! ! /** ! * This method will check to see if the Interface key is contained within the ! * NetworkInterfacetable (hash table) if so typecast it into a EthernetNetworkInterface Object ! * and send the packet and Destination MAC address up to the EthernetNetworkInterface layer ! * @author bevan_calliess ! * @author angela_brown ! * @param inDestMACAddress - Destination MAC address eg: AA:A1:BC:34:65 ! * @param inPacket - A Packet ! * @param inInterfaceKey - The Inteface Key ! * @throws InvalidNetworkInterfaceNameException ! * @version v0.20 ! */ ! public void sendPacket(String inDestMACAddress, Packet inPacket, String inInterfaceKey) throws InvalidNetworkInterfaceNameException, CommunicationException, LowLinkException{ ! if (NetworkInterfacetable.containsKey(inInterfaceKey)) ! { ! EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); ! temp.sendPacket(inPacket,inDestMACAddress); ! } ! else ! { ! throw new InvalidNetworkInterfaceNameException("Inteface does not exist."); ! } ! } ! ! ! /** ! * This method will get the defaultgateway when called from the NodeProtocolStack ! * @author angela_brown ! * @author michael_reith ! * @return Defaultgateway ! * @version v0.20 ! */ ! public String getDefaultGateway() { ! return NodeProtocolStack.getDefaultGateway(); ! } ! ! /** ! * gets a string array from the arp protocol and returns it ! * @author robert_hulford ! * @author bevan_calliess ! * @return String[] - The arp table entries ! */ ! public String[] getARPTable() { ! return NodeProtocolStack.getARPTable(); ! } ! ! /** ! * This method will pass inIterface, incustomeSubnetMask up to the NodeProtocolStack ! * with the aim to set the CustomSubnetMask ! * @author bevan_calliess ! * @author robert_hulford ! * @param inInterface ! * @param inCustomSubnetMask ! * @throws InvalidNetworkInterfaceNameException ! * @throws InvalidSubnetMaskException ! * @version v0.20 ! */ ! ! public void setCustomSubnetMask(String inInterface, String inCustomSubnetMask)throws InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { ! if(NetworkInterfacetable.containsKey(inInterface)){ ! NodeProtocolStack.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! }else{ ! throw new InvalidNetworkInterfaceNameException("Interface does not exsist"); ! } ! } ! ! /** ! * This method will call the setDefaultgatway method within the NodeProtocolStack passing it ! * the inGatewayIPAddress ! * @author angela_brown ! * @author michael_reith ! * @param inGatewayIPAddress ! * @throws InvalidNodeNameException ! * @throws InvalidDefaultGatewayException ! * @version v0.20 ! */ ! ! public void setDefaultGateway(String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException{ ! NodeProtocolStack.setDefaultGateway(inGatewayIPAddress); ! } ! ! /** ! * This method will set the ip address for a network interface. ! * It will test if the inInterface exists and returns the MAC address of the netwokInterface set. ! * @param inInterface - The Interface name eg: eth0 ! * @param inIPAddress - The IP address eg: 192.168.0.2 ! * @return macAddress - The MAC address on the Interface card that the IP address was set for. ! * @throws InvalidNetworkInterfaceNameException ! * @throws InvalidIPAddressException ! */ ! ! protected String setIPAddress(String inInterface, String inIPAddress) throws InvalidNetworkInterfaceNameException,InvalidIPAddressException { ! String macAddress = null; ! if (NetworkInterfacetable.containsKey(inInterface)) { ! NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! EthernetNetworkInterface tempNic = ! (EthernetNetworkInterface) NetworkInterfacetable.get( ! inInterface); ! macAddress = tempNic.getMACAddress(); ! ! } else { ! throw new InvalidNetworkInterfaceNameException("Interface does not exist"); ! } ! return macAddress; ! } ! ! /** ! * This method will call the protocol stacks' add to ARP method ! * passing the ip address and the mac address ! * @author bevan_calliess ! * @author robert_hulford ! * @param inMACAddress - The MAC Address eg: ab:ab:ab:ab:ab:ab ! * @param inIPAddress - The IPAddress eg: 192.168.0.2 ! * @version v0.20 ! */ ! public void addToARP(String inIPAddress, String inMACAddress){ ! NodeProtocolStack.addToARP(inIPAddress, inMACAddress); ! } ! ! /** ! * ARP functions... ! * Shall be documented as well. ! * @author Key ! * @version v0.21 ! */ ! public void addToARPStatic(String inIPAddress, String inMACAddress){ ! NodeProtocolStack.addToARPStatic(inIPAddress, inMACAddress); ! } ! ! public void removeARP(String inIPAddress){ ! NodeProtocolStack.removeARP(inIPAddress); ! } ! ! /** ! * ! * @return ! */ ! public Object[] getAllInterfaces(){ ! ! ArrayList interfaceArray = new ArrayList(); ! 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(); ! } ! ! /** ! * Routing tables functions... Use carefully! ! * Shall be documented as well. ! * @author Key ! * @version v0.21 ! */ ! ! public void addRoute(Route_entry r){ ! NodeProtocolStack.addRoute(r); ! } ! ! public void removeRoute(String destIP){ ! NodeProtocolStack.removeRoute(destIP); ! } ! ! public String[] getRouteTableEntries(){ ! return NodeProtocolStack.getRouteTableEntries(); ! } ! ! public Route_entry getRouteTableEntry(String destIP){ ! return NodeProtocolStack.getRouteTableEntry(destIP); ! } ! ! }//EOF |
From: Alexander B. <da...@us...> - 2005-11-19 21:53:58
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5833 Modified Files: TODO.txt Log Message: Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TODO.txt 19 Nov 2005 17:54:33 -0000 1.4 --- TODO.txt 19 Nov 2005 21:53:50 -0000 1.5 *************** *** 39,43 **** 15. UDP (Gift) 16. TCP(Gift && Key). ! --- 39,43 ---- 15. UDP (Gift) 16. TCP(Gift && Key). ! 17. 2Fedor: RIP (over IP) |
From: gift <gi...@us...> - 2005-11-19 20:13:16
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20327/core/protocolsuite/tcp_ip Modified Files: ARP.java Application.java Echo.java ICMP.java ProtocolStack.java Udp.java Log Message: ...ohhh Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Udp.java 19 Nov 2005 11:16:51 -0000 1.5 --- Udp.java 19 Nov 2005 20:13:07 -0000 1.6 *************** *** 71,74 **** --- 71,76 ---- import core.TransportLayerException; + import core.InvalidNetworkLayerDeviceException; + import core.protocolsuite.tcp_ip.ProtocolStack; *************** *** 128,135 **** public class UDP_HashTableElement { ! public byte PortStatus; // 0 - free port; 1 - port is being listened to; 2 - closed; 3 - busy. public Object application; //points to application that listens to this port | provided PortStatus==1 public String connectedtoIP; //contains IP of the other connected computer | provided PortStatus==3 ! public int connectedtoPort; //contains port number of the other connected computer | provided PortStatus==3 } --- 130,137 ---- public class UDP_HashTableElement { ! public byte PortStatus; // 0 - free port; 1 - port is being listened to; 2 - busy. public Object application; //points to application that listens to this port | provided PortStatus==1 public String connectedtoIP; //contains IP of the other connected computer | provided PortStatus==3 ! public int connectedtoPort; //contains port number of the other connected computer | provided PortStatus==3 } *************** *** 142,146 **** * This method assigns the ParentStack * @author gift (sourceforge.net user) ! * @param Protocol Stack * @version v0.20 */ --- 144,148 ---- * This method assigns the ParentStack * @author gift (sourceforge.net user) ! * @param inParentStack protocol stack * @version v0.20 */ *************** *** 161,165 **** } } ! /** --- 163,167 ---- } } ! /** *************** *** 170,178 **** * @return Nothing. * @exception TransportLayerException If UDP CHECK_SUM != 1 * @version v0.20 * @see TransportLayerException ! */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException { --- 172,186 ---- * @return Nothing. * @exception TransportLayerException If UDP CHECK_SUM != 1 + * @exception CommunicationException + * @exception LowLinkException + * @exception InvalidNetworkLayerDeviceException * @version v0.20 * @see TransportLayerException ! * @see CommunicationException ! * @see LowLinkException ! * @see InvalidNetworkLayerDeviceException ! */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { *************** *** 192,202 **** { case 0: //port is free => Error: no application to receive UDP ! throw new TransportLayerException("UDP Error: no application listening to port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"." ); // no "break" needed ;) ! case 1: // port is being listened to by a new application. Have to "establish" (in UDP no connections are being established) a new connection by replacing hashtable element ! Elm.PortStatus=3; //port will be busy from now Elm.connectedtoIP=inPacket.getSourceIPAddress(); Elm.connectedtoPort=inPacket.get_srcPort(); //now we decompose UDP datagram --- 200,213 ---- { case 0: //port is free => Error: no application to receive UDP ! throw new TransportLayerException("UDP Error: no application listening to port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"!" ); // no "break" needed ;) ! case 1: // port is being listened to by a new application. Have to "establish" (in UDP no connections are being established) a new connection by replacing hashtable element ! Elm.PortStatus=2; //port will be busy from now Elm.connectedtoIP=inPacket.getSourceIPAddress(); Elm.connectedtoPort=inPacket.get_srcPort(); + PortTable.remove(inPacket.get_destPort()); //delete old element + PortTable.put((inPacket.get_destPort()),Elm); //hash table update + //now we decompose UDP datagram *************** *** 217,230 **** Simulation.addLayerInfo(UDP_Info); } else { ! throw new TransportLayerException("UDP Error: Incorrect checksum on receiving."); } break; ! ! case 2: //port is closed ! throw new TransportLayerException("UDP Error: port is closed! Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"." ); ! // no "break" needed ;) ! case 3: //busy port, let's check whether it's busy by us (sender) ;) ! if ((Elm.connectedtoIP==inPacket.getSourceIPAddress()) && (Elm.connectedtoPort==inPacket.get_srcPort())) //temporary { //now we decompose UDP datagram --- 228,244 ---- Simulation.addLayerInfo(UDP_Info); + + Application listener; + listener = (Application)Elm.application; + listener.RecvData(inPacket.getUDP_message()); + + } else { ! throw new TransportLayerException("UDP Error: incorrect checksum on receiving!"); } break; ! ! case 2: //busy port, let's check whether it's busy by us (sender) ;) ! if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) //temporary { //now we decompose UDP datagram *************** *** 246,254 **** Simulation.addLayerInfo(UDP_Info); } else { ! throw new TransportLayerException("UDP Error: Incorrect checksum on receiving."); } } else { ! throw new TransportLayerException("UDP Error: Port is connected to another host or/and port. \r\n" + "Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); } break; --- 260,273 ---- Simulation.addLayerInfo(UDP_Info); + + Application listener; + listener = (Application)Elm.application; + listener.RecvData(inPacket.getUDP_message()); + } else { ! throw new TransportLayerException("UDP Error: incorrect checksum on receiving!"); } } else { ! throw new TransportLayerException("UDP Error: port is busy! Port is connected to another host or/and port and is busy by another application. \r\n" + "Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); } break; *************** *** 258,262 **** } } else { ! throw new TransportLayerException("UDP Error: Port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); } } --- 277,281 ---- } } else { ! throw new TransportLayerException("UDP Error: port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); } } *************** *** 269,282 **** * @param inDestIPAddress destination IP address * @param FirstInterfaceName name of the first network intarface of the node that sends UDP e.g. "eth0" ! * @param indestPort destination port number ! * @param insrcPort sorce port number * @return UDP_packet ! * @version v0.20 */ ! public UDP_packet sendUDPPacket(String inDestIPAddress,String FirstInterfaceName,int indestPort, int insrcPort) { ! ! UDP_packet tosend = new UDP_packet(inDestIPAddress,mParentStack.getIPAddress(FirstInterfaceName),indestPort,insrcPort); //Create Layer info --- 288,315 ---- * @param inDestIPAddress destination IP address * @param FirstInterfaceName name of the first network intarface of the node that sends UDP e.g. "eth0" ! * @param indestPort destination port number ! * @param application application that uses port ! * @param inMessage UDP message to send * @return UDP_packet ! * @exception TransportLayerException ! * @version v0.30 ! * @see TransportLayerException */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException { ! int srcPort; ! String SrcIP; ! ! //let's get first interface IP address ! SrcIP=mParentStack.getIPAddress(inFirstInterfaceName); ! ! //let's get a reserved local port number for this application ! srcPort=getApplicationLocalPortNumber(application); ! ! ! UDP_packet tosend = new UDP_packet(inDestIPAddress,SrcIP,indestPort,srcPort); ! ! tosend.setUDP_message(inMessage); //Create Layer info *************** *** 290,294 **** UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet to " + inDestIPAddress + ":" + insrcPort +"."); Simulation.addLayerInfo(UDP_Info); --- 323,327 ---- UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet to " + inDestIPAddress + ":" + srcPort +"."); Simulation.addLayerInfo(UDP_Info); *************** *** 296,300 **** --- 329,657 ---- return tosend; } + + + /** + * This method reserves LOCAL port number for an application in case reserved. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] + * if not found then we reserve a new number + * @author gift (sourceforge.net user) + * @param application that will: take free port or take already occupied port (only by itself) or tell that all ports are busy :( + * @param inDestIPAddress destination IP address + * @param indestPort destination port number + * @return int port number that has been reserved for application + * @exception TransportLayerException in several cases + * @version v0.10 + * @see TransportLayerException + */ + public int getDefinitePortNumber(Object application,String inDestIPAddress, int indestPort) throws TransportLayerException + { + int number=0; + boolean Found=false; + boolean Reserved=false; + Enumeration LocalPorts = PortTable.keys(); + + + UDP_HashTableElement Elm = new UDP_HashTableElement(); + + while ( (LocalPorts.hasMoreElements()) && !(Found) ) + { + number = Integer.valueOf( (String)LocalPorts.nextElement() ); + + Elm = (UDP_HashTableElement) PortTable.get(number); + + if (Elm.application == application) + { + Found=true; + //we have found our application; let's check whom we are connected to + if (Elm.connectedtoIP.equals(inDestIPAddress)) + { + //now goes port number + if (Elm.connectedtoPort==indestPort) + { + //everything is OK, need to return "number" + + } else { + throw new TransportLayerException("UDP Error: application is already connected to another port number! Connected to host: " + Elm.connectedtoIP + ":" + Elm.connectedtoPort + "."); + } + } else { + throw new TransportLayerException("UDP Error: application is already connected to another IP! Connected to host: " + Elm.connectedtoIP + "."); + } + + } + } + + //in case we have not found our application in hash table..... + if (!Found) + { + //lets try to reserve any free port + number=0; + while ( (number<PORT_QUANT) && !(Reserved) ) + { + Elm = (UDP_HashTableElement) PortTable.get(number+PORT_START_NUMBER); + + if (Elm.PortStatus == 0) //free port + { + Reserved=true; + Elm.PortStatus=2; //port will be busy from now + Elm.connectedtoIP=inDestIPAddress; + Elm.connectedtoPort=indestPort; + PortTable.remove(number+PORT_START_NUMBER); //delete old element + PortTable.put(number+PORT_START_NUMBER,Elm); //hash table update + } + number++; + } + + if (!Reserved) //all ports are busy :( + { + throw new TransportLayerException("UDP Error: all ports are busy! Can not send UDP datagram to host " + inDestIPAddress + ":" + indestPort +"."); + } + number+=PORT_START_NUMBER; //to get the real number + } + + return (number); //do not change here! if you want to change here scan again the code + } + + /** + * This method reserves LOCAL UDP port + * @author gift (sourceforge.net user) + * @param application application that uses port + * @param inDestIPAddress destination IP address + * @param indestPort destination port number + * @return int port number that has been reserved for application + * @exception TransportLayerException + * @version v0.30 + * @see TransportLayerException + */ + public int ReservePort(Object application, String inDestIPAddress, int indestPort) throws TransportLayerException + { + //let's get a proper port number for this application + return getDefinitePortNumber(application,inDestIPAddress,indestPort); + } + + /** + * This method finds port number for an application. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] + * @author gift (sourceforge.net user) + * @param application + * @return int port number that has been reserved for application + * @exception TransportLayerException + * @version v0.10 + * @see TransportLayerException + */ + public int getApplicationDestPortNumber(Object application) throws TransportLayerException + { + int number=0; + boolean Found=false; + Set set = PortTable.keySet(); + Iterator itr = set.iterator(); + UDP_HashTableElement Elm = new UDP_HashTableElement(); + + while ( (itr.hasNext()) && !(Found) ) + { + Elm = (UDP_HashTableElement) itr.next(); + + if (Elm.application == application) + { + Found=true; + //we have found our application + number=Elm.connectedtoPort; + } + } + + //in case we have not found our application in hash table..... + if (!Found) + { + throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination port."); + } + return number; + } + + /** + * This method closes the UDP port for an application + * @author gift (sourceforge.net user) + * @param application application that uses port + * @return Nothing + * @exception TransportLayerException + * @version v0.10 + * @see TransportLayerException + */ + public void ClosePort(Object application) throws TransportLayerException //changes port status from 1 (listen) to 0 (free) + { + UDP_HashTableElement Elm = new UDP_HashTableElement(); + int PortToClose=getApplicationLocalPortNumber(application); + + if (Elm.PortStatus==1) + { + Elm.PortStatus=0; + Elm.application=null; + Elm.connectedtoIP=""; + Elm.connectedtoPort=0; + + PortTable.remove(PortToClose); //delete old element + PortTable.put(PortToClose,Elm); //hash table update + } else throw new TransportLayerException("UDP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); + } + + /** + * This method sets the UDP port free + * @author gift (sourceforge.net user) + * @param application application that uses port + * @return Nothing + * @exception TransportLayerException + * @version v0.10 + * @see TransportLayerException + */ + public void FreePort(Object application) throws TransportLayerException //changes port status from 3 (listen) to 0 (free) + { + UDP_HashTableElement Elm = new UDP_HashTableElement(); + int PortToFree=getApplicationLocalPortNumber(application); + + if (Elm.PortStatus==2) + { + Elm.PortStatus=0; + Elm.application=null; + Elm.connectedtoIP=""; + Elm.connectedtoPort=0; + + PortTable.remove(PortToFree); //delete old element + PortTable.put(PortToFree,Elm); //hash table update + } else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); + } + + + /** + * This method sets the UDP port status to 1 (is being listened to) + * NOTE: server must listen to UDP port numbers from 0 to 10000 + * @author gift (sourceforge.net user) + * @param application application that uses port + * @param inPort port that the application want to listen to + * @return Nothing + * @exception TransportLayerException + * @version v0.10 + * @see TransportLayerException + */ + + // else throw new TransportLayerException("UDP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); + + public void ListenPort(Object application, int inPort) throws TransportLayerException + { + if (inPort>=0 && inPort<=10000) + { + UDP_HashTableElement Elm = new UDP_HashTableElement(); + + if ( (Elm = (UDP_HashTableElement)PortTable.get(inPort)) !=null ) + { + switch(Elm.PortStatus) + { + case 0: //port is free => update such a record in hashtable + + Elm.PortStatus=1; + Elm.application=application; + Elm.connectedtoIP=""; + Elm.connectedtoPort=0; + + PortTable.remove(inPort); //delete old element + PortTable.put(inPort,Elm); //hash table update + break; + case 1: // port is being listened to by whom? + if (Elm.application==application) + { + throw new TransportLayerException("UDP Error: already listening to port "+ inPort +"!"); + } else throw new TransportLayerException("UDP Error: port "+ inPort +" is being listened to by another application! Can listen only to free ports." ); + case 2: //port is busy => error + throw new TransportLayerException("UDP Error: port "+ inPort +" is busy! Can listen only to free ports." ); + // no "break" needed ;) + default: //unknown port status + throw new TransportLayerException("UDP Error: unknown port status! Port "+ inPort +" on host \""+ mParentStack.getParentNodeName()+"\"."); + } + + } else + { + //create such a record in hashtable + Elm.PortStatus=1; + Elm.application=application; + Elm.connectedtoIP=""; + Elm.connectedtoPort=0; + + PortTable.put(inPort,Elm); //hash table update + } + } else throw new TransportLayerException("UDP Error: can not listen to port "+ inPort +"! Use port range from 0 to 10000 to listen to."); + } + + /** + * This method finds destination IP (host) for an application. + * @author gift (sourceforge.net user) + * @param application + * @return String destination IP that has been reserved for application + * @exception TransportLayerException + * @version v0.10 + * @see TransportLayerException + */ + public String getApplicationDestIP(Object application) throws TransportLayerException + { + String dIP=null; + boolean Found=false; + Set set = PortTable.keySet(); + Iterator itr = set.iterator(); + UDP_HashTableElement Elm = new UDP_HashTableElement(); + + while ( (itr.hasNext()) && !(Found) ) + { + Elm = (UDP_HashTableElement) itr.next(); + + if (Elm.application == application) + { + Found=true; + //we have found our application + dIP=Elm.connectedtoIP; + } + } + + //in case we have not found our application in hash table..... + if (!Found) + { + throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not find destination IP."); + } + return dIP; + } + + + /** + * This method finds LOCAL port number for an application. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] + * @author gift (sourceforge.net user) + * @param application that will: take free port or take already occupied port (only by itself) or tell that all ports are busy :( + * @return int port number that has been reserved for application + * @exception TransportLayerException in several cases + * @version v0.10 + * @see TransportLayerException + */ + public int getApplicationLocalPortNumber(Object application) throws TransportLayerException + { + int number=0; + boolean Found=false; + boolean Reserved=false; + Enumeration LocalPorts = PortTable.keys(); + UDP_HashTableElement Elm = new UDP_HashTableElement(); + + while ( (LocalPorts.hasMoreElements()) && !(Found) ) + { + number = Integer.valueOf( (String)LocalPorts.nextElement() ); + Elm = (UDP_HashTableElement) PortTable.get(number); + + if (Elm.application == application) + { + Found=true; + //we have found our application + //everything is OK, need to return "number" + } + } + + //in case we have not found our application in hash table..... + if (!Found) + { + throw new TransportLayerException("UDP Error: no local port reserved for the application: \"" + application.toString() + "\"! Can not get local reserved port number."); + } + + return (number); //do not change here! if you want to change here scan again the code + } } //EOF Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ProtocolStack.java 19 Nov 2005 17:54:33 -0000 1.6 --- ProtocolStack.java 19 Nov 2005 20:13:07 -0000 1.7 *************** *** 191,195 **** */ ! public void sendPacket(IP_packet inPacket) throws LowLinkException, CommunicationException{ String destMAC = null; --- 191,195 ---- */ ! public void sendPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; *************** *** 324,328 **** */ ! public void forwardPacket(IP_packet inPacket) throws CommunicationException, LowLinkException{ String destMAC = null; --- 324,328 ---- */ ! public void forwardPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; *************** *** 416,420 **** */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws CommunicationException, LowLinkException{ String destMAC = "FF:FF:FF:FF:FF:FF"; --- 416,420 ---- */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = "FF:FF:FF:FF:FF:FF"; *************** *** 530,534 **** */ ! public void sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException { if(IPV4Address.validateDecIP(inDestIPAddress)){ --- 530,534 ---- */ ! public void sendPing(String inDestIPAddress) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { if(IPV4Address.validateDecIP(inDestIPAddress)){ *************** *** 686,690 **** */ ! public void receivePacket(Packet inPacket) throws LowLinkException{ --- 686,690 ---- */ ! public void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ *************** *** 750,755 **** mARPprotocol.receiveARPPacket(temp); ! }else{ //need to insert tests for all other packet types --- 750,760 ---- mARPprotocol.receiveARPPacket(temp); ! }else if(ipPacket instanceof UDP_packet){ ! ! UDP_packet temp = (UDP_packet)inPacket; ! ! mUDPprotocol.receiveUDPPacket(temp); + }else{ //need to insert tests for all other packet types *************** *** 1209,1249 **** /** ! * This method sends the UDP packet * @author gift (sourceforge.net user) * @param inDestIPAddress destination IP address ! * @param InterfaceName name of the intarface that sends UDP e.g. "eth0" ! * @param indestPort destination port number ! * @param insrcPort sorce port number * @return Nothing * @exception CommunicationException * @exception LowLinkException * @exception InvalidNetworkLayerDeviceException ! * @version v0.20 * @see CommunicationException * @see LowLinkException * @see InvalidNetworkLayerDeviceException */ ! public void sendUDP(String inDestIPAddress, int indestPort, int insrcPort) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { //lets get first network interface name //will be used when resolving source IP of UDP sender ! String FirstInterfaceName; Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); if (FirstInterfaceName!=null) { ! if(IPV4Address.validateDecIP(inDestIPAddress)) ! { ! UDP_packet tosend = mUDPprotocol.sendUDPPacket(inDestIPAddress,FirstInterfaceName,indestPort,insrcPort); ! sendPacket(tosend); }else ! throw new CommunicationException("Packet dropped host unreachable: " + inDestIPAddress); } else throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! } }//EOF --- 1214,1337 ---- /** ! * This method reserves the UDP port * @author gift (sourceforge.net user) + * @param application application that uses port * @param inDestIPAddress destination IP address ! * @param indestPort destination port number ! * @return int port number that has been reserved for application ! * @exception InvalidNetworkLayerDeviceException ! * @exception TransportLayerException ! * @version v0.30 ! * @see InvalidNetworkLayerDeviceException ! * @see TransportLayerException ! */ ! ! public int reserveUDPPort(Object application, String inDestIPAddress, int indestPort) throws InvalidNetworkLayerDeviceException, TransportLayerException ! { ! ! //lets get first network interface name ! //will be used when resolving source IP of UDP sender ! String FirstInterfaceName; ! Node temp = (Node)mParentNode; ! FirstInterfaceName = temp.getFirstInterfaceName(); ! ! if (FirstInterfaceName!=null) ! { ! return mUDPprotocol.ReservePort(application,inDestIPAddress,indestPort); ! } else ! throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! ! } ! ! ! ! /** ! * This method closes the UDP port for an application ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @return Nothing ! * @exception TransportLayerException ! * @version v0.10 ! * @see TransportLayerException ! */ ! ! public void CloseUDP(Object application) throws TransportLayerException ! { ! mUDPprotocol.ClosePort(application); ! } ! ! ! /** ! * This method sets the UDP port free ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @return Nothing ! * @exception TransportLayerException ! * @version v0.10 ! * @see TransportLayerException ! */ ! public void freeUDPPort(Object application) throws TransportLayerException ! { ! mUDPprotocol.FreePort(application); ! } ! ! /** ! * This method sets the UDP port status to 1 (is being listened to) ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @param inPort port that the application want to listen to ! * @return Nothing ! * @exception TransportLayerException ! * @version v0.10 ! * @see TransportLayerException ! */ ! public void ListenUDP(Object application, int inPort) throws TransportLayerException ! { ! mUDPprotocol.ListenPort(application,inPort); ! } ! ! /** ! * This method sends the UDP packet ! * @author gift (sourceforge.net user) ! * @param application the application that sends the message ! * @param inUDPMessage UDP message to send * @return Nothing * @exception CommunicationException * @exception LowLinkException * @exception InvalidNetworkLayerDeviceException ! * @exception TransportLayerException ! * @version v0.30 * @see CommunicationException * @see LowLinkException * @see InvalidNetworkLayerDeviceException + * @see TransportLayerException */ ! public void sendUDP(Object application, String inUDPMessage) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { //lets get first network interface name //will be used when resolving source IP of UDP sender ! String FirstInterfaceName; ! String DestIPAddress; ! int destPort; Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); + + DestIPAddress=mUDPprotocol.getApplicationDestIP(application); + destPort=mUDPprotocol.getApplicationDestPortNumber(application); if (FirstInterfaceName!=null) { ! if(IPV4Address.validateDecIP(DestIPAddress)) ! { ! UDP_packet tosend = mUDPprotocol.sendUDPPacket(application, DestIPAddress,FirstInterfaceName,destPort,inUDPMessage); ! sendPacket(tosend); }else ! throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); } else throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! } }//EOF Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ARP.java 17 Nov 2005 20:13:56 -0000 1.2 --- ARP.java 19 Nov 2005 20:13:07 -0000 1.3 *************** *** 75,78 **** --- 75,82 ---- import core.LayerInfo; + import core.TransportLayerException; + + import core.InvalidNetworkLayerDeviceException; + *************** *** 317,321 **** */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws LowLinkException { --- 321,325 ---- */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { *************** *** 425,429 **** ! public void receiveARPPacket(ARP_packet inARPpacket) throws LowLinkException{ // test if this packet is for a local Address. --- 429,433 ---- ! public void receiveARPPacket(ARP_packet inARPpacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ // test if this packet is for a local Address. Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Application.java 19 Nov 2005 16:16:32 -0000 1.6 --- Application.java 19 Nov 2005 20:13:07 -0000 1.7 *************** *** 9,12 **** --- 9,18 ---- import core.TransportLayerException; + import core.InvalidNetworkLayerDeviceException; + + import core.CommunicationException; + + import core.LowLinkException; + /** * *************** *** 47,51 **** * @version v0.01 */ ! public void Close(){} /** --- 53,57 ---- * @version v0.01 */ ! public void Close() throws TransportLayerException{} /** *************** *** 65,69 **** */ ! public void Disconnect(){} /** --- 71,75 ---- */ ! public void Disconnect()throws TransportLayerException{} /** *************** *** 74,78 **** */ ! public void SendData(String Data) throws TransportLayerException {} /** --- 80,84 ---- */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} /** *************** *** 82,86 **** * @version v0.01 */ ! public void RecvData(String Data) throws TransportLayerException {} public void setPort(int port){ --- 88,92 ---- * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} public void setPort(int port){ Index: ICMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ICMP.java 17 Nov 2005 20:13:56 -0000 1.2 --- ICMP.java 19 Nov 2005 20:13:07 -0000 1.3 *************** *** 73,76 **** --- 73,82 ---- import core.Simulation; + import core.TransportLayerException; + + import core.InvalidNetworkLayerDeviceException; + + + *************** *** 143,147 **** */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws LowLinkException { --- 149,153 ---- */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { *************** *** 195,199 **** */ ! private void echoRequest(ICMP_packet inPacket) throws LowLinkException{ String destIPAddress = inPacket.getSourceIPAddress(); --- 201,205 ---- */ ! private void echoRequest(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destIPAddress = inPacket.getSourceIPAddress(); Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Echo.java 19 Nov 2005 14:26:02 -0000 1.5 --- Echo.java 19 Nov 2005 20:13:07 -0000 1.6 *************** *** 10,13 **** --- 10,20 ---- import core.TransportLayerException; + import core.InvalidNetworkLayerDeviceException; + + import core.CommunicationException; + + import core.LowLinkException; + + /** * *************** *** 27,32 **** */ public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! //mParentStack.ListenUDP(this, listenPort); } --- 34,39 ---- */ public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! mParentStack.ListenUDP(this, listenPort); } *************** *** 38,43 **** * @version v0.01 */ ! public void Close(){ ! //mParentStack.CloseUDP(this); } --- 45,51 ---- * @version v0.01 */ ! public void Close() throws TransportLayerException ! { ! mParentStack.CloseUDP(this); } *************** *** 49,57 **** * @version v0.01 */ ! ! public void ClientConnect(String Host, int port) throws TransportLayerException { sdHost = Host; ! sdPort = port; ! //clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); } --- 57,65 ---- * @version v0.01 */ ! ! public void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException { sdHost = Host; ! sdPort = port; ! clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); } *************** *** 73,78 **** */ ! public void Disconnect(){ ! //mParentStack.freeUDPPort(this); } --- 81,86 ---- */ ! public void Disconnect() throws TransportLayerException { ! mParentStack.freeUDPPort(this); } *************** *** 84,89 **** */ ! public void SendData(String Data) throws TransportLayerException { ! //mParentStack.sendUDP(this, Data); //processing the protocol doings. } --- 92,98 ---- */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException ! { ! mParentStack.sendUDP(this, Data); //processing the protocol doings. } *************** *** 97,101 **** * @version v0.01 */ ! public void RecvData(String Data) throws TransportLayerException { //processing the protocol doings. if(appType == 0){ --- 106,110 ---- * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { //processing the protocol doings. if(appType == 0){ *************** *** 119,123 **** * @version v0.01 */ ! public void SendEcho(String Data, String Host, int port) throws TransportLayerException{ ClientConnect(Host, port); SendData(Data); --- 128,132 ---- * @version v0.01 */ ! public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ ClientConnect(Host, port); SendData(Data); |
From: gift <gi...@us...> - 2005-11-19 20:13:15
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20327/core Modified Files: NetworkInterface.java NetworkInterfacePort.java NetworkLayerDevice.java Node.java ProtocolStack.java Log Message: ...ohhh Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProtocolStack.java 19 Nov 2005 14:26:02 -0000 1.2 --- ProtocolStack.java 19 Nov 2005 20:13:07 -0000 1.3 *************** *** 1,77 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! ! /** ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! ! public abstract class ProtocolStack { ! public static final int TCP_IP = 0; ! public static final int IPX_SPX = 1; ! public static final int IBM_SNA = 2; ! public static final int APPLETALK = 3; ! ! public static int UIDGen; ! /** ! * Future use. All protocol stacks regardless of type must implement ! * recievepacket! ! * @author bevan_calliess ! * @param inPacket ! */ ! public abstract void receivePacket(Packet inPacket) throws LowLinkException; ! ! }//EOF --- 1,154 ---- ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! ! ! /** ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public abstract class ProtocolStack { ! ! public static final int TCP_IP = 0; ! ! public static final int IPX_SPX = 1; ! ! public static final int IBM_SNA = 2; ! ! public static final int APPLETALK = 3; ! ! ! ! public static int UIDGen; ! ! /** ! ! * Future use. All protocol stacks regardless of type must implement ! ! * recievepacket! ! ! * @author bevan_calliess ! ! * @param inPacket ! ! */ ! ! public abstract void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException; ! ! ! ! }//EOF ! Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NetworkLayerDevice.java 8 Nov 2005 20:58:14 -0000 1.2 --- NetworkLayerDevice.java 19 Nov 2005 20:13:07 -0000 1.3 *************** *** 1,289 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! package core; ! import core.EthernetNetworkInterface; ! import core.protocolsuite.tcp_ip.InvalidIPAddressException; ! import core.InvalidNetworkInterfaceNameException; ! import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; ! import core.protocolsuite.tcp_ip.Route_entry; ! import java.util.*; ! ! /** ! * NetworkLayerDevice extends Node. This class adds network layer devices ! * sets IPAddress, defaultgateway, sends a ping and a few more options ! * @author luke_hamilton ! * @author angela_brown ! * @author michael_reith ! * @author robert_hulford ! * @author bevan_calliess ! * @since Oct 9, 2004 ! * @version v0.20 ! */ ! public abstract class NetworkLayerDevice extends Node { ! ! /** ! * calls the super class (Node) and passes it inName and inProtocolStack ! * @author luke_hamilton ! * @author bevan_calliess ! * @param inName - Node Name eg: PC1 ! * @param inProtocolStackLayers - ProtocolStack Layer ! * @version v0.20 ! */ ! public NetworkLayerDevice(String inName, int inProtocolStackLayers) { ! super(inName, inProtocolStackLayers); ! } ! ! /** ! * This method will get the subnetMask of the Interface that was ! * passed in ! * @author bevan_callies ! * @author robert_hulford ! * @param inInteface - The Name of the Inteface eg: eth0 ! * @return The subnetMask ! * @version v0.20 ! */ ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! public String getSubnetMask(String inInterface) { ! return NodeProtocolStack.getSubnetMask(inInterface); ! } ! ! /** ! * This method will get the ipaddress of the Interface that was passed in ! * ! * @author luke_hamilton ! * @param inInteface - The Name of the Inteface eg: eth0 ! * @return The subnetMask ! * @version v0.20 ! ! */ ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! public String getIPAddress(String inInterface){ ! return NodeProtocolStack.getIPAddress(inInterface); ! } ! ! /** ! * This method will pass in a packet and send it off to the ! * nodeProtocolStack ! * @author angela_brown ! * @author bevan_calliess ! * @param inPacket - A Packet ! * @version v0.20 ! */ ! public void receivePacket(Packet inPacket) throws LowLinkException { ! NodeProtocolStack.receivePacket(inPacket); ! } ! ! /** ! * This method will send a ping to the specified Destination ! * Address passing it up to the NodeProtocolStack ! * @author angela_brown ! * @author bevna_calliess ! * @param inDestIPAddress - The Destination IP Addres eg: 192.168.0.2 ! * @throws CommunicationException ! * @version v0.20 ! */ ! public void sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException{ ! NodeProtocolStack.sendPing(inDestIPAddress); ! } ! ! ! /** ! * This method will check to see if the Interface key is contained within the ! * NetworkInterfacetable (hash table) if so typecast it into a EthernetNetworkInterface Object ! * and send the packet and Destination MAC address up to the EthernetNetworkInterface layer ! * @author bevan_calliess ! * @author angela_brown ! * @param inDestMACAddress - Destination MAC address eg: AA:A1:BC:34:65 ! * @param inPacket - A Packet ! * @param inInterfaceKey - The Inteface Key ! * @throws InvalidNetworkInterfaceNameException ! * @version v0.20 ! */ ! public void sendPacket(String inDestMACAddress, Packet inPacket, String inInterfaceKey) throws InvalidNetworkInterfaceNameException, CommunicationException, LowLinkException{ ! if (NetworkInterfacetable.containsKey(inInterfaceKey)) ! { ! EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); ! temp.sendPacket(inPacket,inDestMACAddress); ! } ! else ! { ! throw new InvalidNetworkInterfaceNameException("Inteface does not exist."); ! } ! } ! ! ! /** ! * This method will get the defaultgateway when called from the NodeProtocolStack ! * @author angela_brown ! * @author michael_reith ! * @return Defaultgateway ! * @version v0.20 ! */ ! public String getDefaultGateway() { ! return NodeProtocolStack.getDefaultGateway(); ! } ! ! /** ! * gets a string array from the arp protocol and returns it ! * @author robert_hulford ! * @author bevan_calliess ! * @return String[] - The arp table entries ! */ ! public String[] getARPTable() { ! return NodeProtocolStack.getARPTable(); ! } ! ! /** ! * This method will pass inIterface, incustomeSubnetMask up to the NodeProtocolStack ! * with the aim to set the CustomSubnetMask ! * @author bevan_calliess ! * @author robert_hulford ! * @param inInterface ! * @param inCustomSubnetMask ! * @throws InvalidNetworkInterfaceNameException ! * @throws InvalidSubnetMaskException ! * @version v0.20 ! */ ! ! public void setCustomSubnetMask(String inInterface, String inCustomSubnetMask)throws InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { ! if(NetworkInterfacetable.containsKey(inInterface)){ ! NodeProtocolStack.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! }else{ ! throw new InvalidNetworkInterfaceNameException("Interface does not exsist"); ! } ! } ! ! /** ! * This method will call the setDefaultgatway method within the NodeProtocolStack passing it ! * the inGatewayIPAddress ! * @author angela_brown ! * @author michael_reith ! * @param inGatewayIPAddress ! * @throws InvalidNodeNameException ! * @throws InvalidDefaultGatewayException ! * @version v0.20 ! */ ! ! public void setDefaultGateway(String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException{ ! NodeProtocolStack.setDefaultGateway(inGatewayIPAddress); ! } ! ! /** ! * This method will set the ip address for a network interface. ! * It will test if the inInterface exists and returns the MAC address of the netwokInterface set. ! * @param inInterface - The Interface name eg: eth0 ! * @param inIPAddress - The IP address eg: 192.168.0.2 ! * @return macAddress - The MAC address on the Interface card that the IP address was set for. ! * @throws InvalidNetworkInterfaceNameException ! * @throws InvalidIPAddressException ! */ ! ! protected String setIPAddress(String inInterface, String inIPAddress) throws InvalidNetworkInterfaceNameException,InvalidIPAddressException { ! String macAddress = null; ! if (NetworkInterfacetable.containsKey(inInterface)) { ! NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! EthernetNetworkInterface tempNic = ! (EthernetNetworkInterface) NetworkInterfacetable.get( ! inInterface); ! macAddress = tempNic.getMACAddress(); ! ! } else { ! throw new InvalidNetworkInterfaceNameException("Interface does not exist"); ! } ! return macAddress; ! } ! ! /** ! * This method will call the protocol stacks' add to ARP method ! * passing the ip address and the mac address ! * @author bevan_calliess ! * @author robert_hulford ! * @param inMACAddress - The MAC Address eg: ab:ab:ab:ab:ab:ab ! * @param inIPAddress - The IPAddress eg: 192.168.0.2 ! * @version v0.20 ! */ ! public void addToARP(String inIPAddress, String inMACAddress){ ! NodeProtocolStack.addToARP(inIPAddress, inMACAddress); ! } ! ! /** ! * ARP functions... ! * Shall be documented as well. ! * @author Key ! * @version v0.21 ! */ ! public void addToARPStatic(String inIPAddress, String inMACAddress){ ! NodeProtocolStack.addToARPStatic(inIPAddress, inMACAddress); ! } ! ! public void removeARP(String inIPAddress){ ! NodeProtocolStack.removeARP(inIPAddress); ! } ! ! /** ! * ! * @return ! */ ! public Object[] getAllInterfaces(){ ! ! ArrayList interfaceArray = new ArrayList(); ! 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(); ! } ! ! /** ! * Routing tables functions... Use carefully! ! * Shall be documented as well. ! * @author Key ! * @version v0.21 ! */ ! ! public void addRoute(Route_entry r){ ! NodeProtocolStack.addRoute(r); ! } ! ! public void removeRoute(String destIP){ ! NodeProtocolStack.removeRoute(destIP); ! } ! ! public String[] getRouteTableEntries(){ ! return NodeProtocolStack.getRouteTableEntries(); ! } ! ! public Route_entry getRouteTableEntry(String destIP){ ! return NodeProtocolStack.getRouteTableEntry(destIP); ! } ! ! }//EOF --- 1,578 ---- ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! ! ! package core; ! ! import core.EthernetNetworkInterface; ! ! import core.protocolsuite.tcp_ip.InvalidIPAddressException; ! ! import core.InvalidNetworkInterfaceNameException; ! ! import core.protocolsuite.tcp_ip.InvalidSubnetMaskException; ! ! import core.protocolsuite.tcp_ip.Route_entry; ! ! import java.util.*; ! ! ! ! /** ! ! * NetworkLayerDevice extends Node. This class adds network layer devices ! ! * sets IPAddress, defaultgateway, sends a ping and a few more options ! ! * @author luke_hamilton ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @since Oct 9, 2004 ! ! * @version v0.20 ! ! */ ! ! public abstract class NetworkLayerDevice extends Node { ! ! ! ! /** ! ! * calls the super class (Node) and passes it inName and inProtocolStack ! ! * @author luke_hamilton ! ! * @author bevan_calliess ! ! * @param inName - Node Name eg: PC1 ! ! * @param inProtocolStackLayers - ProtocolStack Layer ! ! * @version v0.20 ! ! */ ! ! public NetworkLayerDevice(String inName, int inProtocolStackLayers) { ! ! super(inName, inProtocolStackLayers); ! ! } ! ! ! ! /** ! ! * This method will get the subnetMask of the Interface that was ! ! * passed in ! ! * @author bevan_callies ! ! * @author robert_hulford ! ! * @param inInteface - The Name of the Inteface eg: eth0 ! ! * @return The subnetMask ! ! * @version v0.20 ! ! */ ! ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! ! public String getSubnetMask(String inInterface) { ! ! return NodeProtocolStack.getSubnetMask(inInterface); ! ! } ! ! ! ! /** ! ! * This method will get the ipaddress of the Interface that was passed in ! ! * ! ! * @author luke_hamilton ! ! * @param inInteface - The Name of the Inteface eg: eth0 ! ! * @return The subnetMask ! ! * @version v0.20 ! ! ! ! */ ! ! //TODO This should maybe check the inInterface exists within the Interface hashtable first -luke hamilton ! ! public String getIPAddress(String inInterface){ ! ! return NodeProtocolStack.getIPAddress(inInterface); ! ! } ! ! ! ! /** ! ! * This method will pass in a packet and send it off to the ! ! * nodeProtocolStack ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @param inPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! public void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { ! ! NodeProtocolStack.receivePacket(inPacket); ! ! } ! ! ! ! /** ! ! * This method will send a ping to the specified Destination ! ! * Address passing it up to the NodeProtocolStack ! ! * @author angela_brown ! ! * @author bevna_calliess ! ! * @param inDestIPAddress - The Destination IP Addres eg: 192.168.0.2 ! ! * @throws CommunicationException ! ! * @version v0.20 ! ! */ ! ! public void sendPing(String inDestIPAddress) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! NodeProtocolStack.sendPing(inDestIPAddress); ! ! } ! ! ! ! ! ! /** ! ! * This method will check to see if the Interface key is contained within the ! ! * NetworkInterfacetable (hash table) if so typecast it into a EthernetNetworkInterface Object ! ! * and send the packet and Destination MAC address up to the EthernetNetworkInterface layer ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inDestMACAddress - Destination MAC address eg: AA:A1:BC:34:65 ! ! * @param inPacket - A Packet ! ! * @param inInterfaceKey - The Inteface Key ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @version v0.20 ! ! */ ! ! public void sendPacket(String inDestMACAddress, Packet inPacket, String inInterfaceKey) throws InvalidNetworkInterfaceNameException, TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! if (NetworkInterfacetable.containsKey(inInterfaceKey)) ! ! { ! ! EthernetNetworkInterface temp = (EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceKey); ! ! temp.sendPacket(inPacket,inDestMACAddress); ! ! } ! ! else ! ! { ! ! throw new InvalidNetworkInterfaceNameException("Inteface does not exist."); ! ! } ! ! } ! ! ! ! ! ! /** ! ! * This method will get the defaultgateway when called from the NodeProtocolStack ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @return Defaultgateway ! ! * @version v0.20 ! ! */ ! ! public String getDefaultGateway() { ! ! return NodeProtocolStack.getDefaultGateway(); ! ! } ! ! ! ! /** ! ! * gets a string array from the arp protocol and returns it ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @return String[] - The arp table entries ! ! */ ! ! public String[] getARPTable() { ! ! return NodeProtocolStack.getARPTable(); ! ! } ! ! ! ! /** ! ! * This method will pass inIterface, incustomeSubnetMask up to the NodeProtocolStack ! ! * with the aim to set the CustomSubnetMask ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inInterface ! ! * @param inCustomSubnetMask ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @throws InvalidSubnetMaskException ! ! * @version v0.20 ! ! */ ! ! ! ! public void setCustomSubnetMask(String inInterface, String inCustomSubnetMask)throws InvalidNetworkInterfaceNameException,InvalidSubnetMaskException { ! ! if(NetworkInterfacetable.containsKey(inInterface)){ ! ! NodeProtocolStack.setCustomSubnetMask(inInterface, inCustomSubnetMask); ! ! }else{ ! ! throw new InvalidNetworkInterfaceNameException("Interface does not exsist"); ! ! } ! ! } ! ! ! ! /** ! ! * This method will call the setDefaultgatway method within the NodeProtocolStack passing it ! ! * the inGatewayIPAddress ! ! * @author angela_brown ! ! * @author michael_reith ! ! * @param inGatewayIPAddress ! ! * @throws InvalidNodeNameException ! ! * @throws InvalidDefaultGatewayException ! ! * @version v0.20 ! ! */ ! ! ! ! public void setDefaultGateway(String inGatewayIPAddress) throws InvalidNodeNameException, InvalidDefaultGatewayException{ ! ! NodeProtocolStack.setDefaultGateway(inGatewayIPAddress); ! ! } ! ! ! ! /** ! ! * This method will set the ip address for a network interface. ! ! * It will test if the inInterface exists and returns the MAC address of the netwokInterface set. ! ! * @param inInterface - The Interface name eg: eth0 ! ! * @param inIPAddress - The IP address eg: 192.168.0.2 ! ! * @return macAddress - The MAC address on the Interface card that the IP address was set for. ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @throws InvalidIPAddressException ! ! */ ! ! ! ! protected String setIPAddress(String inInterface, String inIPAddress) throws InvalidNetworkInterfaceNameException,InvalidIPAddressException { ! ! String macAddress = null; ! ! if (NetworkInterfacetable.containsKey(inInterface)) { ! ! NodeProtocolStack.setIPAddress(inInterface, inIPAddress); ! ! EthernetNetworkInterface tempNic = ! ! (EthernetNetworkInterface) NetworkInterfacetable.get( ! ! inInterface); ! ! macAddress = tempNic.getMACAddress(); ! ! ! ! } else { ! ! throw new InvalidNetworkInterfaceNameException("Interface does not exist"); ! ! } ! ! return macAddress; ! ! } ! ! ! ! /** ! ! * This method will call the protocol stacks' add to ARP method ! ! * passing the ip address and the mac address ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inMACAddress - The MAC Address eg: ab:ab:ab:ab:ab:ab ! ! * @param inIPAddress - The IPAddress eg: 192.168.0.2 ! ! * @version v0.20 ! ! */ ! ! public void addToARP(String inIPAddress, String inMACAddress){ ! ! NodeProtocolStack.addToARP(inIPAddress, inMACAddress); ! ! } ! ! ! ! /** ! ! * ARP functions... ! ! * Shall be documented as well. ! ! * @author Key ! ! * @version v0.21 ! ! */ ! ! public void addToARPStatic(String inIPAddress, String inMACAddress){ ! ! NodeProtocolStack.addToARPStatic(inIPAddress, inMACAddress); ! ! } ! ! ! ! public void removeARP(String inIPAddress){ ! ! NodeProtocolStack.removeARP(inIPAddress); ! ! } ! ! ! ! /** ! ! * ! ! * @return ! ! */ ! ! public Object[] getAllInterfaces(){ ! ! ! ! ArrayList interfaceArray = new ArrayList(); ! ! 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(); ! ! } ! ! ! ! /** ! ! * Routing tables functions... Use carefully! ! ! * Shall be documented as well. ! ! * @author Key ! ! * @version v0.21 ! ! */ ! ! ! ! public void addRoute(Route_entry r){ ! ! NodeProtocolStack.addRoute(r); ! ! } ! ! ! ! public void removeRoute(String destIP){ ! ! NodeProtocolStack.removeRoute(destIP); ! ! } ! ! ! ! public String[] getRouteTableEntries(){ ! ! return NodeProtocolStack.getRouteTableEntries(); ! ! } ! ! ! ! public Route_entry getRouteTableEntry(String destIP){ ! ! return NodeProtocolStack.getRouteTableEntry(destIP); ! ! } ! ! ! ! }//EOF ! Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Node.java 19 Nov 2005 11:16:51 -0000 1.3 --- Node.java 19 Nov 2005 20:13:07 -0000 1.4 *************** *** 233,237 **** */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { return; --- 233,237 ---- */ ! protected void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { return; Index: NetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NetworkInterface.java 8 Nov 2005 15:35:29 -0000 1.1 --- NetworkInterface.java 19 Nov 2005 20:13:07 -0000 1.2 *************** *** 1,200 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterface represents the physical interface between ! * a Node and a physical Link (network cable). Think of it as the NIC ! * (Network Interface Card) of a Node. ! * ! * <P>Different Nodes can contain different numbers of NetworkInterfaces. ! * A client PC usually only has one NetworkInterface, whereas a Router contains ! * at least two. A Hub or a Switch often has 8 or 16.</P> ! * ! * <P>In order for a Node to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author tristan_veness (Original Author) ! * @author bevan_calliess ! * @author luke_hamilton ! * @since 19 September 2004 ! * @version v0.20 ! */ ! ! abstract class NetworkInterface implements Serializable{ ! /** The NetworkInterface's name, eg "eth0" */ ! protected String name; ! /** The Link that this NetworkInterface is connected to */ ! protected Link connectedLink; ! protected Node parentNode; ! ! /** ! * Constructs a NetworkInterface object with the name inName and a reference to it's parent Node. ! * @author tristan_veness ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param parent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.10 ! */ ! protected NetworkInterface(String inName, Node inParent) { ! name = inName; ! parentNode = inParent; ! } ! ! /** ! * This method reset the connected link to null ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void resetConnectedLink() { ! connectedLink = null; ! } ! ! /** ! * This method will call the disconnectLink method on the ! * Connected link, and then set the connected link to null ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void removeConnectedLink() { ! if(connectedLink != null){ ! connectedLink.disconnectLink(); ! connectedLink = null; ! } ! } ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * This method is overridded by the subclasses on interface to suite ! * there requirements ! * @author baven_calliess ! * @param inPacket - A packet ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException {} ! ! /** ! * This method sends a packet to a connected link Depending on ! * @author bevan_calliess ! * @param inPacket ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException {} ! ! /** ! * Returns the NetworkInterface's name. ! * @author bevan_calliess ! * @return Name - The NetworkInterface's name ! * @version v0.20 ! */ ! ! protected String getName() { ! return name; ! } ! ! /** ! * This method is used by interfaces to uniquely identify themselves ! * in the simulation it will return a combination of the ! * Parent naodes name and the Interfaces name ! * eg. Node name PC1 interface eth0 will return "PC1eth0" ! * @author bevan_calliess ! * @return Name - The Source name of this Node Interface ! * @version v0.20 ! */ ! protected String getSourceName() { ! return parentNode.getName()+name; ! } ! ! /** ! * Sets the connectedLink attribute of the NetworkInterface with Link l. ! * ! * <P>This method should only be called by the Link class when an Interface is added or removed from the Link.</P> ! * @author tristan_veness ! * @param l - The Link connected with this NetworkInterface. ! * @version v0.10 ! */ ! protected void setConnectedLink(Link l)throws InvalidLinkConnectionException { ! if(connectedLink == null){ ! connectedLink = l; ! }else ! throw new InvalidLinkConnectionException("Network Interface is already connected. Delete Connected link first"); ! ! } ! ! /** ! * Returns the Link that this NetworkInterface is connected to. ! * @author tristan_veness ! * @return The Link object that this NetworkInterface is connected to. null if it is not connected. ! * @version v0.10 ! */ ! protected Link getConnectedLink() { ! return connectedLink; ! } ! ! protected String getConnectedLinkName() { ! if(connectedLink!=null) return connectedLink.getName(); ! else return null; ! } ! ! /** ! * This method returns the name of the network interface ! * @author tristan_veness ! * @return Name ! * @version v0.10 ! */ ! protected String getDetails(){ ! return name; ! } ! ! /** ! * This method returns a string of information about if the network interface is connected of not. ! * <P>This method is useful for a CLI or for debugging.</P> ! * @author tristan_veness ! * @return Name - Connection: link1 ! * @version v0.10 ! */ ! protected String getConnectLinkDetails(){ ! if(connectedLink != null){ ! return "Connection: "+ connectedLink.getName(); ! } ! return "Connection: Not connected"; ! } ! ! protected String getConnectLinkName() ! { ! if(connectedLink !=null) ! { ! return (String)connectedLink.getName(); ! } ! return "Not Connected"; ! } ! }//EOF --- 1,400 ---- ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! import java.io.Serializable; ! ! /** ! ! * A NetworkInterface represents the physical interface between ! ! * a Node and a physical Link (network cable). Think of it as the NIC ! ! * (Network Interface Card) of a Node. ! ! * ! ! * <P>Different Nodes can contain different numbers of NetworkInterfaces. ! ! * A client PC usually only has one NetworkInterface, whereas a Router contains ! ! * at least two. A Hub or a Switch often has 8 or 16.</P> ! ! * ! ! * <P>In order for a Node to be able to send or receive network information (packets), ! ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! ! * ! ! * <P>NetworkInterfaces receive and send packets to and from DatalinkProtocols and ! ! * the Link object they are connected to.</P> ! ! * ! ! * @author tristan_veness (Original Author) ! ! * @author bevan_calliess ! ! * @author luke_hamilton ! ! * @since 19 September 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! abstract class NetworkInterface implements Serializable{ ! ! /** The NetworkInterface's name, eg "eth0" */ ! ! protected String name; ! ! /** The Link that this NetworkInterface is connected to */ ! ! protected Link connectedLink; ! ! protected Node parentNode; ! ! ! ! /** ! ! * Constructs a NetworkInterface object with the name inName and a reference to it's parent Node. ! ! * @author tristan_veness ! ! * @param inName - The name to give the NetworkInterface eg: eth0 ! ! * @param parent - The Node that the NetworkInterface is to be added to, it's parent. ! ! * @version v0.10 ! ! */ ! ! protected NetworkInterface(String inName, Node inParent) { ! ! name = inName; ! ! parentNode = inParent; ! ! } ! ! ! ! /** ! ! * This method reset the connected link to null ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void resetConnectedLink() { ! ! connectedLink = null; ! ! } ! ! ! ! /** ! ! * This method will call the disconnectLink method on the ! ! * Connected link, and then set the connected link to null ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void removeConnectedLink() { ! ! if(connectedLink != null){ ! ! connectedLink.disconnectLink(); ! ! connectedLink = null; ! ! } ! ! } ! ! ! ! /** ! ! * This method recevie a packet from a connected link and then pass it ! ! * to the node's protocolstack. Depending on the network any ! ! * testing of the packets headers may need to be inserted here. ! ! * This method is overridded by the subclasses on interface to suite ! ! * there requirements ! ! * @author baven_calliess ! ! * @param inPacket - A packet ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException {} ! ! ! ! /** ! ! * This method sends a packet to a connected link Depending on ! ! * @author bevan_calliess ! ! * @param inPacket ! ! * @version v0.20 ! ! */ ! ! protected void sendPacket(Packet outPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException {} ! ! ! ! /** ! ! * Returns the NetworkInterface's name. ! ! * @author bevan_calliess ! ! * @return Name - The NetworkInterface's name ! ! * @version v0.20 ! ! */ ! ! ! ! protected String getName() { ! ! return name; ! ! } ! ! ! ! /** ! ! * This method is used by interfaces to uniquely identify themselves ! ! * in the simulation it will return a combination of the ! ! * Parent naodes name and the Interfaces name ! ! * eg. Node name PC1 interface eth0 will return "PC1eth0" ! ! * @author bevan_calliess ! ! * @return Name - The Source name of this Node Interface ! ! * @version v0.20 ! ! */ ! ! protected String getSourceName() { ! ! return parentNode.getName()+name; ! ! } ! ! ! ! /** ! ! * Sets the connectedLink attribute of the NetworkInterface with Link l. ! ! * ! ! * <P>This method should only be called by the Link class when an Interface is added or removed from the Link.</P> ! ! * @author tristan_veness ! ! * @param l - The Link connected with this NetworkInterface. ! ! * @version v0.10 ! ! */ ! ! protected void setConnectedLink(Link l)throws InvalidLinkConnectionException { ! ! if(connectedLink == null){ ! ! connectedLink = l; ! ! }else ! ! throw new InvalidLinkConnectionException("Network Interface is already connected. Delete Connected link first"); ! ! ! ! } ! ! ! ! /** ! ! * Returns the Link that this NetworkInterface is connected to. ! ! * @author tristan_veness ! ! * @return The Link object that this NetworkInterface is connected to. null if it is not connected. ! ! * @version v0.10 ! ! */ ! ! protected Link getConnectedLink() { ! ! return connectedLink; ! ! } ! ! ! ! protected String getConnectedLinkName() { ! ! if(connectedLink!=null) return connectedLink.getName(); ! ! else return null; ! ! } ! ! ! ! /** ! ! * This method returns the name of the network interface ! ! * @author tristan_veness ! ! * @return Name ! ! * @version v0.10 ! ! */ ! ! protected String getDetails(){ ! ! return name; ! ! } ! ! ! ! /** ! ! * This method returns a string of information about if the network interface is connected of not. ! ! * <P>This method is useful for a CLI or for debugging.</P> ! ! * @author tristan_veness ! ! * @return Name - Connection: link1 ! ! * @version v0.10 ! ! */ ! ! protected String getConnectLinkDetails(){ ! ! if(connectedLink != null){ ! ! return "Connection: "+ connectedLink.getName(); ! ! } ! ! return "Connection: Not connected"; ! ! } ! ! ! ! protected String getConnectLinkName() ! ! { ! ! if(connectedLink !=null) ! ! { ! ! return (String)connectedLink.getName(); ! ! } ! ! return "Not Connected"; ! ! } ! ! }//EOF ! Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NetworkInterfacePort.java 8 Nov 2005 15:35:29 -0000 1.1 --- NetworkInterfacePort.java 19 Nov 2005 20:13:07 -0000 1.2 *************** *** 1,103 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterfacePort represents the physical interface between ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! * ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! * ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author bevan_valliess ! * @since 13 Nov 2004 ! * @version v0.20 ! */ ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! /** ! * Constructs a NetworkInterfacePort object with the name inName ! * and a reference to it's parent Node. ! * @author baven_calliess ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.20 ! */ ! protected NetworkInterfacePort(String inName, Node inParent) { ! super(inName,inParent); ! } ! ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * @author bevan_calliess ! * @param inPacket - The packet being recived by this port ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! parentNode.receivePacket(inPacket, name); ! return; ! } ! ! /** ! * This method sends a packet to a connected link Depending ! * it is used by the datalinkLayer devices to tansport ! * packets without any validation or data checking. ! * @author bevan_calliess ! * @author angela_brown ! * @param outPacket - A Packet ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException{ ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! EthernetLink temp = (EthernetLink)connectedLink; ! ! if(temp!=null){ ! temp.transportPacket(tempPacket,getSourceName()); ! } ! } ! ! /** ! * This method returns information about this InterfacePort ! * @author bevan_calliess ! * @return String - The details of Interface name Mac and Links ! * @version v0.20 ! */ ! protected String getDetails(){ ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! } ! }//EOF --- 1,206 ---- ! /* ! ! Java Firewall Simulator (jFirewallSim) ! ! ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! ! ! Redistribution and use in source and binary forms, with or without modification, are ! ! permitted provided that the following conditions are met: ! ! ! ! - Redistributions of source code must retain the above copyright notice, this list ! ! of conditions and the following disclaimer. ! ! - Redistributions in binary form must reproduce the above copyright notice, this list ! ! of conditions and the following disclaimer in the documentation and/or other ! ! materials provided with the distribution. ! ! - Neither the name of the Canberra Institute of Technology nor the names of its ! ! contributors may be used to endorse or promote products derived from this software ! ! without specific prior written permission. ! ! ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! */ ! ! package core; ! ! import java.io.Serializable; ! ! /** ! ! * A NetworkInterfacePort represents the physical interface between ! ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! ! * ! ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! ! * ! ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! ! * ! ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! ! * the Link object they are connected to.</P> ! ! * ! ! * @author bevan_valliess ! ! * @since 13 Nov 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! ! ! /** ! ! * Constructs a NetworkInterfacePort object with the name inName ! ! * and a reference to it's parent Node. ! ! * @author baven_calliess ! ! * @param inName - The name to give the NetworkInterface eg: eth0 ! ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! ! * @version v0.20 ! ! */ ! ! protected NetworkInterfacePort(String inName, Node inParent) { ! ! super(inName,inParent); ! ! } ! ! ! ! ! ! /** ! ! * This method recevie a packet from a connected link and then pass it ! ! * to the node's protocolstack. Depending on the network any ! ! * testing of the packets headers may need to be inserted here. ! ! * @author bevan_calliess ! ! * @param inPacket - The packet being recived by this port ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! ! parentNode.receivePacket(inPacket, name); ! ! return; ! ! } ! ! ! ! /** ! ! * This method sends a packet to a connected link Depending ! ! * it is used by the datalinkLayer devices to tansport ! ! * packets without any validation or data checking. ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param outPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! protected void sendPacket(Packet outPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ ! ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! ! EthernetLink temp = (EthernetLink)connectedLink; ! ! ! ! if(temp!=null){ ! ! temp.transportPacket(tempPacket,getSourceName()); ! ! } ! ! } ! ! ! ! /** ! ! * This method returns information about this InterfacePort ! ! * @author bevan_calliess ! ! * @return String - The details of Interface name Mac and Links ! ! * @version v0.20 ! ! */ ! ! protected String getDetails(){ ! ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! ! } ! ! }//EOF ! |
From: Alexander B. <da...@us...> - 2005-11-19 17:54:41
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18442/guiUI Modified Files: MainScreen.java Log Message: +Dirty lines (without save/load). Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MainScreen.java 19 Nov 2005 16:16:32 -0000 1.4 --- MainScreen.java 19 Nov 2005 17:54:33 -0000 1.5 *************** *** 475,498 **** if(dlgSendPing.getWasOKPressed()) { ! try{ String strDestinationIP = dlgSendPing.getDestinationIPAddress(); Sim.sendPing(inNodeName, strDestinationIP); ! Vector vecRecordedInfo = Sim.getRecordedInfo(); ! if(vecRecordedInfo.size()==0){ ! pnlConsole.append("No entries to display. \n"); ! }else{ ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("The following is a record of the last Transactions movements. \n"); ! pnlConsole.append("**************************************************************************************************************** \n"); ! Iterator it = vecRecordedInfo.iterator(); ! while(it.hasNext()){ ! String recording[] = (String[])it.next(); ! pnlConsole.append(pad(recording[1],15,' ')+pad(recording[2],25,' ')+pad(recording[3],15,' ')+pad(recording[4],10,' ')+recording[5]+ "\n"); ! } ! pnlConsole.append("****************************************************************************************************************\n"); ! Sim.clearLayerInfo(); ! } ! } catch(LowLinkException e){ --- 475,488 ---- if(dlgSendPing.getWasOKPressed()) { ! try{ ! ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("Starting network transfer... \n"); ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("\n"); String strDestinationIP = dlgSendPing.getDestinationIPAddress(); Sim.sendPing(inNodeName, strDestinationIP); ! } catch(LowLinkException e){ *************** *** 509,513 **** pnlConsole.append(e.toString()+"\n"); } ! // Ok button was pressed. } --- 499,518 ---- pnlConsole.append(e.toString()+"\n"); } ! pnlConsole.append("\n"); ! Vector vecRecordedInfo = Sim.getRecordedInfo(); ! if(vecRecordedInfo.size()==0){ ! pnlConsole.append("No entries to display. \n"); ! }else{ ! pnlConsole.append("**************************************************************************************************************** \n"); ! pnlConsole.append("The following is a record of the last Transactions movements. \n"); ! pnlConsole.append("**************************************************************************************************************** \n"); ! Iterator it = vecRecordedInfo.iterator(); ! while(it.hasNext()){ ! String recording[] = (String[])it.next(); ! pnlConsole.append(pad(recording[1],15,' ')+pad(recording[2],25,' ')+pad(recording[3],15,' ')+pad(recording[4],10,' ')+recording[5]+ "\n"); ! } ! pnlConsole.append("****************************************************************************************************************\n"); ! Sim.clearLayerInfo(); ! } // Ok button was pressed. } |
From: Alexander B. <da...@us...> - 2005-11-19 17:54:41
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18442/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Log Message: +Dirty lines (without save/load). Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ProtocolStack.java 19 Nov 2005 11:16:51 -0000 1.5 --- ProtocolStack.java 19 Nov 2005 17:54:33 -0000 1.6 *************** *** 288,295 **** }catch(LowLinkException ex){ ! throw new LowLinkException("Hub buffer overflow (packet loop flood?). Please check hubs state."); ! ! }catch(CommunicationException ex){ --- 288,294 ---- }catch(LowLinkException ex){ + throw new LowLinkException(ex.toString()); ! }catch(CommunicationException ex){ |
From: Alexander B. <da...@us...> - 2005-11-19 17:54:41
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18442/core Modified Files: EthernetLink.java EthernetNetworkInterface.java Log Message: +Dirty lines (without save/load). Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EthernetLink.java 8 Nov 2005 15:35:29 -0000 1.1 --- EthernetLink.java 19 Nov 2005 17:54:33 -0000 1.2 *************** *** 76,83 **** { NetworkInterface temp = (NetworkInterface) it.next(); - if (!temp.getSourceName().equals(inSourceName)) { temp.receivePacket(inPacket); } } --- 76,84 ---- { NetworkInterface temp = (NetworkInterface) it.next(); if (!temp.getSourceName().equals(inSourceName)) { + if( (sievingCoefficient/100)>Math.random()) temp.receivePacket(inPacket); + else throw new LowLinkException("Packet lost due to physical link problems!"); } } Index: EthernetNetworkInterface.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetNetworkInterface.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EthernetNetworkInterface.java 8 Nov 2005 15:35:29 -0000 1.1 --- EthernetNetworkInterface.java 19 Nov 2005 17:54:33 -0000 1.2 *************** *** 139,143 **** --- 139,154 ---- if(temp!=null){ + try{ temp.transportPacket(Packet,getSourceName()); + }catch(LowLinkException ex){ + LayerInfo frameErrInfo = new LayerInfo(getClass().getName()); + frameErrInfo.setObjectName(parentNode.getName()); + frameErrInfo.setDataType("Ethernet Packet"); + frameErrInfo.setLayer("Link"); + frameErrInfo.setDescription(ex.toString()); + Simulation.addLayerInfo(frameErrInfo); + System.out.println("!!!"); + //throw new LowLinkException(ex.toString()); + } } } |
From: Alexander B. <da...@us...> - 2005-11-19 17:54:40
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18442 Modified Files: TODO.txt Log Message: +Dirty lines (without save/load). Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TODO.txt 19 Nov 2005 16:55:37 -0000 1.3 --- TODO.txt 19 Nov 2005 17:54:33 -0000 1.4 *************** *** 39,43 **** 15. UDP (Gift) 16. TCP(Gift && Key). ! 17. ***IMPORTANT***: Dirty lines[links]!!! --- 39,43 ---- 15. UDP (Gift) 16. TCP(Gift && Key). ! |
From: Alexander B. <da...@us...> - 2005-11-19 16:55:52
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4295/core Modified Files: Link.java Simulation.java Log Message: Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Simulation.java 19 Nov 2005 14:26:02 -0000 1.3 --- Simulation.java 19 Nov 2005 16:55:37 -0000 1.4 *************** *** 500,503 **** --- 500,537 ---- } + /** + * Get link probability. + * @author Key + * @param inLinkName - The name of the link eg: Link1 + * @throws InvalidLinkNameException + * @version v0.20 + **/ + public double GetLinkProb(String inLinkName) throws InvalidLinkNameException{ + if(linkTable.containsKey(inLinkName)){ + Link lnk = (Link)linkTable.get(inLinkName); + return lnk.getSC(); + }else{ + throw new InvalidLinkNameException("Link does not exist"); + } + + } + + /** + * Get link probability. + * @author Key + * @param inLinkName - The name of the link eg: Link1 + * @param SC - sieve coefficient: *TODO* - description + * @throws InvalidLinkNameException + * @version v0.20 + **/ + public void SetLinkProb(String inLinkName, double SC) throws InvalidLinkNameException{ + if(linkTable.containsKey(inLinkName)){ + ((Link)linkTable.get(inLinkName)).setSC(SC); + }else{ + throw new InvalidLinkNameException("Link does not exist"); + } + + } + /** * This method checks to see if inLinkName is contained within the has table(linkTable).If so, Index: Link.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Link.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Link.java 8 Nov 2005 15:35:29 -0000 1.1 --- Link.java 19 Nov 2005 16:55:37 -0000 1.2 *************** *** 63,67 **** --- 63,85 ---- /** Name of the link */ protected String name; + + protected double sievingCoefficient; + + /** *TODO*: javaDoc + * + */ + public double getSC(){ + return sievingCoefficient; + } + + + /** *TODO*: javaDoc + * + */ + public void setSC(double SC){ + sievingCoefficient = SC; + } + /** * Constructs a Link with the specified name. Conceptually this will simply create a cable *************** *** 75,78 **** --- 93,97 ---- NetworkInterfaces = new Vector(); name = inName; + sievingCoefficient = 100; } |
From: Alexander B. <da...@us...> - 2005-11-19 16:55:49
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4295/guiUI Modified Files: LinkProperties.java Log Message: Index: LinkProperties.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/LinkProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinkProperties.java 19 Nov 2005 16:16:32 -0000 1.1 --- LinkProperties.java 19 Nov 2005 16:55:37 -0000 1.2 *************** *** 226,230 **** }); ! txtProp.setEnabled(false); final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL; --- 226,230 ---- }); ! txtProp.setEnabled(true); final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL; *************** *** 278,283 **** //String str = Sim.disconnectLink(NodeName, Interface); //SBox.removeLine(str); ! //controller.addToConsole(NodeName +"'s link on interface "+Interface+" has been disconnected!\n"); ! } --- 278,292 ---- //String str = Sim.disconnectLink(NodeName, Interface); //SBox.removeLine(str); ! ! ///!!!!!!!!!!!!!!! ! // !!!!!!!!!!!!!!!!!! ! // *TODO*: security from FOOLS ! String SC = txtProp.getText(); ! double scoeff = Double.valueOf(SC.trim()).doubleValue(); ! String lnk = Sim.getLinkName(NodeName, Interface); ! if(lnk!=null){ ! Sim.SetLinkProb(lnk, scoeff); ! controller.addToConsole("Setting sieving coefficient for " + NodeName +"'s link on interface "+Interface+" by " + SC + ".\n"); ! } } *************** *** 327,334 **** cmbInterface.setEnabled(true); ! } catch (Exception e) { //This should never happen e.printStackTrace(); } } --- 336,345 ---- cmbInterface.setEnabled(true); ! selectInterface(); ! } catch (Exception e) { //This should never happen e.printStackTrace(); } + } *************** *** 344,349 **** try{ String lnk = Sim.getLinkName(NodeName, Interface); ! //txtProp.setText(Sim.getLinkProb(lnk)); ! }catch(Exception e){ } } --- 355,360 ---- try{ String lnk = Sim.getLinkName(NodeName, Interface); ! if(lnk!=null) txtProp.setText(Double.valueOf(Sim.GetLinkProb(lnk)).toString()); ! }catch(Exception e){ System.out.println(e.toString()); } } |