javanetsim-cvs Mailing List for javaNetSim (Page 35)
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-19 16:55:48
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4295 Modified Files: TODO.txt Log Message: Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TODO.txt 10 Nov 2005 18:57:55 -0000 1.2 --- TODO.txt 19 Nov 2005 16:55:37 -0000 1.3 *************** *** 17,20 **** --- 17,24 ---- that "route" command is only for ugly testing purposes! 3. Routing tables save/load. + 4. Dirty Lines SAVE/LOAD!!!!! + 5. App setting SAVE/LOAD!!!! + 6. App level in S/L. + 7. Fix LinkProperties Dialog: safe using (check for correct input values). *** Simulation Related |
From: Alexander B. <da...@us...> - 2005-11-19 16:16:40
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28569/guiUI Modified Files: ApplicationLayerDevice.java MainScreen.java NetworkLayerDevice.java breakLinkDialog.java Added Files: LinkProperties.java Log Message: Index: NetworkLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/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 16:16:32 -0000 1.3 *************** *** 34,37 **** --- 34,38 ---- import javax.swing.JMenuItem; + import javax.swing.JMenu; /** *************** *** 49,56 **** --- 50,60 ---- private JMenuItem mnuSendPing = new JMenuItem("Send Ping ..."); private JMenuItem mnuProperties = new JMenuItem("Properties ..."); + private JMenu mnuARPMenu = new JMenu("ARP"); + private JMenuItem mnuArpStaticAdd = new JMenuItem("Add static entry to ARP table..."); private JMenuItem mnuArpRemove = new JMenuItem("Remove entry from ARP table..."); private JMenuItem mnuRunCmd = new JMenuItem("Run low-level command..."); private JMenuItem mnuArp = new JMenuItem("Print ARP Table"); + private JMenuItem mnuLink = new JMenuItem("Links properties"); private JMenuItem mnuBreakLink = new JMenuItem("Break link"); *************** *** 108,120 **** } }); GuiNodePopMenu.add(mnuSetTCPIPProperties); GuiNodePopMenu.add(mnuSendPing); ! GuiNodePopMenu.add(mnuArpStaticAdd); ! GuiNodePopMenu.add(mnuArpRemove); ! GuiNodePopMenu.add(mnuArp); GuiNodePopMenu.add(mnuRunCmd); GuiNodePopMenu.add(mnuBreakLink); GuiNodePopMenu.add(mnuProperties); --- 112,131 ---- } }); + mnuLink.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.showLinkDialog(lblNodeName.getText()); + } + }); GuiNodePopMenu.add(mnuSetTCPIPProperties); GuiNodePopMenu.add(mnuSendPing); ! GuiNodePopMenu.add(mnuARPMenu); ! mnuARPMenu.add(mnuArpStaticAdd); ! mnuARPMenu.add(mnuArpRemove); ! mnuARPMenu.add(mnuArp); GuiNodePopMenu.add(mnuRunCmd); GuiNodePopMenu.add(mnuBreakLink); + GuiNodePopMenu.add(mnuLink); GuiNodePopMenu.add(mnuProperties); Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MainScreen.java 19 Nov 2005 14:26:02 -0000 1.3 --- MainScreen.java 19 Nov 2005 16:16:32 -0000 1.4 *************** *** 46,49 **** --- 46,50 ---- import java.util.Arrays; + import javax.swing.*; import javax.swing.filechooser.FileFilter; *************** *** 55,61 **** --- 56,64 ---- import core.Simulation; import core.Node; + import core.protocolsuite.tcp_ip.Route_entry; import core.protocolsuite.tcp_ip.Echo; + /** * This class is the GUI's main screen. *************** *** 569,573 **** --- 572,615 ---- } + + /** + * Creates a Link Properties Dialog on the specific Node + * @param String inNodeName The name node to show properties on + */ + + public void showLinkDialog(String inNodeName) + { + Object[] nodesArray = null; + int selectedIndex = -1; + //if null is passed from the menubar item + //Get array of nodes from within the simulation + if(inNodeName == null){ + ArrayList Values = new ArrayList(); + Enumeration enum1 = GUInodeTable.keys(); + while(enum1.hasMoreElements()){ + String key = (String)enum1.nextElement(); + GuiNode tempNode = (GuiNode)GUInodeTable.get(key); + if(tempNode instanceof NetworkLayerDevice){ + Values.add(key); + } + } + nodesArray = Values.toArray(); + + //Else pass the selected node name + }else{ + nodesArray = new Object[1]; + nodesArray[0] = inNodeName; + selectedIndex = 0; + } + + //test that there are any node within the simulation + if(nodesArray.length != 0){ + new LinkProperties(this,nodesArray,selectedIndex,Sim,Sandbox); + this.refreshNodeInformationTab(); + }else + JOptionPane.showMessageDialog(this,"There are currently no node's within the simulation","Warning!",JOptionPane.WARNING_MESSAGE); + } + /** *************** *** 1737,1740 **** --- 1779,1802 ---- /** + * Send echo message to server + * @author Key + * @param String inNodeName Name of node to server listen + */ + + 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{ + ((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()); + } + } + } + + /** * Runs network configure command on the target host. (route, et cetera) * Need for: *************** *** 1751,1767 **** if(tokens[0].contains("route")){ ! //only tests ! this.addToConsole("You enter route command.\n"); ! ! try{ if(tokens[1].contains("print")){ ! }else if(tokens[1].contains("add")){ ! }else if(tokens[1].contains("del")){ ! }else{ this.addToConsole("Unknown route command. Usage:\n"); ! this.addToConsole("route add (host_ip|network_ip) target_interface [netmask] [gateway] \n"); this.addToConsole("route del (host_ip|network_ip) \n"); this.addToConsole("route print \n"); --- 1813,1836 ---- if(tokens[0].contains("route")){ ! try{ if(tokens[1].contains("print")){ ! String routes[] = Sim.getRouteTableEntries(inNodeName); ! this.addToConsole("IP routing table:\n" + "Destination" + "\t" + "Gateway" + "\t" + "Genmask" + "\t" + "Type" + "\t" + "Iface"); ! for(int i=0; i<routes.length - 1; i++){ ! Route_entry r = Sim.getRouteEntry(inNodeName, routes[i]); ! this.addToConsole(routes[i] + "\t" + r.gateway + "\t" + r.genMask + "\t" + r.Type + "\t" + r.iFace + "\n"); ! } }else if(tokens[1].contains("add")){ ! String gw = ""; ! if(tokens.length > 5) gw = tokens[5]; ! Route_entry r = new Route_entry(tokens[2], gw, tokens[4], tokens[3], 0); ! Sim.addRoute(inNodeName, r); ! this.addToConsole("Route added.\n"); }else if(tokens[1].contains("del")){ ! Sim.removeRoute(inNodeName, tokens[2]); ! this.addToConsole("Route to " + tokens[2] + "removed.\n"); }else{ this.addToConsole("Unknown route command. Usage:\n"); ! this.addToConsole("route add (host_ip|network_ip) target_interface netmask [gateway] \n"); this.addToConsole("route del (host_ip|network_ip) \n"); this.addToConsole("route print \n"); *************** *** 1769,1773 **** }catch(ArrayIndexOutOfBoundsException e){ this.addToConsole("Unknown route command. Usage:\n"); ! this.addToConsole("route add (host_ip|network_ip) target_interface [netmask] [gateway] \n"); this.addToConsole("route del (host_ip|network_ip) \n"); this.addToConsole("route print \n"); --- 1838,1842 ---- }catch(ArrayIndexOutOfBoundsException e){ this.addToConsole("Unknown route command. Usage:\n"); ! this.addToConsole("route add (host_ip|network_ip) target_interface netmask [gateway] \n"); this.addToConsole("route del (host_ip|network_ip) \n"); this.addToConsole("route print \n"); *************** *** 1775,1779 **** }else{ ! this.addToConsole("Unknown command.\n"); } } --- 1844,1848 ---- }else{ ! this.addToConsole("Unknown or invalid command.\n"); } } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ApplicationLayerDevice.java 19 Nov 2005 14:26:02 -0000 1.2 --- ApplicationLayerDevice.java 19 Nov 2005 16:16:32 -0000 1.3 *************** *** 37,41 **** mnuEchoSend.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! //controller.EchoSend(lblNodeName.getText()); } }); --- 37,41 ---- mnuEchoSend.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! controller.EchoSend(lblNodeName.getText()); } }); Index: breakLinkDialog.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/breakLinkDialog.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** breakLinkDialog.java 8 Nov 2005 04:04:23 -0000 1.1.1.1 --- breakLinkDialog.java 19 Nov 2005 16:16:32 -0000 1.2 *************** *** 87,91 **** this.Sim = Sim; this.SBox = SBox; ! //setTitle("Internet Protocol (TCP/IP) Properties"); initGUI(nodeArray,selectedIndex); --- 87,91 ---- this.Sim = Sim; this.SBox = SBox; ! setTitle("Break link"); initGUI(nodeArray,selectedIndex); --- NEW FILE: LinkProperties.java --- /* 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 guiUI; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.GridBagLayout; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.Insets; import java.awt.GridBagConstraints; import java.awt.BorderLayout; import javax.swing.JButton; import java.awt.Dimension; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JComboBox; import core.Simulation; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.Color; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.util.Arrays; import java.awt.Component; import javax.swing.SwingConstants; /** * * @author Key * * This class is a dialog that enables to set link properties * */ public class LinkProperties extends javax.swing.JDialog { private JPanel backpanel; private JLabel lblInterface; private JLabel lblNodeName; private JComboBox cmbNodeName; private JComboBox cmbInterface; private JLabel lblError; private JLabel lblProp; private JButton btnOk; private JTextField txtProp; private MainScreen controller; private Simulation Sim; private SandBox SBox; private String NodeName; private String Interface; private boolean ErrorFlag = true; public LinkProperties(JFrame frame, Object nodeArray[], int selectedIndex, Simulation Sim, SandBox SBox) { super(frame); setResizable(false); controller = (MainScreen)frame; this.Sim = Sim; this.SBox = SBox; setTitle("Link Properties (Ahtung: NOT WORKING!!!!!)"); initGUI(nodeArray,selectedIndex); final JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); btnOk = new JButton(); btnOk.setEnabled(true); btnOk.setToolTipText("Set options!"); btnOk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton(); } }); btnOk.setName("btnOK"); panel.add(btnOk); btnOk.setText("OK"); final JButton btnCancel = new JButton(); btnCancel.setToolTipText("Cancel changes"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton(); } }); btnCancel.setName("btnCancel"); panel.add(btnCancel); btnCancel.setText("Cancel"); this.getRootPane().setDefaultButton(btnOk); this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setModal(true); this.setVisible(true); } private void initGUI(Object nodeArray[], int selectedIndex) { try { setSize(350, 225); { backpanel = new JPanel(); backpanel.setMinimumSize(new Dimension(200, 10)); this.getContentPane().add(backpanel, BorderLayout.CENTER); GridBagLayout backpanelLayout = new GridBagLayout(); backpanel.setPreferredSize(new java.awt.Dimension(264, 213)); backpanelLayout.columnWeights = new double[] {}; backpanelLayout.columnWidths = new int[] {}; backpanelLayout.rowWeights = new double[] {0.0}; backpanelLayout.rowHeights = new int[] {5,5,5,5}; backpanel.setLayout(backpanelLayout); { lblNodeName = new JLabel(); backpanel.add(lblNodeName, new GridBagConstraints( 0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 21, 0)); lblNodeName.setText("Node Name:"); } { lblInterface = new JLabel(); backpanel.add(lblInterface, new GridBagConstraints( 0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 27), 0, 0)); lblInterface.setText("Interface:"); } { lblProp = new JLabel(); backpanel.add(lblProp, new GridBagConstraints( 0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 16), 0, 0)); lblProp.setText("Packet passthrough(%) (0 - 100):"); } cmbNodeName = new JComboBox(nodeArray); cmbNodeName.setMinimumSize(new Dimension(100, 0)); cmbNodeName.setSelectedIndex(selectedIndex); cmbNodeName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectNode(); } }); final GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.LINE_START; gridBagConstraints.gridy = 0; gridBagConstraints.gridx = 1; backpanel.add(cmbNodeName, gridBagConstraints); cmbInterface = new JComboBox(); cmbInterface.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectInterface(); } }); cmbInterface.setEnabled(false); final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints(); gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_1.anchor = GridBagConstraints.LINE_START; gridBagConstraints_1.gridy = 1; gridBagConstraints_1.gridx = 1; backpanel.add(cmbInterface, gridBagConstraints_1); txtProp = new JTextField(); txtProp.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { //ipAddressEntered(); } }); txtProp.setEnabled(false); final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints(); gridBagConstraints_3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints_3.anchor = GridBagConstraints.LINE_START; gridBagConstraints_3.gridy = 2; gridBagConstraints_3.gridx = 1; backpanel.add(txtProp, gridBagConstraints_3); txtProp.setText("Enter %% 0-100"); lblError = new JLabel(); lblError.setHorizontalTextPosition(SwingConstants.CENTER); lblError.setHorizontalAlignment(SwingConstants.CENTER); lblError.setAlignmentX(Component.CENTER_ALIGNMENT); lblError.setMinimumSize(new Dimension(100, 20)); lblError.setMaximumSize(new Dimension(100, 20)); lblError.setPreferredSize(new Dimension(100, 20)); lblError.setVisible(false); final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints(); gridBagConstraints_5.anchor = GridBagConstraints.WEST; gridBagConstraints_5.insets = new Insets(0, 1, 0, 0); gridBagConstraints_5.fill = GridBagConstraints.BOTH; gridBagConstraints_5.gridwidth = 2; gridBagConstraints_5.gridy = 5; gridBagConstraints_5.gridx = 0; backpanel.add(lblError, gridBagConstraints_5); lblError.setText("Error Message!!!! Error"); if(selectedIndex == 0){ selectNode(); } } } catch (Exception e) { e.printStackTrace(); } } /** * This method is executed when the user hit's the enter button. * It will delete the link on selected interface. * * @author Key * */ private void okButton(){ try { if(NodeName != null && Interface != null){ //String str = Sim.disconnectLink(NodeName, Interface); //SBox.removeLine(str); //controller.addToConsole(NodeName +"'s link on interface "+Interface+" has been disconnected!\n"); } this.dispose(); } catch (Exception e) { e.printStackTrace(); } } /** * This method is executed when the user hits the cancel button * @author luke_hamilton * @author Key * */ private void cancelButton(){ this.dispose(); } /** * This method will generate the data within the Interface combobox based * on the node that is selected. It will also get the default gateway if there is one set * for the node and add the text to the text field * * @author luke_hamilton * @author Key * */ private void selectNode(){ //Remove all items before regenerating the combobox. //This is because if a users selects the node twice, it would add the interfaces twice. cmbInterface.removeAllItems(); NodeName = (String)cmbNodeName.getSelectedItem(); try { Object nics[] = Sim.getAllInterfaces(NodeName); //Get object array of interface names //Sort the array Arrays.sort(nics); for (int i = 0; i < nics.length; i++) { //Add them to the combobox cmbInterface.addItem(nics[i]); } cmbInterface.setEnabled(true); } catch (Exception e) { //This should never happen e.printStackTrace(); } } /** * This method enabled's the IP Address text field once the interface has been selected. * This will also check the selected interface to see if the ip address has already been set * if so entering that ip address into the text field and then getting the set subnet mask for that * ip address. * @author Key */ private void selectInterface(){ Interface = (String)cmbInterface.getSelectedItem(); try{ String lnk = Sim.getLinkName(NodeName, Interface); //txtProp.setText(Sim.getLinkProb(lnk)); }catch(Exception e){ } } } |
From: Alexander B. <da...@us...> - 2005-11-19 16:16:39
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28569/core/protocolsuite/tcp_ip Modified Files: Application.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Application.java 19 Nov 2005 14:26:02 -0000 1.5 --- Application.java 19 Nov 2005 16:16:32 -0000 1.6 *************** *** 18,22 **** protected int listenPort; protected int clientPort; ! private ProtocolStack mParentStack; protected String sdHost; --- 18,22 ---- protected int listenPort; protected int clientPort; ! protected ProtocolStack mParentStack; protected String sdHost; |
From: Alexander B. <da...@us...> - 2005-11-19 14:26:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7620/core Modified Files: PC.java ProtocolStack.java Simulation.java Log Message: Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/ProtocolStack.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProtocolStack.java 8 Nov 2005 15:35:29 -0000 1.1 --- ProtocolStack.java 19 Nov 2005 14:26:02 -0000 1.2 *************** *** 65,68 **** --- 65,70 ---- 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 Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PC.java 19 Nov 2005 13:13:58 -0000 1.3 --- PC.java 19 Nov 2005 14:26:02 -0000 1.4 *************** *** 40,43 **** --- 40,44 ---- class PC extends ApplicationLayerDevice { + /** * Constructs a PC with the specified name. *************** *** 49,54 **** super(inName,7); ! Echo echoServer = new Echo(NodeProtocolStack, 7, 1); ! Echo echoClient = new Echo(NodeProtocolStack, 0, 0); addApp(echoServer, 7); --- 50,55 ---- super(inName,7); ! Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); ! Echo echoClient = new Echo(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); addApp(echoServer, 7); Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Simulation.java 8 Nov 2005 20:58:14 -0000 1.2 --- Simulation.java 19 Nov 2005 14:26:02 -0000 1.3 *************** *** 226,229 **** --- 226,235 ---- } + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! comment && doc this + + public Node getNode(String inNodeName) throws InvalidNodeNameException{ + return (Node)nodeTable.get(inNodeName); + } + /** * This method is called from the TEXTUI or GUI. If inNodeName is an instance of Node pass it up the |
From: Alexander B. <da...@us...> - 2005-11-19 14:26:10
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7620/guiUI Modified Files: ApplicationLayerDevice.java MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MainScreen.java 8 Nov 2005 20:58:14 -0000 1.2 --- MainScreen.java 19 Nov 2005 14:26:02 -0000 1.3 *************** *** 56,60 **** import core.Node; ! /** --- 56,60 ---- import core.Node; ! import core.protocolsuite.tcp_ip.Echo; /** *************** *** 185,188 **** --- 185,189 ---- //JFrame.setDefaultLookAndFeelDecorated(true); //JDialog.setDefaultLookAndFeelDecorated(true); + core.ProtocolStack.UIDGen = 0; new SplashWindow("images/firewall.gif",2000); new MainScreen(); *************** *** 1715,1718 **** --- 1716,1739 ---- } + + /** + * Set Echo Server Status on node to listening + * @author Key + * @param String inNodeName Name of node to server listen + */ + + public void EchoServerListen(String inNodeName){ + String port = JOptionPane.showInputDialog(this, "Port:", "Set Echo Server listening on port.", JOptionPane.QUESTION_MESSAGE); + 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){ + addToConsole(e.toString()); + } + } + } + /** * Runs network configure command on the target host. (route, et cetera) Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ApplicationLayerDevice.java 19 Nov 2005 13:07:37 -0000 1.1 --- ApplicationLayerDevice.java 19 Nov 2005 14:26:02 -0000 1.2 *************** *** 30,34 **** mnuEchoListen.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! //controller.setTCPIPProperties(lblNodeName.getText()); --- 30,34 ---- mnuEchoListen.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! controller.EchoServerListen(lblNodeName.getText()); *************** *** 37,41 **** mnuEchoSend.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! //controller.SendPing(lblNodeName.getText()); } }); --- 37,41 ---- mnuEchoSend.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ! //controller.EchoSend(lblNodeName.getText()); } }); |
From: Alexander B. <da...@us...> - 2005-11-19 14:26:09
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7620/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Application.java 19 Nov 2005 13:07:37 -0000 1.4 --- Application.java 19 Nov 2005 14:26:02 -0000 1.5 *************** *** 24,36 **** protected int appType; ! private int id; ! static int count; ! /** Creates a new instance of ApplicationProtocol */ ! public Application(ProtocolStack inParentStack, int listenPort, int appType){ this.listenPort = listenPort; this.mParentStack = inParentStack; - count++; - this.id = count; } --- 24,32 ---- protected int appType; ! 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; } *************** *** 95,97 **** --- 91,97 ---- return this.listenPort; } + + public int getUID(){ + return this.UID; + } } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Echo.java 19 Nov 2005 13:07:37 -0000 1.4 --- Echo.java 19 Nov 2005 14:26:02 -0000 1.5 *************** *** 17,22 **** /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort, int appType) { ! super(inParentStack, listenPort, appType); } --- 17,22 ---- /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); } *************** *** 28,32 **** public void Listen() throws TransportLayerException{ //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! mParentStack.ListenUDP(this, listenPort); } --- 28,32 ---- public void Listen() throws TransportLayerException{ //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! //mParentStack.ListenUDP(this, listenPort); } *************** *** 39,43 **** */ public void Close(){ ! mParentStack.CloseUDP(this, listenPort); } --- 39,43 ---- */ public void Close(){ ! //mParentStack.CloseUDP(this); } *************** *** 53,57 **** sdHost = Host; sdPort = port; ! clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); } --- 53,57 ---- sdHost = Host; sdPort = port; ! //clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); } *************** *** 74,78 **** public void Disconnect(){ ! mParentStack.freeUDPPort(this); } --- 74,78 ---- public void Disconnect(){ ! //mParentStack.freeUDPPort(this); } *************** *** 85,92 **** public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this); //processing the protocol doings. } /** * This method recieves data from the other side. --- 85,94 ---- public void SendData(String Data) throws TransportLayerException { ! //mParentStack.sendUDP(this, Data); //processing the protocol doings. } + + /** * This method recieves data from the other side. |
From: Alouette <alo...@us...> - 2005-11-19 13:27:20
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27888/core/protocolsuite/tcp_ip/ospf Added Files: OSPFhello_packet.java ospf_packetheader.java Log Message: --- NEW FILE: OSPFhello_packet.java --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ospf_packetheader.java --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2005-11-19 13:14:05
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24885/core Modified Files: PC.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PC.java 19 Nov 2005 13:07:37 -0000 1.2 --- PC.java 19 Nov 2005 13:13:58 -0000 1.3 *************** *** 28,32 **** */ ! /** --- 28,32 ---- */ ! import core.protocolsuite.tcp_ip.Echo; /** *************** *** 47,51 **** */ protected PC(String inName) { ! super(inName,7); addNetworkInterface("eth0"); } --- 47,58 ---- */ protected PC(String inName) { ! super(inName,7); ! ! Echo echoServer = new Echo(NodeProtocolStack, 7, 1); ! Echo echoClient = new Echo(NodeProtocolStack, 0, 0); ! ! addApp(echoServer, 7); ! addApp(echoClient, 30007); ! addNetworkInterface("eth0"); } |
From: Alexander B. <da...@us...> - 2005-11-19 13:07:49
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23447/core Modified Files: PC.java Added Files: ApplicationLayerDevice.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PC.java 8 Nov 2005 15:35:29 -0000 1.1 --- PC.java 19 Nov 2005 13:07:37 -0000 1.2 *************** *** 38,42 **** */ ! class PC extends NetworkLayerDevice { /** --- 38,42 ---- */ ! class PC extends ApplicationLayerDevice { /** --- NEW FILE: ApplicationLayerDevice.java --- /* * ApplicationLayerDevice.java * * Created on 19 Nov 2005, 15:48 * */ package core; import java.util.Hashtable; /** * * @author key */ public class ApplicationLayerDevice extends NetworkLayerDevice{ protected Hashtable Apps = null; /** Creates a new instance of ApplicationLayerDevice */ public ApplicationLayerDevice(String inName, int inProtocolStackLayers) { super(inName, inProtocolStackLayers); Apps = new Hashtable(); } public void addApp(Object app, int code){ Apps.put(code, app); } public Object getApp(int code){ return Apps.get(code); } } |
From: Alexander B. <da...@us...> - 2005-11-19 13:07:49
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23447/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Application.java 19 Nov 2005 12:40:59 -0000 1.3 --- Application.java 19 Nov 2005 13:07:37 -0000 1.4 *************** *** 88,92 **** public void RecvData(String Data) throws TransportLayerException {} - public void setPort(int port){ this.listenPort = port; --- 88,91 ---- Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Echo.java 19 Nov 2005 12:40:59 -0000 1.3 --- Echo.java 19 Nov 2005 13:07:37 -0000 1.4 *************** *** 109,116 **** } ! public void SendEcho(String Data, String Host, int port) throws TransportLayerException{ ClientConnect(Host, port); ! SendData(Data); } } --- 109,123 ---- } ! /** ! * This method processes a echo sending by client ! * @param data to send ! * @param server host ! * @param server port ! * @author key ! * @version v0.01 ! */ public void SendEcho(String Data, String Host, int port) throws TransportLayerException{ ClientConnect(Host, port); ! SendData(Data); } } |
From: Alexander B. <da...@us...> - 2005-11-19 13:07:49
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23447/guiUI Modified Files: GuiPC.java Added Files: ApplicationLayerDevice.java Log Message: Index: GuiPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiPC.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GuiPC.java 8 Nov 2005 04:04:22 -0000 1.1.1.1 --- GuiPC.java 19 Nov 2005 13:07:37 -0000 1.2 *************** *** 36,40 **** */ ! public class GuiPC extends NetworkLayerDevice { /** --- 36,40 ---- */ ! public class GuiPC extends ApplicationLayerDevice { /** --- NEW FILE: ApplicationLayerDevice.java --- /* * ApplicationLayerDevice.java * * Created on 19 Nov 2005, 16:03 * */ package guiUI; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JMenuItem; /** * * @author key */ public class ApplicationLayerDevice extends NetworkLayerDevice { private JMenuItem mnuEchoListen = new JMenuItem("Start echo server to listen."); private JMenuItem mnuEchoSend = new JMenuItem("Send data via echo client."); /** Creates a new instance of ApplicationLayerDevice */ public ApplicationLayerDevice(String inName, MainScreen inMainScreen, String imageLocation) { super(inName, inMainScreen, imageLocation); mnuEchoListen.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ //controller.setTCPIPProperties(lblNodeName.getText()); } }); mnuEchoSend.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ //controller.SendPing(lblNodeName.getText()); } }); GuiNodePopMenu.add(mnuEchoListen); GuiNodePopMenu.add(mnuEchoSend); } } |
From: Alexander B. <da...@us...> - 2005-11-19 12:41:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16671/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Application.java 19 Nov 2005 11:46:08 -0000 1.2 --- Application.java 19 Nov 2005 12:40:59 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- protected String sdHost; protected int sdPort; + protected int appType; private int id; *************** *** 27,31 **** /** Creates a new instance of ApplicationProtocol */ ! public Application(ProtocolStack inParentStack, int listenPort){ this.listenPort = listenPort; this.mParentStack = inParentStack; --- 28,32 ---- /** Creates a new instance of ApplicationProtocol */ ! public Application(ProtocolStack inParentStack, int listenPort, int appType){ this.listenPort = listenPort; this.mParentStack = inParentStack; Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Echo.java 19 Nov 2005 11:46:08 -0000 1.2 --- Echo.java 19 Nov 2005 12:40:59 -0000 1.3 *************** *** 17,22 **** /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort) { ! super(inParentStack, listenPort); } --- 17,22 ---- /** Creates a new instance of Echo */ ! public Echo(ProtocolStack inParentStack, int listenPort, int appType) { ! super(inParentStack, listenPort, appType); } *************** *** 50,54 **** */ ! public void Connect(String Host, int port) throws TransportLayerException { sdHost = Host; sdPort = port; --- 50,54 ---- */ ! public void ClientConnect(String Host, int port) throws TransportLayerException { sdHost = Host; sdPort = port; *************** *** 56,59 **** --- 56,70 ---- } + + /** + * This method should be called from UDP when client connects to server + * @author key + * @version v0.01 + */ + public void Connected(String Host, int port){ + sdHost = Host; + sdPort = port; + } + /** * This method disconnects from server. *************** *** 74,78 **** public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this, clientPort); //processing the protocol doings. } --- 85,89 ---- public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this); //processing the protocol doings. } *************** *** 86,89 **** --- 97,116 ---- public void RecvData(String Data) throws TransportLayerException { //processing the protocol doings. + if(appType == 0){ + //client processing recieve + // printing some ... + Disconnect(); + }else{ + //server processing recieve + SendData(Data); + Close(); + Listen(); + } + } + + + public void SendEcho(String Data, String Host, int port) throws TransportLayerException{ + ClientConnect(Host, port); + SendData(Data); } } |
From: Alexander B. <da...@us...> - 2005-11-19 11:46:15
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3308/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Application.java 19 Nov 2005 11:18:57 -0000 1.1 --- Application.java 19 Nov 2005 11:46:08 -0000 1.2 *************** *** 17,21 **** --- 17,28 ---- protected String protocolName; protected int listenPort; + protected int clientPort; private ProtocolStack mParentStack; + + protected String sdHost; + protected int sdPort; + + private int id; + static int count; /** Creates a new instance of ApplicationProtocol */ *************** *** 23,26 **** --- 30,35 ---- this.listenPort = listenPort; this.mParentStack = inParentStack; + count++; + this.id = count; } *************** *** 31,35 **** */ public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); } --- 40,44 ---- */ public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Echo.java 19 Nov 2005 11:18:57 -0000 1.1 --- Echo.java 19 Nov 2005 11:46:08 -0000 1.2 *************** *** 28,32 **** public void Listen() throws TransportLayerException{ //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! //mParentStack. } --- 28,32 ---- public void Listen() throws TransportLayerException{ //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! mParentStack.ListenUDP(this, listenPort); } *************** *** 38,42 **** * @version v0.01 */ ! public void Close(){} /** --- 38,44 ---- * @version v0.01 */ ! public void Close(){ ! mParentStack.CloseUDP(this, listenPort); ! } /** *************** *** 48,52 **** */ ! public void Connect(String Host, int port) throws TransportLayerException {} /** --- 50,58 ---- */ ! public void Connect(String Host, int port) throws TransportLayerException { ! sdHost = Host; ! sdPort = port; ! clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); ! } /** *************** *** 56,60 **** */ ! public void Disconnect(){} /** --- 62,68 ---- */ ! public void Disconnect(){ ! mParentStack.freeUDPPort(this); ! } /** *************** *** 65,69 **** */ ! public void SendData(String Data) throws TransportLayerException {} /** --- 73,80 ---- */ ! public void SendData(String Data) throws TransportLayerException { ! mParentStack.sendUDP(Data, this, clientPort); ! //processing the protocol doings. ! } /** *************** *** 73,76 **** * @version v0.01 */ ! public void RecvData(String Data) throws TransportLayerException {} } --- 84,89 ---- * @version v0.01 */ ! public void RecvData(String Data) throws TransportLayerException { ! //processing the protocol doings. ! } } |
From: Alouette <alo...@us...> - 2005-11-19 11:19:23
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32066/ospf Log Message: Directory /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf added to the repository |
From: Alexander B. <da...@us...> - 2005-11-19 11:19:15
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32035 Added Files: Application.java Echo.java Log Message: --- NEW FILE: Application.java --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Echo.java --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2005-11-19 11:17:01
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31576/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.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ProtocolStack.java 18 Nov 2005 19:41:32 -0000 1.4 --- ProtocolStack.java 19 Nov 2005 11:16:51 -0000 1.5 *************** *** 1235,1239 **** FirstInterfaceName = temp.getFirstInterfaceName(); ! if (FirstInterfaceName!="unavailable") { if(IPV4Address.validateDecIP(inDestIPAddress)) --- 1235,1239 ---- FirstInterfaceName = temp.getFirstInterfaceName(); ! if (FirstInterfaceName!=null) { if(IPV4Address.validateDecIP(inDestIPAddress)) Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Udp.java 18 Nov 2005 20:47:56 -0000 1.4 --- Udp.java 19 Nov 2005 11:16:51 -0000 1.5 *************** *** 143,147 **** * @author gift (sourceforge.net user) * @param Protocol Stack - * @return Nothing. * @version v0.20 */ --- 143,146 ---- *************** *** 299,301 **** ! } //EOF \ No newline at end of file --- 298,300 ---- ! } //EOF |
From: Alexander B. <da...@us...> - 2005-11-19 11:17:01
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31576/core Modified Files: Node.java Log Message: Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Node.java 18 Nov 2005 19:41:32 -0000 1.2 --- Node.java 19 Nov 2005 11:16:51 -0000 1.3 *************** *** 546,550 **** * Returns 1st interface name in the network interfaces hashtable * @author gift (sourceforge.net user) - * @param Unused. * @return * @version v0.20 --- 546,549 ---- *************** *** 561,565 **** return strInterfaceName; } ! else return "unavailable"; } --- 560,564 ---- return strInterfaceName; } ! else return null; } |
From: gift <gi...@us...> - 2005-11-18 20:48:05
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20406/core/protocolsuite/tcp_ip Modified Files: Udp.java Log Message: comments changed Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Udp.java 18 Nov 2005 19:41:32 -0000 1.3 --- Udp.java 18 Nov 2005 20:47:56 -0000 1.4 *************** *** 159,163 **** for(i=0;i<PORT_QUANT;i++) { ! PortTable.put((PORT_START_NUMBER+i),Elm); } } --- 159,163 ---- for(i=0;i<PORT_QUANT;i++) { ! PortTable.put((PORT_START_NUMBER+i),Elm); // CHECK HERE } } *************** *** 226,230 **** 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 and our application ;) if ((Elm.connectedtoIP==inPacket.getSourceIPAddress()) && (Elm.connectedtoPort==inPacket.get_srcPort())) //temporary { --- 226,230 ---- 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 { |
From: gift <gi...@us...> - 2005-11-18 19:41:41
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4528/core Modified Files: Node.java TransportLayerException.java Log Message: UDP vNEXT :))) Index: Node.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Node.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Node.java 8 Nov 2005 15:35:29 -0000 1.1 --- Node.java 18 Nov 2005 19:41:32 -0000 1.2 *************** *** 1,273 **** ! /* ! 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; ! import java.util.*; ! ! import core.protocolsuite.tcp_ip.ProtocolStack; ! ! /** ! * A Node represents a device or a machine on a network. For example a PC, Hub, Switch or Router. ! * ! * <P>Note: This class may well need to be majorly modified. In order to implement Layer-2 Nodes such as ! * hubs and switches. Or alternatively a separate class be created for hub and switch to inherit from. ! * Currently the PC and Router nodes both inherit directly from this class. There is no DatalinkNode or ! * NetworkNode like in our class diagrams. The ideal way would probably be to shift all layer-2 associated ! * methods and attributes to a DatalinkNode class and all methods and attributes above layer-2 to be moved ! * to a NetworkNode class. Or something similar.</P> ! * ! * @author tristan_veness (Original Author) ! * @author luke_hamilton ! * @author angela_brown ! * @author bevan_calliess ! * @author michael_reith ! * @author robert_hulford ! * @since 13 June 2004 ! * @version v0.20 ! */ ! ! public abstract class Node implements Serializable{ ! /** ! * @link aggregation <{core.NetworkInterface}> ! * @directed directed ! * @supplierCardinality 0..* ! */ ! protected java.util.Hashtable NetworkInterfacetable = null; //Hashtable of network interfaces ! protected ProtocolStack NodeProtocolStack; ! protected String name; ! ! /** ! * Constructs an object of type Node. This can only be called by the Node's ! * respective sub classes like PC and Router. This constructor is only to be called ! * by the Node's sub classes using <b>super</b>. ! * @author luke_hamilton ! * @author ! * @param inName The name to give the Node. ! * @version v0.20 ! */ ! protected Node(String inName, int inProtocolStackLayers) { ! NetworkInterfacetable = new Hashtable(); ! name=inName; ! ! if(inProtocolStackLayers != 1){ ! //This test the current simulation object for the type of protocol that is being used and then ! //Creates a protocolstack of that type. ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! } ! }else{ ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! } ! } ! ! /** ! * This method loops throught the NetworkInface hashtable and ! * then removes all connected links ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void removeAllLinks() { ! Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()){ ! String str = (String)keys.nextElement(); ! NetworkInterface temp = (NetworkInterface)NetworkInterfacetable.get(str); ! temp.removeConnectedLink(); ! } ! } ! /** ! * This method is called by a netinterface card connect to this node. ! * The packet will then in passed to the protocolstack ! * @author bevan_calliess ! * @author angela_brown ! * @param inPacket - A Packet ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! return; ! } ! ! /** ! * This method is called by a network interface card connect to this node. ! * It is an alternative signature to be used when the Interface ! * receiving the packet needs to be known. eg hubs and switches. ! * @author bevan_calliess ! * @author angela_brown ! * @param inPacket - A Packet ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket,String inInterfaceName) throws LowLinkException {} ! ! /** ! * Creates a new network interface and adds it to the Node's NetworkInterfacetable(hashtable) ! * @author bevan_calliess ! * @param interfaceName - The name to give the new NetworkInterface. eg: eth0 ! * @version v0.20 ! * */ ! protected void addNetworkInterface(String interfaceName) { ! NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); ! } ! ! /** ! * Deletes a network interface from the interface list. ! * @author bevan_calliess ! * @param inNetworkInterfaceName - The name of the NetworkInterface to remove from the Node. eg: eth0 ! * @version v0.20 ! */ ! protected void removeNetworkInterface(String interfaceName) { ! NetworkInterfacetable.remove(interfaceName); ! } ! ! /** ! * Gets the name of the Node. ! * @author luke_hamilton ! * @return The name of the Node. ! * @version v0.20 ! */ ! public String getName() { ! return name; ! } ! ! public int getState() { return 0; } ! public void Reset() {} ! ! /** ! * Displays all the interfaces in the network interfaces hashtable ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void displayInterfaces() { ! NetworkInterface NIC; ! String str; ! ! Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()){ ! str = (String) keys.nextElement(); ! NIC = (NetworkInterface)NetworkInterfacetable.get(str); ! System.out.print(NIC.getDetails()); ! if(this.getClass() != Hub.class){ ! String strIPAddress = NodeProtocolStack.getIPAddress(str); ! if(strIPAddress == null) ! { ! strIPAddress = "Not set"; ! } ! System.out.println("\tIP Address: "+ strIPAddress); ! }else ! System.out.println(); ! } ! } ! ! /** ! * This method returns the network interface object. ! * This is called when a link is created. It test to see if the passed interfaceName ! * is valid, if not it will throw a exception ! * @author luke_hamilton ! * @param interfaceName ! * @throws InvalidNetworkInterfaceNameException ! * @return object refences ! * @version v0.20 ! */ ! protected NetworkInterface getNetworkInterface(String interfaceName) throws InvalidNetworkInterfaceNameException{ ! if(NetworkInterfacetable.containsKey(interfaceName)){ ! return (NetworkInterface)NetworkInterfacetable.get(interfaceName); ! } ! throw new InvalidNetworkInterfaceNameException("'"+interfaceName+ "' on node '"+ name +"' is an invalid Network Interface name"); ! } ! ! /** ! * This method returns the MAC address of the the interface ! * The method uses a TCP/IP method from the Ethernet interface ! * so if you are replacing the Protocol stack with another type ! * you will need to change this method. ! * @author luke_hamilton ! * @author bevan_calliess ! * @param inInterfaceName ! * @return String The MAC address of the Interface. ! * @throws InvalidNetworkInterfaceNameException ! * @version v0.20 ! */ ! public String getMACAddress(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ ! if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! return temp.getMACAddress(); ! } ! throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); ! } ! ! /** ! * This method will iterate through all of this nodes interfaces ! * and add the name of any that do not have a link connected ! * to a String Array. This list is used in the gui to display a ! * list of available interfaces for the user to select from when creating ! * a link. ! * @return String[] List of Interface names without a link. ! */ ! public String[] getAvailableInterfaces() ! { ! int counter = 0; ! Enumeration it = NetworkInterfacetable.elements(); ! Enumeration it2 = NetworkInterfacetable.elements(); ! while(it.hasMoreElements()) ! { ! NetworkInterface temp = (NetworkInterface)it.nextElement(); ! if(temp.getConnectedLink() == null){ ! counter++; ! } ! } ! String strAvailInterfaces[] = new String[counter]; ! int iterator = 0; ! while(it2.hasMoreElements()) ! { ! NetworkInterface temp = (NetworkInterface)it2.nextElement(); ! if(temp.getConnectedLink() == null){ ! strAvailInterfaces[iterator] = temp.getName(); ! iterator++; ! } ! } ! return strAvailInterfaces; ! } ! ! public ArrayList getAllInterfacesNames(){ ! ! ArrayList interfaceArray = new ArrayList(); ! Enumeration keys = NetworkInterfacetable.keys(); ! while(keys.hasMoreElements()){ ! String strInterfaceName = (String) keys.nextElement(); ! interfaceArray.add(strInterfaceName); ! } ! ! return interfaceArray; ! } ! }//EOF --- 1,567 ---- ! /* ! ! 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; ! ! import java.util.*; ! ! ! ! import core.protocolsuite.tcp_ip.ProtocolStack; ! ! ! ! /** ! ! * A Node represents a device or a machine on a network. For example a PC, Hub, Switch or Router. ! ! * ! ! * <P>Note: This class may well need to be majorly modified. In order to implement Layer-2 Nodes such as ! ! * hubs and switches. Or alternatively a separate class be created for hub and switch to inherit from. ! ! * Currently the PC and Router nodes both inherit directly from this class. There is no DatalinkNode or ! ! * NetworkNode like in our class diagrams. The ideal way would probably be to shift all layer-2 associated ! ! * methods and attributes to a DatalinkNode class and all methods and attributes above layer-2 to be moved ! ! * to a NetworkNode class. Or something similar.</P> ! ! * ! ! * @author tristan_veness (Original Author) ! ! * @author luke_hamilton ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @author michael_reith ! ! * @author robert_hulford ! ! * @since 13 June 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public abstract class Node implements Serializable{ ! ! /** ! ! * @link aggregation <{core.NetworkInterface}> ! ! * @directed directed ! ! * @supplierCardinality 0..* ! ! */ ! ! protected java.util.Hashtable NetworkInterfacetable = null; //Hashtable of network interfaces ! ! protected ProtocolStack NodeProtocolStack; ! ! protected String name; ! ! ! ! /** ! ! * Constructs an object of type Node. This can only be called by the Node's ! ! * respective sub classes like PC and Router. This constructor is only to be called ! ! * by the Node's sub classes using <b>super</b>. ! ! * @author luke_hamilton ! ! * @author ! ! * @param inName The name to give the Node. ! ! * @version v0.20 ! ! */ ! ! protected Node(String inName, int inProtocolStackLayers) { ! ! NetworkInterfacetable = new Hashtable(); ! ! name=inName; ! ! ! ! if(inProtocolStackLayers != 1){ ! ! //This test the current simulation object for the type of protocol that is being used and then ! ! //Creates a protocolstack of that type. ! ! if(Simulation.getProtocolType() == ProtocolStack.TCP_IP){ ! ! NodeProtocolStack = new core.protocolsuite.tcp_ip.ProtocolStack(this,inProtocolStackLayers); ! ! }else if(Simulation.getProtocolType() == ProtocolStack.APPLETALK){ ! ! //NodeProtocolStack = new core.protocolsuite.appletalk.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IBM_SNA){ ! ! //NodeProtocolStack = new core.protocolsuite.ibm_sna.ProtocolStack(this); //Not implemented ! ! }else if(Simulation.getProtocolType() == ProtocolStack.IPX_SPX){ ! ! //NodeProtocolStack = new core.protocolsuite.ipx_spx.ProtocolStack(this); //Not implemented ! ! } ! ! }else{ ! ! NodeProtocolStack = null; //Set layer 1 devices protocolstack to null ! ! } ! ! } ! ! ! ! /** ! ! * This method loops throught the NetworkInface hashtable and ! ! * then removes all connected links ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void removeAllLinks() { ! ! Enumeration keys = NetworkInterfacetable.keys(); ! ! while(keys.hasMoreElements()){ ! ! String str = (String)keys.nextElement(); ! ! NetworkInterface temp = (NetworkInterface)NetworkInterfacetable.get(str); ! ! temp.removeConnectedLink(); ! ! } ! ! } ! ! /** ! ! * This method is called by a netinterface card connect to this node. ! ! * The packet will then in passed to the protocolstack ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! ! return; ! ! } ! ! ! ! /** ! ! * This method is called by a network interface card connect to this node. ! ! * It is an alternative signature to be used when the Interface ! ! * receiving the packet needs to be known. eg hubs and switches. ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inPacket - A Packet ! ! * @version v0.20 ! ! */ ! ! protected void receivePacket(Packet inPacket,String inInterfaceName) throws LowLinkException {} ! ! ! ! /** ! ! * Creates a new network interface and adds it to the Node's NetworkInterfacetable(hashtable) ! ! * @author bevan_calliess ! ! * @param interfaceName - The name to give the new NetworkInterface. eg: eth0 ! ! * @version v0.20 ! ! * */ ! ! protected void addNetworkInterface(String interfaceName) { ! ! NetworkInterfacetable.put(interfaceName,new EthernetNetworkInterface(interfaceName,this)); ! ! } ! ! ! ! /** ! ! * Deletes a network interface from the interface list. ! ! * @author bevan_calliess ! ! * @param inNetworkInterfaceName - The name of the NetworkInterface to remove from the Node. eg: eth0 ! ! * @version v0.20 ! ! */ ! ! protected void removeNetworkInterface(String interfaceName) { ! ! NetworkInterfacetable.remove(interfaceName); ! ! } ! ! ! ! /** ! ! * Gets the name of the Node. ! ! * @author luke_hamilton ! ! * @return The name of the Node. ! ! * @version v0.20 ! ! */ ! ! public String getName() { ! ! return name; ! ! } ! ! ! ! public int getState() { return 0; } ! ! public void Reset() {} ! ! ! ! /** ! ! * Displays all the interfaces in the network interfaces hashtable ! ! * @author luke_hamilton ! ! * @version v0.20 ! ! */ ! ! protected void displayInterfaces() { ! ! NetworkInterface NIC; ! ! String str; ! ! ! ! Enumeration keys = NetworkInterfacetable.keys(); ! ! while(keys.hasMoreElements()){ ! ! str = (String) keys.nextElement(); ! ! NIC = (NetworkInterface)NetworkInterfacetable.get(str); ! ! System.out.print(NIC.getDetails()); ! ! if(this.getClass() != Hub.class){ ! ! String strIPAddress = NodeProtocolStack.getIPAddress(str); ! ! if(strIPAddress == null) ! ! { ! ! strIPAddress = "Not set"; ! ! } ! ! System.out.println("\tIP Address: "+ strIPAddress); ! ! }else ! ! System.out.println(); ! ! } ! ! } ! ! ! ! /** ! ! * This method returns the network interface object. ! ! * This is called when a link is created. It test to see if the passed interfaceName ! ! * is valid, if not it will throw a exception ! ! * @author luke_hamilton ! ! * @param interfaceName ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @return object refences ! ! * @version v0.20 ! ! */ ! ! protected NetworkInterface getNetworkInterface(String interfaceName) throws InvalidNetworkInterfaceNameException{ ! ! if(NetworkInterfacetable.containsKey(interfaceName)){ ! ! return (NetworkInterface)NetworkInterfacetable.get(interfaceName); ! ! } ! ! throw new InvalidNetworkInterfaceNameException("'"+interfaceName+ "' on node '"+ name +"' is an invalid Network Interface name"); ! ! } ! ! ! ! /** ! ! * This method returns the MAC address of the the interface ! ! * The method uses a TCP/IP method from the Ethernet interface ! ! * so if you are replacing the Protocol stack with another type ! ! * you will need to change this method. ! ! * @author luke_hamilton ! ! * @author bevan_calliess ! ! * @param inInterfaceName ! ! * @return String The MAC address of the Interface. ! ! * @throws InvalidNetworkInterfaceNameException ! ! * @version v0.20 ! ! */ ! ! public String getMACAddress(String inInterfaceName)throws InvalidNetworkInterfaceNameException{ ! ! if(NetworkInterfacetable.containsKey(inInterfaceName)){ ! ! EthernetNetworkInterface temp =(EthernetNetworkInterface)NetworkInterfacetable.get(inInterfaceName); ! ! return temp.getMACAddress(); ! ! } ! ! throw new InvalidNetworkInterfaceNameException("'"+ inInterfaceName + "' on node '"+ name +"' is an invalid Network Interface name"); ! ! } ! ! ! ! /** ! ! * This method will iterate through all of this nodes interfaces ! ! * and add the name of any that do not have a link connected ! ! * to a String Array. This list is used in the gui to display a ! ! * list of available interfaces for the user to select from when creating ! ! * a link. ! ! * @return String[] List of Interface names without a link. ! ! */ ! ! public String[] getAvailableInterfaces() ! ! { ! ! int counter = 0; ! ! Enumeration it = NetworkInterfacetable.elements(); ! ! Enumeration it2 = NetworkInterfacetable.elements(); ! ! while(it.hasMoreElements()) ! ! { ! ! NetworkInterface temp = (NetworkInterface)it.nextElement(); ! ! if(temp.getConnectedLink() == null){ ! ! counter++; ! ! } ! ! } ! ! String strAvailInterfaces[] = new String[counter]; ! ! int iterator = 0; ! ! while(it2.hasMoreElements()) ! ! { ! ! NetworkInterface temp = (NetworkInterface)it2.nextElement(); ! ! if(temp.getConnectedLink() == null){ ! ! strAvailInterfaces[iterator] = temp.getName(); ! ! iterator++; ! ! } ! ! } ! ! return strAvailInterfaces; ! ! } ! ! ! ! public ArrayList getAllInterfacesNames(){ ! ! ! ! ArrayList interfaceArray = new ArrayList(); ! ! Enumeration keys = NetworkInterfacetable.keys(); ! ! while(keys.hasMoreElements()){ ! ! String strInterfaceName = (String) keys.nextElement(); ! ! interfaceArray.add(strInterfaceName); ! ! } ! ! ! ! return interfaceArray; ! ! } ! ! /** ! * Returns 1st interface name in the network interfaces hashtable ! * @author gift (sourceforge.net user) ! * @param Unused. ! * @return ! * @version v0.20 ! */ ! ! public String getFirstInterfaceName() ! { ! Enumeration keys = NetworkInterfacetable.keys(); ! ! if(keys.hasMoreElements()) ! { ! String strInterfaceName = (String) keys.nextElement(); ! ! return strInterfaceName; ! } ! else return "unavailable"; ! } ! ! }//EOF ! Index: TransportLayerException.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/TransportLayerException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TransportLayerException.java 17 Nov 2005 20:13:56 -0000 1.2 --- TransportLayerException.java 18 Nov 2005 19:41:32 -0000 1.3 *************** *** 65,73 **** /** - * * @author gift (sourceforge.net user) ! * @param inExceptionMsg The Exception Message * @version v0.10 ! */ public class TransportLayerException extends SimulationException { --- 65,72 ---- /** * @author gift (sourceforge.net user) ! * @param inExceptionMsg the Exception Message * @version v0.10 ! */ public class TransportLayerException extends SimulationException { |
From: gift <gi...@us...> - 2005-11-18 19:41:41
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4528/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java UDP_packet.java Udp.java Log Message: UDP vNEXT :))) Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProtocolStack.java 17 Nov 2005 20:13:56 -0000 1.3 --- ProtocolStack.java 18 Nov 2005 19:41:32 -0000 1.4 *************** *** 1190,1193 **** --- 1190,1250 ---- } + + /** + + * Sends a UDP packet to the IPAddress provided + + * @author robert_hulford + + * @author bevan_calliess + + * @author angela_brown + + * @param inDestIPAddress - Destination IP address eg: 192.168.0.2 + + * @throws CommunicationException + + * @version v0.20 + + */ + + /** + * 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!="unavailable") + { + 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 Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Udp.java 17 Nov 2005 20:13:56 -0000 1.2 --- Udp.java 18 Nov 2005 19:41:32 -0000 1.3 *************** *** 59,62 **** --- 59,64 ---- import java.io.Serializable; + import java.util.*; + import core.CommunicationException; *************** *** 71,76 **** import core.protocolsuite.tcp_ip.ProtocolStack; ! ! /** --- 73,77 ---- import core.protocolsuite.tcp_ip.ProtocolStack; ! ///import core.protocolsuite.tcp_ip.UDP_HashTableElement; /** *************** *** 112,120 **** ! class Udp implements Serializable ! { private ProtocolStack mParentStack; ! /** --- 113,141 ---- ! public class Udp implements Serializable ! { ! ! /* ! * UDP_HashTableElement.java ! * ! * Created on 18 November 2005, 21:09 ! */ + /** + * @author gift (sourceforge.net user) + * @version v0.10, 18 Nov 2005 + */ + 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 + } + + private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private static final int PORT_QUANT=100; ! private static final int PORT_START_NUMBER=3000; /** *************** *** 127,131 **** public Udp(ProtocolStack inParentStack) { ! mParentStack = inParentStack; } --- 148,164 ---- public Udp(ProtocolStack inParentStack) { ! int i; ! UDP_HashTableElement Elm = new UDP_HashTableElement(); ! ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! mParentStack = inParentStack; ! ! for(i=0;i<PORT_QUANT;i++) ! { ! PortTable.put((PORT_START_NUMBER+i),Elm); ! } } *************** *** 135,139 **** * and prints out a message to the layer info. * @author gift (sourceforge.net user) ! * @param Protocol Stack * @return Nothing. * @exception TransportLayerException If UDP CHECK_SUM != 1 --- 168,172 ---- * and prints out a message to the layer info. * @author gift (sourceforge.net user) ! * @param inPacket a packet to receive (decompilate) * @return Nothing. * @exception TransportLayerException If UDP CHECK_SUM != 1 *************** *** 149,172 **** if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ ! // test check sum of UDP packet ! ! if (inPacket.getCheck_Sum() == 1) { ! //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("UDP packet received from "+ inPacket.getSourceIPAddress() + " message length " +inPacket.getUDP_MessageLength() + " bytes."); ! Simulation.addLayerInfo(UDP_Info); } else { ! throw new TransportLayerException("UDP Error: Incorrect checksum on receiving."); ! } } } --- 182,264 ---- if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ ! // test if destination UDP port exists on this NeworkLayerDevice ! if (PortTable.get(inPacket.get_destPort()) !=null) { ! ! //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()); ! ! switch(Elm.PortStatus) ! { ! 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 ! ! // everything is OK, one more test: check sum of UDP packet ! if (inPacket.getCheck_Sum() == 1) ! { ! //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("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\". \r\n" + "UDP Port " + inPacket.get_destPort() + " has status \"busy\" from now. Host \"" + mParentStack.getParentNodeName()+"\"."); ! 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 and our application ;) ! if ((Elm.connectedtoIP==inPacket.getSourceIPAddress()) && (Elm.connectedtoPort==inPacket.get_srcPort())) //temporary ! { ! //now we decompose UDP datagram ! ! // everything is OK, one more test: check sum of UDP packet ! if (inPacket.getCheck_Sum() == 1) ! { ! //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("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\". \r\n" + "Host \"" + mParentStack.getParentNodeName()+"\"."); ! ! 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; ! ! default: //UDP Error: unknown port status :( ! throw new TransportLayerException("UDP Error: unknown port status! Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); ! } } else { ! throw new TransportLayerException("UDP Error: Port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); ! } } } *************** *** 176,188 **** * and prints out a message to the layer info. * @author gift (sourceforge.net user) ! * @param inDestIPAddress ! * @param InterfaceName name of the intarface that sends UDP e.g. "eth0" * @return UDP_packet * @version v0.20 */ ! public UDP_packet sendUDPPacket(String inDestIPAddress, String InterfaceName) ! { ! UDP_packet tosend = new UDP_packet(inDestIPAddress, mParentStack.getIPAddress(InterfaceName)); //Create Layer info --- 268,283 ---- * and prints out a message to the layer info. * @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 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 *************** *** 196,200 **** UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet to " + inDestIPAddress); Simulation.addLayerInfo(UDP_Info); --- 291,295 ---- UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet to " + inDestIPAddress + ":" + insrcPort +"."); Simulation.addLayerInfo(UDP_Info); Index: UDP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/UDP_packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UDP_packet.java 17 Nov 2005 20:13:56 -0000 1.3 --- UDP_packet.java 18 Nov 2005 19:41:32 -0000 1.4 *************** *** 85,89 **** private int UDP_MessageLength; ! private String UDP_message; private static final int PTCL = 17; //see RFC :) --- 85,93 ---- private int UDP_MessageLength; ! private String UDP_message; ! ! private int UDP_srcPort; ! ! private int UDP_destPort; private static final int PTCL = 17; //see RFC :) *************** *** 100,112 **** * This method passes the destination and source addresses into the super class * @author gift (sourceforge.net user) ! * @param destination IP address, source IP address * @return Nothing. * @version v0.20 */ ! public UDP_packet(String inDestIPAddress, String inSourceIPAddress) { super (inDestIPAddress); this.setSourceIPAddress(inSourceIPAddress); UDP_MessageLength = HEAD_LENGTH; UDP_message = ""; --- 104,121 ---- * This method passes the destination and source addresses into the super class * @author gift (sourceforge.net user) ! * @param inDestIPAddress destination IP address ! * @param inSourceIPAddress source IP address ! * @param indestPort destination port number ! * @param insrcPort sorce port number * @return Nothing. * @version v0.20 */ ! public UDP_packet(String inDestIPAddress, String inSourceIPAddress, int indestPort, int insrcPort) { super (inDestIPAddress); this.setSourceIPAddress(inSourceIPAddress); + UDP_destPort = indestPort; + UDP_srcPort = insrcPort; UDP_MessageLength = HEAD_LENGTH; UDP_message = ""; *************** *** 170,178 **** * This if for design and future implementation of UDP_packet * @author gift (sourceforge.net user) ! * @param Nothing. * @return Nothing. * @version v0.20 */ ! public void calculateCheck_Sum() { --- 179,187 ---- * This if for design and future implementation of UDP_packet * @author gift (sourceforge.net user) ! * @param Unused. * @return Nothing. * @version v0.20 */ ! public void calculate_Check_Sum() { *************** *** 204,207 **** --- 213,240 ---- } + /** + * This method gets source port + * @author gift (sourceforge.net user) + * @param Unused. + * @return source UDP port number. + * @version v0.20 + */ + public int get_srcPort() + { + return UDP_srcPort; + } + + /** + * This method gets destination port + * @author gift (sourceforge.net user) + * @param Unused. + * @return destination UDP port number. + * @version v0.20 + */ + public int get_destPort() + { + return UDP_destPort; + } + }//EOF |
From: gift <gi...@us...> - 2005-11-17 20:14:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28923/core Modified Files: TransportLayerException.java Log Message: UDP.java implementation v0.01 ;) arrival Index: TransportLayerException.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/TransportLayerException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TransportLayerException.java 16 Nov 2005 20:25:40 -0000 1.1 --- TransportLayerException.java 17 Nov 2005 20:13:56 -0000 1.2 *************** *** 66,70 **** /** * ! * @author gift * @param inExceptionMsg The Exception Message * @version v0.10 --- 66,70 ---- /** * ! * @author gift (sourceforge.net user) * @param inExceptionMsg The Exception Message * @version v0.10 *************** *** 80,84 **** /** ! * @author gift * @return exceptionMsg * @version v0.10 --- 80,84 ---- /** ! * @author gift (sourceforge.net user) * @return exceptionMsg * @version v0.10 |
From: gift <gi...@us...> - 2005-11-17 20:14:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28923/core/protocolsuite/tcp_ip Modified Files: ARP.java ICMP.java IP_packet.java ProtocolStack.java UDP_packet.java Udp.java Log Message: UDP.java implementation v0.01 ;) arrival Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Udp.java 8 Nov 2005 16:10:47 -0000 1.1 --- Udp.java 17 Nov 2005 20:13:56 -0000 1.2 *************** *** 1,53 **** ! /* ! 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.protocolsuite.tcp_ip; ! ! import java.io.Serializable; ! ! /** ! * This UDP class is constructed in a way that it represents its real world cousin (the UDP protocol) as accurately ! * as possible. ! ! * <P>This class contains methods which allow the transfer of packets to and from the lower layer. (Network Layer - IP ! * only at this stage). During a packets stay in this class, UDP headers are added, removed and examined ! * depending on wether the packet is in compilation or decompilation. During compilation, a packet is created, headers are added (all based ! * on real world UDP specification) and the packet is passed onto NetworkLayer (IP). During decompilation ! * UDP headers are removed and the data that was contained in the packet is passed onto the ProtocolStack. Relavent ! * information about what is happening in this class is added to the LayerInfo object so that it can be displayed ! * to the user in a clear and concise way.</P> ! * ! * @author james_nikolaidis ! * @since 10/06/2004 ! * @version v0.10 ! */ ! ! class Udp implements Serializable{ ! ! ! ! } --- 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.protocolsuite.tcp_ip; ! ! ! ! import java.io.Serializable; ! ! import core.CommunicationException; ! ! import core.LowLinkException; ! ! import core.LayerInfo; ! ! import core.Simulation; ! ! import core.TransportLayerException; ! ! import core.protocolsuite.tcp_ip.ProtocolStack; ! ! ! ! ! /** ! ! * This UDP class is constructed in a way that it represents its real world cousin (the UDP protocol) as accurately ! ! * as possible. ! ! ! ! * <P>This class contains methods which allow the transfer of packets to and from the lower layer. (Network Layer - IP ! ! * only at this stage). During a packets stay in this class, UDP headers are added, removed and examined ! ! * depending on wether the packet is in compilation or decompilation. During compilation, a packet is created, headers are added (all based ! ! * on real world UDP specification) and the packet is passed onto NetworkLayer (IP). During decompilation ! ! * UDP headers are removed and the data that was contained in the packet is passed onto the ProtocolStack. Relavent ! ! * information about what is happening in this class is added to the LayerInfo object so that it can be displayed ! ! * to the user in a clear and concise way.</P> ! ! * ! ! * @author james_nikolaidis ! ! * @since 10/06/2004 ! ! * @author gift (sourceforge.net user) ! ! * @since 17 Nov 2005 ! ! * @version v0.10 ! ! */ ! ! ! ! class Udp implements Serializable ! { ! ! private ProtocolStack mParentStack; ! ! ! /** ! * This method assigns the ParentStack ! * @author gift (sourceforge.net user) ! * @param Protocol Stack ! * @return Nothing. ! * @version v0.20 ! */ ! public Udp(ProtocolStack inParentStack) ! { ! mParentStack = inParentStack; ! } ! ! ! /** ! * This method receives the UDP packet, checks CHECK_SUM ! * and prints out a message to the layer info. ! * @author gift (sourceforge.net user) ! * @param Protocol Stack ! * @return Nothing. ! * @exception TransportLayerException If UDP CHECK_SUM != 1 ! * @version v0.20 ! * @see TransportLayerException ! */ ! ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException ! { ! ! // test if this packet is for a local Address. ! ! if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ ! ! // test check sum of UDP packet ! ! if (inPacket.getCheck_Sum() == 1) ! { ! //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("UDP packet received from "+ inPacket.getSourceIPAddress() + " message length " +inPacket.getUDP_MessageLength() + " bytes."); ! ! Simulation.addLayerInfo(UDP_Info); ! } else { ! throw new TransportLayerException("UDP Error: Incorrect checksum on receiving."); ! } ! } ! } ! ! /** ! * This method sends the UDP packet ! * and prints out a message to the layer info. ! * @author gift (sourceforge.net user) ! * @param inDestIPAddress ! * @param InterfaceName name of the intarface that sends UDP e.g. "eth0" ! * @return UDP_packet ! * @version v0.20 ! */ ! ! public UDP_packet sendUDPPacket(String inDestIPAddress, String InterfaceName) ! { ! UDP_packet tosend = new UDP_packet(inDestIPAddress, mParentStack.getIPAddress(InterfaceName)); ! ! //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); ! ! Simulation.addLayerInfo(UDP_Info); ! ! return tosend; ! } ! ! ! } //EOF \ No newline at end of file Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProtocolStack.java 8 Nov 2005 20:58:14 -0000 1.2 --- ProtocolStack.java 17 Nov 2005 20:13:56 -0000 1.3 *************** *** 1,597 **** ! /* ! 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. [...1762 lines suppressed...] ! } ! ! ! ! public String[] getRouteTableEntries(){ ! ! return mIPprotocol.getRouteTableEntries(); ! ! } ! ! ! ! public Route_entry getRouteTableEntry(String destIP){ ! ! return mIPprotocol.getRouteTableEntry(destIP); ! ! } ! ! }//EOF ! Index: IP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IP_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IP_packet.java 8 Nov 2005 16:10:47 -0000 1.1 --- IP_packet.java 17 Nov 2005 20:13:56 -0000 1.2 *************** *** 1,126 **** ! /* ! 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.protocolsuite.tcp_ip; ! ! import core.Packet; ! ! /** ! * IP_Packet extends the packet class. It set the IP_Packet Source address ! * and the destination IP address ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! ! public class IP_packet extends Packet{ ! ! String mSourceIPAddress; ! String mDestIPAddress; ! ! /** ! * Sets a IP packet ! * @author angela_brown ! * @author bevan_calliess ! * @param inDestIPAddress - Destination IP address ! * @version v0.20 ! */ ! public IP_packet(String inDestIPAddress) ! { ! mDestIPAddress = inDestIPAddress; ! } ! /** ! * Sets the destination IP address ! * @author angela_brown ! * @author bevan_calliess ! * @param inDestIPAddress - Destination IP address eg: 192.168.10.1 ! * @version v0.20 ! */ ! public void setDestIPAddress(String inDestIPAddress) ! { ! mDestIPAddress = inDestIPAddress; ! } ! /** ! * Sets the source IP address ! * @author angela_brown ! * @author bevan_calliess ! * @param inSourceIPAddress - Source IP address ! * @version v0.20 ! */ ! public void setSourceIPAddress(String inSourceIPAddress) ! { ! mSourceIPAddress = inSourceIPAddress; ! } ! ! /** ! * Sets the Data within the Packet ! * @author bevan_calliess ! * @author angela_brown ! * @param inData ! * @version v0.20 ! */ ! public void setData(Packet inData) ! { ! Data = inData; ! } ! /** ! * Gets the source IP Address ! * @author angela_brown ! * @author bevan_calliess ! * @return mSourceIPAddress - Source IP address ! * @version v0.20 ! */ ! public String getSourceIPAddress() ! { ! return mSourceIPAddress; ! } ! /** ! * Gets the destination IP address ! * @author bevan_calliess ! * @author angela_brown ! * @return mDestIPAddress - Destination IP Address ! * @version v0.20 ! */ ! public String getDestIPAddress() ! { ! return mDestIPAddress; ! } ! ! /** ! * Gets the Data packet ! * @author bevan_calliess ! * @author angela_brown ! * @return Data - The data packet ! * @version v0.20 ! **/ ! public Packet getData() ! { ! return Data; ! } ! }//EOF --- 1,252 ---- ! /* ! ! 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.protocolsuite.tcp_ip; ! ! ! ! import core.Packet; ! ! ! ! /** ! ! * IP_Packet extends the packet class. It set the IP_Packet Source address ! ! * and the destination IP address ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public class IP_packet extends Packet{ ! ! ! ! String mSourceIPAddress; ! ! String mDestIPAddress; ! ! ! ! /** ! ! * Sets a IP packet ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @param inDestIPAddress - Destination IP address ! ! * @version v0.20 ! ! */ ! ! public IP_packet(String inDestIPAddress) ! ! { ! ! mDestIPAddress = inDestIPAddress; ! ! } ! ! /** ! ! * Sets the destination IP address ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @param inDestIPAddress - Destination IP address eg: 192.168.10.1 ! ! * @version v0.20 ! ! */ ! ! public void setDestIPAddress(String inDestIPAddress) ! ! { ! ! mDestIPAddress = inDestIPAddress; ! ! } ! ! /** ! ! * Sets the source IP address ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @param inSourceIPAddress - Source IP address ! ! * @version v0.20 ! ! */ ! ! public void setSourceIPAddress(String inSourceIPAddress) ! ! { ! ! mSourceIPAddress = inSourceIPAddress; ! ! } ! ! ! ! /** ! ! * Sets the Data within the Packet ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inData ! ! * @version v0.20 ! ! */ ! ! public void setData(Packet inData) ! ! { ! ! Data = inData; ! ! } ! ! /** ! ! * Gets the source IP Address ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @return mSourceIPAddress - Source IP address ! ! * @version v0.20 ! ! */ ! ! public String getSourceIPAddress() ! ! { ! ! return mSourceIPAddress; ! ! } ! ! /** ! ! * Gets the destination IP address ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @return mDestIPAddress - Destination IP Address ! ! * @version v0.20 ! ! */ ! ! public String getDestIPAddress() ! ! { ! ! return mDestIPAddress; ! ! } ! ! ! ! /** ! ! * Gets the Data packet ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @return Data - The data packet ! ! * @version v0.20 ! ! **/ ! ! public Packet getData() ! ! { ! ! return Data; ! ! } ! ! }//EOF ! Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ARP.java 8 Nov 2005 16:10:47 -0000 1.1 --- ARP.java 17 Nov 2005 20:13:56 -0000 1.2 *************** *** 1,295 **** ! /* ! Java Network Simulator (jNetSim) ! ! Copyright (c) 2005, Ice Team; All rights reserved. ! 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 Ice Team 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.protocolsuite.tcp_ip; ! ! import java.io.Serializable; ! import java.util.*; ! import core.CommunicationException; ! import core.LowLinkException; ! import core.Simulation; ! import core.LayerInfo; ! ! /** ! * Currently the ARP protocol is implemented using a ststic method. This ! * means that each time the IP address is set for a node in the simulation the ! * IP address and MAC address are sent to all computers and the ARP table ! * is then updated for any entries that are local. This leaves a BIG WHOLE in the ! * protocol because any new nodes added to the simulation do not have the ARP table ! * for any of the older computers in the Simulation. This issue will need to be ! * covered in later versions of the Protocol. ! * @author bevan_calliess ! * @author robert_hulford ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! public class ARP implements Serializable{ ! private ProtocolStack mParentStack; ! private Vector ARPTable = new Vector(); ! private String mLastIpRequest = "0.0.0.0"; ! ! public ARP(ProtocolStack inParentStack){ ! mParentStack = inParentStack; ! } ! ! /** ! * This method will add a new entry to the ARP table ! * @author robert_hulford ! * @author bevan_calliess ! * @author Key ! * @param IPAddress - The IP address of the new entry ! * @param MacAddress - The Mac address of the new entry ! * @param inEntryType - The type of the new entry : Static or Dynamic ! * @version v0.22 ! */ ! public void addToArpTable(String inIPAddress, String inMacAddress, String inEntryType) { ! //look for an entry with this MAC address in the table ! Iterator it = ARPTable.iterator(); ! while(it.hasNext()) ! { ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! if (currEnt.getMACAddress().equals(inMacAddress)) ! { ! it.remove(); ! } ! } ! ARPTableEntry newEntry = new ARPTableEntry(inIPAddress,inMacAddress,inEntryType); ! ARPTable.add(newEntry); ! } ! ! /** ! * This method will remove all entries from the ARP table that match ! * nay IP Address in the String Array. ! * @author bevan_calliess ! * @author robert_calliess ! * @param IPAddress - An array of IP addreses that need to be removed ! * @version v0.20 ! */ ! public void removeFromArpTable(String[] IPAddress){ ! ARPTableEntry currentEntry; ! ! Iterator it = ARPTable.iterator(); ! while(it.hasNext()) ! { ! currentEntry = (ARPTableEntry)it.next(); ! for(int y=0; y < IPAddress.length; y++) ! { ! if(IPAddress[y].equals(currentEntry.getIPAddress())) ! { ! it.remove(); ! } ! } ! } ! } ! ! /** ! * This method will generate a String array containing all ! * the entries from the ARP table ! * @author robert_hulford ! * @author bevan_calliess ! * @return String Array - An array of strings that can be used to display the ARP table. ! * @version v0.20 ! */ ! public String[] getARPTable() ! { ! // first clean out the ARP table so that there are no old entries ! cleanARPTable(); ! ! String output[] = new String[ARPTable.size()+1]; ! int counter = 0; ! String ipAddress; ! char padding = ' '; ! ! if(ARPTable.size()>0){ ! output[0] = "Internet Address Physical Address Type"; ! ! Iterator it = ARPTable.iterator(); ! while(it.hasNext()) ! { ! counter++; ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! ipAddress = pad(currEnt.getIPAddress(),20,padding); ! output[counter] = ipAddress + currEnt.getMACAddress() + " " + currEnt.getEntryType(); ! } ! }else{ ! output[0] = "No ARP Entries Found"; ! } ! ! return output; ! } ! ! /** ! * This method will generate a String containing the Mac address ! * of the IP address passed in or null if it is not in the ARP table ! * the entries from the ARP table are cleaned out after two minutes ! * as they are in the real protocol. ! * @author bevan_calliess ! * @author robert_hulford ! * @param String - The IP address to search for in the ARP table ! * @return String - Either the MAC of the ip passed in or null. ! * @version v0.20 ! */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws LowLinkException ! { ! String output= null; ! //this cleans out any entries older than 2 minutes ! cleanARPTable(); ! ! Iterator it = ARPTable.iterator(); ! while(it.hasNext()){ ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! if (currEnt.getIPAddress().equals(IPAddress)){ ! output = currEnt.getMACAddress(); ! } ! } ! if(output == null){ ! //then send ARP Packet to try and find out about IP Address ! mLastIpRequest = IPAddress; ! String srcMAC = mParentStack.getMACAddress(inInterfaceKey); ! ARP_packet ArpDisc = new ARP_packet(IPAddress); ! ArpDisc.setMessageCode(ARP_packet.ARP_REQUEST); ! ArpDisc.setSourceMAC(srcMAC); ! //Create layer info object ! LayerInfo arpInfo = new LayerInfo(getClass().getName()); ! arpInfo.setObjectName(mParentStack.getParentNodeName()); ! arpInfo.setDataType("ARP Discovery Packet"); ! arpInfo.setLayer("DataLink"); ! arpInfo.setDescription("Created ARP discovery packet to source MAC address for IP "+IPAddress); ! Simulation.addLayerInfo(arpInfo); ! try{ ! mParentStack.broadcastPacket(ArpDisc,inInterfaceKey); ! }catch(CommunicationException e){ ! // no need to throw this. method will return null ! } ! Iterator it1 = ARPTable.iterator(); ! while(it1.hasNext()) ! { ! ARPTableEntry currEnt = (ARPTableEntry)it1.next(); ! if (currEnt.getIPAddress().equals(IPAddress)) ! { ! output = currEnt.getMACAddress(); ! } ! } ! } ! return output; ! } ! ! /** ! * This method will recieve a packet and determind the type ! * Then deal with the packet depending on the required response. ! * @author bevan_calliess ! * @author robert_hulford ! * @param temp - The packet to be processed ! * @version v0.20 ! */ ! ! public void receiveARPPacket(ARP_packet inARPpacket) throws LowLinkException{ ! // test if this packet is for a local Address. ! if(mParentStack.isInternalIP(inARPpacket.getDestIPAddress())){ ! // test the type of ARP packet ! if(inARPpacket.getMessageCode()==1){ ! //If its an ARP Request add the entry to the arp table ! // and send response ! try{ ! addToArpTable(inARPpacket.getSourceIPAddress(),inARPpacket.getSourceMAC(),"Dynamic"); ! ARP_packet ArpResponse = new ARP_packet(inARPpacket.getSourceIPAddress()); ! ArpResponse.setMessageCode(ARP_packet.ARP_REPLY); ! String outInterface = mParentStack.getRouteInfo(inARPpacket.getSourceIPAddress()); ! String srcMAC = mParentStack.getMACAddress(outInterface); ! ArpResponse.setSourceMAC(srcMAC); ! //Create Layer info ! LayerInfo arpInfo = new LayerInfo(getClass().getName()); ! arpInfo.setObjectName(mParentStack.getParentNodeName()); ! arpInfo.setDataType("ARP Response Packet"); ! arpInfo.setLayer("DataLink"); ! arpInfo.setDescription("Created ARP Response packet to "+inARPpacket.getSourceIPAddress() ); ! Simulation.addLayerInfo(arpInfo); ! //Send packet ! mParentStack.sendPacket(ArpResponse); ! }catch(CommunicationException e){ ! // no need to throw this. method will return null ! }catch(LowLinkException e){ ! // no need to throw this. method will return null ! throw e; ! } ! }else{ ! //if its an ARP response Add the entry to the ARP table. ! addToArpTable(inARPpacket.getSourceIPAddress(),inARPpacket.getSourceMAC(),"Dynamic"); ! } ! } ! } ! ! /** ! * This method is used to create a fixed length string ! * If the string is already greater than the length no action is taken ! * and the original string is returned. ! * @author bevan_calliess ! * @author robert_hulford ! * @param inString - The string that you want padded to the fixed length. ! * @param length - The length you would like to string to be. ! * @param pad - The character you would like to use to pad the String. ! * @return String - Returns a gap lenght ! * @version v0.20 ! */ ! private String pad(String inString, int length, char pad) { ! StringBuffer buffer = new StringBuffer(inString); ! while (buffer.length() < length) { ! buffer.append(pad); ! } ! return buffer.toString(); ! } ! /** ! * This method will iterate through the ARP table and clean out ! * any ARP entries that have been here for more than 2 minutes. ! * Note: This is a simplified version of the Real ARP ! * The Real ARP process that will only keep an entry for 2 minutes ! * unless it is used again. It will retain the entries that are ! * reused up to a maximum of 20 Minutes. ! */ ! private void cleanARPTable(){ ! GregorianCalendar tempTime = new GregorianCalendar(); ! tempTime.add(Calendar.MINUTE,-2); ! Iterator it = ARPTable.iterator(); ! ! while(it.hasNext()){ ! ARPTableEntry tempEntry = (ARPTableEntry)it.next(); ! GregorianCalendar entryTime = tempEntry.getEntryTime(); ! if(entryTime.getTimeInMillis()<tempTime.getTimeInMillis()){ ! if(tempEntry.getIPAddress().equals(mLastIpRequest)){ ! mLastIpRequest = "0.0.0.0"; ! } ! if(tempEntry.getEntryType().contains("Dynamic")) it.remove(); ! } ! } ! } ! ! ! }//EOF --- 1,590 ---- ! /* ! ! Java Network Simulator (jNetSim) ! ! ! ! Copyright (c) 2005, Ice Team; All rights reserved. ! ! 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 Ice Team 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.protocolsuite.tcp_ip; ! ! ! ! import java.io.Serializable; ! ! import java.util.*; ! ! import core.CommunicationException; ! ! import core.LowLinkException; ! ! import core.Simulation; ! ! import core.LayerInfo; ! ! ! ! /** ! ! * Currently the ARP protocol is implemented using a ststic method. This ! ! * means that each time the IP address is set for a node in the simulation the ! ! * IP address and MAC address are sent to all computers and the ARP table ! ! * is then updated for any entries that are local. This leaves a BIG WHOLE in the ! ! * protocol because any new nodes added to the simulation do not have the ARP table ! ! * for any of the older computers in the Simulation. This issue will need to be ! ! * covered in later versions of the Protocol. ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * @version v0.20 ! ! */ ! ! public class ARP implements Serializable{ ! ! private ProtocolStack mParentStack; ! ! private Vector ARPTable = new Vector(); ! ! private String mLastIpRequest = "0.0.0.0"; ! ! ! ! public ARP(ProtocolStack inParentStack){ ! ! mParentStack = inParentStack; ! ! } ! ! ! ! /** ! ! * This method will add a new entry to the ARP table ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @author Key ! ! * @param IPAddress - The IP address of the new entry ! ! * @param MacAddress - The Mac address of the new entry ! ! * @param inEntryType - The type of the new entry : Static or Dynamic ! ! * @version v0.22 ! ! */ ! ! public void addToArpTable(String inIPAddress, String inMacAddress, String inEntryType) { ! ! //look for an entry with this MAC address in the table ! ! Iterator it = ARPTable.iterator(); ! ! while(it.hasNext()) ! ! { ! ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! ! if (currEnt.getMACAddress().equals(inMacAddress)) ! ! { ! ! it.remove(); ! ! } ! ! } ! ! ARPTableEntry newEntry = new ARPTableEntry(inIPAddress,inMacAddress,inEntryType); ! ! ARPTable.add(newEntry); ! ! } ! ! ! ! /** ! ! * This method will remove all entries from the ARP table that match ! ! * nay IP Address in the String Array. ! ! * @author bevan_calliess ! ! * @author robert_calliess ! ! * @param IPAddress - An array of IP addreses that need to be removed ! ! * @version v0.20 ! ! */ ! ! public void removeFromArpTable(String[] IPAddress){ ! ! ARPTableEntry currentEntry; ! ! ! ! Iterator it = ARPTable.iterator(); ! ! while(it.hasNext()) ! ! { ! ! currentEntry = (ARPTableEntry)it.next(); ! ! for(int y=0; y < IPAddress.length; y++) ! ! { ! ! if(IPAddress[y].equals(currentEntry.getIPAddress())) ! ! { ! ! it.remove(); ! ! } ! ! } ! ! } ! ! } ! ! ! ! /** ! ! * This method will generate a String array containing all ! ! * the entries from the ARP table ! ! * @author robert_hulford ! ! * @author bevan_calliess ! ! * @return String Array - An array of strings that can be used to display the ARP table. ! ! * @version v0.20 ! ! */ ! ! public String[] getARPTable() ! ! { ! ! // first clean out the ARP table so that there are no old entries ! ! cleanARPTable(); ! ! ! ! String output[] = new String[ARPTable.size()+1]; ! ! int counter = 0; ! ! String ipAddress; ! ! char padding = ' '; ! ! ! ! if(ARPTable.size()>0){ ! ! output[0] = "Internet Address Physical Address Type"; ! ! ! ! Iterator it = ARPTable.iterator(); ! ! while(it.hasNext()) ! ! { ! ! counter++; ! ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! ! ipAddress = pad(currEnt.getIPAddress(),20,padding); ! ! output[counter] = ipAddress + currEnt.getMACAddress() + " " + currEnt.getEntryType(); ! ! } ! ! }else{ ! ! output[0] = "No ARP Entries Found"; ! ! } ! ! ! ! return output; ! ! } ! ! ! ! /** ! ! * This method will generate a String containing the Mac address ! ! * of the IP address passed in or null if it is not in the ARP table ! ! * the entries from the ARP table are cleaned out after two minutes ! ! * as they are in the real protocol. ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param String - The IP address to search for in the ARP table ! ! * @return String - Either the MAC of the ip passed in or null. ! ! * @version v0.20 ! ! */ ! ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws LowLinkException ! ! { ! ! String output= null; ! ! //this cleans out any entries older than 2 minutes ! ! cleanARPTable(); ! ! ! ! Iterator it = ARPTable.iterator(); ! ! while(it.hasNext()){ ! ! ARPTableEntry currEnt = (ARPTableEntry)it.next(); ! ! if (currEnt.getIPAddress().equals(IPAddress)){ ! ! output = currEnt.getMACAddress(); ! ! } ! ! } ! ! if(output == null){ ! ! //then send ARP Packet to try and find out about IP Address ! ! mLastIpRequest = IPAddress; ! ! String srcMAC = mParentStack.getMACAddress(inInterfaceKey); ! ! ARP_packet ArpDisc = new ARP_packet(IPAddress); ! ! ArpDisc.setMessageCode(ARP_packet.ARP_REQUEST); ! ! ArpDisc.setSourceMAC(srcMAC); ! ! //Create layer info object ! ! LayerInfo arpInfo = new LayerInfo(getClass().getName()); ! ! arpInfo.setObjectName(mParentStack.getParentNodeName()); ! ! arpInfo.setDataType("ARP Discovery Packet"); ! ! arpInfo.setLayer("DataLink"); ! ! arpInfo.setDescription("Created ARP discovery packet to source MAC address for IP "+IPAddress); ! ! Simulation.addLayerInfo(arpInfo); ! ! try{ ! ! mParentStack.broadcastPacket(ArpDisc,inInterfaceKey); ! ! }catch(CommunicationException e){ ! ! // no need to throw this. method will return null ! ! } ! ! Iterator it1 = ARPTable.iterator(); ! ! while(it1.hasNext()) ! ! { ! ! ARPTableEntry currEnt = (ARPTableEntry)it1.next(); ! ! if (currEnt.getIPAddress().equals(IPAddress)) ! ! { ! ! output = currEnt.getMACAddress(); ! ! } ! ! } ! ! } ! ! return output; ! ! } ! ! ! ! /** ! ! * This method will recieve a packet and determind the type ! ! * Then deal with the packet depending on the required response. ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param temp - The packet to be processed ! ! * @version v0.20 ! ! */ ! ! ! ! public void receiveARPPacket(ARP_packet inARPpacket) throws LowLinkException{ ! ! // test if this packet is for a local Address. ! ! if(mParentStack.isInternalIP(inARPpacket.getDestIPAddress())){ ! ! // test the type of ARP packet ! ! if(inARPpacket.getMessageCode()==1){ ! ! //If its an ARP Request add the entry to the arp table ! ! // and send response ! ! try{ ! ! addToArpTable(inARPpacket.getSourceIPAddress(),inARPpacket.getSourceMAC(),"Dynamic"); ! ! ARP_packet ArpResponse = new ARP_packet(inARPpacket.getSourceIPAddress()); ! ! ArpResponse.setMessageCode(ARP_packet.ARP_REPLY); ! ! String outInterface = mParentStack.getRouteInfo(inARPpacket.getSourceIPAddress()); ! ! String srcMAC = mParentStack.getMACAddress(outInterface); ! ! ArpResponse.setSourceMAC(srcMAC); ! ! //Create Layer info ! ! LayerInfo arpInfo = new LayerInfo(getClass().getName()); ! ! arpInfo.setObjectName(mParentStack.getParentNodeName()); ! ! arpInfo.setDataType("ARP Response Packet"); ! ! arpInfo.setLayer("DataLink"); ! ! arpInfo.setDescription("Created ARP Response packet to "+inARPpacket.getSourceIPAddress() ); ! ! Simulation.addLayerInfo(arpInfo); ! ! //Send packet ! ! mParentStack.sendPacket(ArpResponse); ! ! }catch(CommunicationException e){ ! ! // no need to throw this. method will return null ! ! }catch(LowLinkException e){ ! ! // no need to throw this. method will return null ! ! throw e; ! ! } ! ! }else{ ! ! //if its an ARP response Add the entry to the ARP table. ! ! addToArpTable(inARPpacket.getSourceIPAddress(),inARPpacket.getSourceMAC(),"Dynamic"); ! ! } ! ! } ! ! } ! ! ! ! /** ! ! * This method is used to create a fixed length string ! ! * If the string is already greater than the length no action is taken ! ! * and the original string is returned. ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inString - The string that you want padded to the fixed length. ! ! * @param length - The length you would like to string to be. ! ! * @param pad - The character you would like to use to pad the String. ! ! * @return String - Returns a gap lenght ! ! * @version v0.20 ! ! */ ! ! private String pad(String inString, int length, char pad) { ! ! StringBuffer buffer = new StringBuffer(inString); ! ! while (buffer.length() < length) { ! ! buffer.append(pad); ! ! } ! ! return buffer.toString(); ! ! } ! ! /** ! ! * This method will iterate through the ARP table and clean out ! ! * any ARP entries that have been here for more than 2 minutes. ! ! * Note: This is a simplified version of the Real ARP ! ! * The Real ARP process that will only keep an entry for 2 minutes ! ! * unless it is used again. It will retain the entries that are ! ! * reused up to a maximum of 20 Minutes. ! ! */ ! ! private void cleanARPTable(){ ! ! GregorianCalendar tempTime = new GregorianCalendar(); ! ! tempTime.add(Calendar.MINUTE,-2); ! ! Iterator it = ARPTable.iterator(); ! ! ! ! while(it.hasNext()){ ! ! ARPTableEntry tempEntry = (ARPTableEntry)it.next(); ! ! GregorianCalendar entryTime = tempEntry.getEntryTime(); ! ! if(entryTime.getTimeInMillis()<tempTime.getTimeInMillis()){ ! ! if(tempEntry.getIPAddress().equals(mLastIpRequest)){ ! ! mLastIpRequest = "0.0.0.0"; ! ! } ! ! if(tempEntry.getEntryType().contains("Dynamic")) it.remove(); ! ! } ! ! } ! ! } ! ! ! ! ! ! }//EOF ! Index: ICMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICMP.java 8 Nov 2005 16:10:47 -0000 1.1 --- ICMP.java 17 Nov 2005 20:13:56 -0000 1.2 *************** *** 1,149 **** ! /* ! 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.protocolsuite.tcp_ip; ! ! import java.io.Serializable; ! import core.protocolsuite.tcp_ip.ICMP_packet; ! import core.CommunicationException; ! import core.LowLinkException; ! import core.LayerInfo; ! import core.Simulation; ! ! ! /** ! * @author angela_brown ! * @author bevan_calliess ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.00 ! */ ! ! ! public class ICMP implements Serializable{ ! private ProtocolStack mParentStack; ! ! /** ! * Assigns the ParentStack ! * @author bevan_calliess ! * @author luke_hamilton ! * @param inParentStack - Protocol Stack ! * @version v0.20 ! */ ! public ICMP(ProtocolStack inParentStack){ ! mParentStack = inParentStack; ! } ! ! /** ! * Receives the ICMP packet and checks the message ! * code attached to it. If 8, it is an echo request and ! * pass it of. If 0, print out a message to the layer info. ! * @author bevan_calliess ! * @author angela_brown ! * @author robert_hulford ! * @param inPacket - A PAcket ! * @version v0.20 ! */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws LowLinkException { ! ! if(inPacket.getMessageCode() == 8 ){ ! echoRequest(inPacket); ! } ! if(inPacket.getMessageCode() == 0 ){ ! //Create Layer info ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! pingInfo.setDataType("Echo Reply Packet"); ! pingInfo.setLayer("Network"); ! pingInfo.setDescription("Echo reply packet received from "+ inPacket.getSourceIPAddress()); ! Simulation.addLayerInfo(pingInfo); ! } ! } ! ! /** ! * This method will send a reply to a ping request ! * @author angela_brown ! * @author bevan_calliess ! * @author robert_hulford ! * @author luke_hamilton ! * @param inPacket - The original packet recived by this Node ! * @exception CommunicationException ! * @version v0.20 ! */ ! private void echoRequest(ICMP_packet inPacket) throws LowLinkException{ ! String destIPAddress = inPacket.getSourceIPAddress(); ! ICMP_packet pingPacket = new ICMP_packet(destIPAddress); ! pingPacket.setMessageCode(ICMP_packet.ECHO_REPLY); ! ! //Create Layer info ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! pingInfo.setDataType("Echo Reply Packet"); ! pingInfo.setLayer("Network"); ! pingInfo.setDescription("Created Echo Reply packet to "+destIPAddress); ! Simulation.addLayerInfo(pingInfo); ! ! try{ ! mParentStack.sendPacket(pingPacket); ! }catch(CommunicationException e){ ! //This exception is caught but not acted upon as the ! //Echo request on any PC would not notify the user if it failed ! //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 ! //Echo request on any PC would not notify the user if it failed ! //TODO Once the recording of a sim process is implemented this should record the error. ! //} ! } ! ! /** ! * This method will generate an ICMP echo request and send it ! * out via the Protocol stacks send method. ! * @author angela_brown ! * @author bevan_calliess ! * @author robert_hulford ! * @param inDestIPAddress - Destination IP Address ! * @return ICMP_packet - Ping Packet ! */ ! public ICMP_packet sendPing(String inDestIPAddress) { ! ICMP_packet pingPacket = new ICMP_packet(inDestIPAddress); ! pingPacket.setMessageCode(ICMP_packet.ECHO_REQUEST); ! ! //Create Layer info ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! pingInfo.setDataType("Echo Request Packet"); ! pingInfo.setLayer("Network"); ! pingInfo.setDescription("Created Echo Request packet to " +inDestIPAddress ); ! Simulation.addLayerInfo(pingInfo); ! ! return pingPacket; ! } ! ! }//EOF --- 1,298 ---- ! /* ! ! 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.protocolsuite.tcp_ip; ! ! ! ! import java.io.Serializable; ! ! //import core.protocolsuite.tcp_ip.ICMP_packet; ! ! import core.CommunicationException; ! ! import core.LowLinkException; ! ! import core.LayerInfo; ! ! import core.Simulation; ! ! ! ! ! ! /** ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * @version v0.00 ! ! */ ! ! ! ! ! ! public class ICMP implements Serializable{ ! ! private ProtocolStack mParentStack; ! ! ! ! /** ! ! * Assigns the ParentStack ! ! * @author bevan_calliess ! ! * @author luke_hamilton ! ! * @param inParentStack - Protocol Stack ! ! * @version v0.20 ! ! */ ! ! public ICMP(ProtocolStack inParentStack){ ! ! mParentStack = inParentStack; ! ! } ! ! ! ! /** ! ! * Receives the ICMP packet and checks the message ! ! * code attached to it. If 8, it is an echo request and ! ! * pass it of. If 0, print out a message to the layer info. ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @author robert_hulford ! ! * @param inPacket - A PAcket ! ! * @version v0.20 ! ! */ ! ! public void receiveICMPPacket(ICMP_packet inPacket) throws LowLinkException { ! ! ! ! if(inPacket.getMessageCode() == 8 ){ ! ! echoRequest(inPacket); ! ! } ! ! if(inPacket.getMessageCode() == 0 ){ ! ! //Create Layer info ! ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! ! pingInfo.setDataType("Echo Reply Packet"); ! ! pingInfo.setLayer("Network"); ! ! pingInfo.setDescription("Echo reply packet received from "+ inPacket.getSourceIPAddress()); ! ! Simulation.addLayerInfo(pingInfo); ! ! } ! ! } ! ! ! ! /** ! ! * This method will send a reply to a ping request ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @author luke_hamilton ! ! * @param inPacket - The original packet recived by this Node ! ! * @exception CommunicationException ! ! * @version v0.20 ! ! */ ! ! private void echoRequest(ICMP_packet inPacket) throws LowLinkException{ ! ! String destIPAddress = inPacket.getSourceIPAddress(); ! ! ICMP_packet pingPacket = new ICMP_packet(destIPAddress); ! ! pingPacket.setMessageCode(ICMP_packet.ECHO_REPLY); ! ! ! ! //Create Layer info ! ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! ! pingInfo.setDataType("Echo Reply Packet"); ! ! pingInfo.setLayer("Network"); ! ! pingInfo.setDescription("Created Echo Reply packet to "+destIPAddress); ! ! Simulation.addLayerInfo(pingInfo); ! ! ! ! try{ ! ! mParentStack.sendPacket(pingPacket); ! ! }catch(CommunicationException e){ ! ! //This exception is caught but not acted upon as the ! ! //Echo request on any PC would not notify the user if it failed ! ! //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 ! ! //Echo request on any PC would not notify the user if it failed ! ! //TODO Once the recording of a sim process is implemented this should record the error. ! ! //} ! ! } ! ! ! ! /** ! ! * This method will generate an ICMP echo request and send it ! ! * out via the Protocol stacks send method. ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inDestIPAddress - Destination IP Address ! ! * @return ICMP_packet - Ping Packet ! ! */ ! ! public ICMP_packet sendPing(String inDestIPAddress) { ! ! ICMP_packet pingPacket = new ICMP_packet(inDestIPAddress); ! ! pingPacket.setMessageCode(ICMP_packet.ECHO_REQUEST); ! ! ! ! //Create Layer info ! ! LayerInfo pingInfo = new LayerInfo(getClass().getName()); ! ! pingInfo.setObjectName(mParentStack.getParentNodeName()); ! ! pingInfo.setDataType("Echo Request Packet"); ! ! pingInfo.setLayer("Network"); ! ! pingInfo.setDescription("Created Echo Request packet to " +inDestIPAddress ); ! ! Simulation.addLayerInfo(pingInfo); ! ! ! ! return pingPacket; ! ! } ! ! ! ! }//EOF ! Index: UDP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/UDP_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UDP_packet.java 16 Nov 2005 20:25:40 -0000 1.2 --- UDP_packet.java 17 Nov 2005 20:13:56 -0000 1.3 *************** *** 68,72 **** * Design and implementation of UDP_packet ! * @author gift * @since Nov 16, 2005 * @version v0.20 --- 68,72 ---- * Design and implementation of UDP_packet ! * @author gift (sourceforge.net user) * @since Nov 16, 2005 * @version v0.20 *************** *** 76,86 **** { ! private int UDP_MessageLength; ! private int mMessageCode; private String UDP_message; ! private static final int CHECK_SUM = 1; //for future developing :) private static final int HEAD_LENGTH = 8; //UDP header is 8 bytes --- 76,93 ---- { ! /* DO NOT forget about pseudo UDP header fields ! * - mSourceIPAddress (implemented) ! * - mDestIPAddress (implemented) ! * - PTCL (protocol type code) (implemented) ! * - UDP length - not needed (not implemented) ! * that's why UDP_packet extends IP_packet */ ! private int UDP_MessageLength; private String UDP_message; ! private static final int PTCL = 17; //see RFC :) ! ! private static final int CHECK_SUM = 1; //for future developing :) private static final int HEAD_LENGTH = 8; //UDP header is 8 bytes *************** *** 91,104 **** /** ! * This method passes the destination address into the super class ! * @author gift ! * @param destination IP address * @return Nothing. * @version v0.20 */ ! public UDP_packet(String inDestIPAddress) { ! super (inDestIPAddress); UDP_MessageLength = HEAD_LENGTH; UDP_message = ""; --- 98,112 ---- /** ! * This method passes the destination and source addresses into the super class ! * @author gift (sourceforge.net user) ! * @param destination IP address, source IP address * @return Nothing. * @version v0.20 */ ! public UDP_packet(String inDestIPAddress, String inSourceIPAddress) { ! super (inDestIPAddress); ! this.setSourceIPAddress(inSourceIPAddress); UDP_MessageLength = HEAD_LENGTH; UDP_message = ""; *************** *** 107,112 **** /** * This method sets the UDP_message and calculates UDP_message length ! * @author gift ! * @param a string to be set as a UDP message * @return Nothing. * @exception TransportLayerException If UDP message exceeds maximum size of UDP message. --- 115,120 ---- /** * This method sets the UDP_message and calculates UDP_message length ! * @author gift (sourceforge.net user) ! * @param inUDP_message a string to be set as a UDP message * @return Nothing. * @exception TransportLayerException If UDP message exceeds maximum size of UDP message. *************** *** 134,138 **** /** * This method returns the string describing UDP message ! * @author gift * @param Unused. * @return the UDP message --- 142,146 ---- /** * This method returns the string describing UDP message ! * @author gift (sourceforge.net user) * @param Unused. * @return the UDP message *************** *** 147,151 **** /** * This method returns integer describing UDP message length ! * @author gift * @param Unused. * @return the length of UDP message. --- 155,159 ---- /** * This method returns integer describing UDP message length ! * @author gift (sourceforge.net user) * @param Unused. * @return the length of UDP message. *************** *** 158,185 **** } /** ! * This method sets mMessageCode ! * @author gift ! * @param the value to be set as mMessageCode * @return Nothing. * @version v0.20 */ ! public void setMessageCode(int inCode) { ! mMessageCode = inCode; } /** ! * This method gets mMessageCode ! * @author gift * @param Unused. ! * @return message code. * @version v0.20 */ ! public int getMessageCode() { ! return mMessageCode; } }//EOF --- 166,206 ---- } + /** ! * This if for design and future implementation of UDP_packet ! * @author gift (sourceforge.net user) ! * @param Nothing. * @return Nothing. * @version v0.20 */ ! public void calculateCheck_Sum() { ! } /** ! * This method gets Check_Sum ! * can be used for design and future implementation of UDP_packet ! * @author gift (sourceforge.net user) * @param Unused. ! * @return CHECK_SUM. * @version v0.20 */ ! public int getCheck_Sum() { ! return CHECK_SUM; } + /** + * This method gets protocol code (17 for UDP) + * @author gift (sourceforge.net user) + * @param Unused. + * @return protocol code PTCL. + * @version v0.20 + */ + public int getProtocolCode() + { + return PTCL; + } }//EOF |
From: gift <gi...@us...> - 2005-11-16 20:26:17
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17792/core/protocolsuite/tcp_ip Modified Files: ARP_packet.java Route_entry.java UDP_packet.java Log Message: well this is first thing I've done on CVS ;) Index: Route_entry.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Route_entry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Route_entry.java 8 Nov 2005 20:58:14 -0000 1.2 --- Route_entry.java 16 Nov 2005 20:25:40 -0000 1.3 *************** *** 2,6 **** * Route_entry.java * ! * Created on 7 îÏÑÂÒØ 2005 Ç., 17:52 * * To change this template, choose Tools | Options and locate the template under --- 2,6 ---- * Route_entry.java * ! * Created on 7 Nov 2005 Ç., 17:52 * * To change this template, choose Tools | Options and locate the template under Index: ARP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ARP_packet.java 8 Nov 2005 16:10:47 -0000 1.1 --- ARP_packet.java 16 Nov 2005 20:25:40 -0000 1.2 *************** *** 1,131 **** ! /* ! 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.protocolsuite.tcp_ip; ! ! /** ! * This class is a representation of the Internets ARP packet. ! * ARP packets are userd for IP address resolution. Echo resquests and echo reply ! * are currently the only ones implemented. Packets type will need to be ! * implemented if you wish to futher this class. ! * @author bevan_calliess ! * @author robert_hulford ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! ! public class ARP_packet extends IP_packet{ ! public static final int ARP_REQUEST = 1; ! public static final int ARP_REPLY = 2; ! public static final int RARP_REQUEST = 3; ! public static final int RARP_REPLY = 4; ! private String ARP_message; ! private String sourceMac; ! private int mMessageCode; ! ! /** ! * This method passes the destination address into the super class ! * (IP_packet) ! * @author bevan_calliess ! * @author robert_hulford ! * @param inDestIPAddress ! * @version v0.20 ! */ ! public ARP_packet(String inDestIPAddress){ ! super (inDestIPAddress); ! } ! ! /** ! * This method passes sets the ARP_message ! * @author bevan_calliess ! * @author robert_hulford ! * @param inARP_message ! * @version v0.20 ! */ ! public void setARP_message(String inARP_message) ! { ! ARP_message = inARP_message; ! } ! /** ! * This method gets the ARP_message ! * @author bevan_calliess ! * @author robert_hulford ! * @version v0.20 ! */ ! public String getARP_message() ! { ! return ARP_message; ! } ! /** ! * This method sets the SourceMAC address ! * @author bevan_calliess ! * @author robert_hulford ! * @param inMac ! * @version v0.20 ! */ ! public void setSourceMAC(String inMac){ ! sourceMac = inMac; ! } ! /** ! * This method gets the SourceMAC address ! * @author bevan_calliess ! * @author robert_hulford ! * @param inDestIPAddress ! * @version v0.20 ! */ ! public String getSourceMAC(){ ! return sourceMac; ! } ! /** ! * This method will take an integer value representing the ARP Packet ! * code that identifies the type of Packet. EG an ARP request packet is ! * type 1, ARP reply is 2 see page 57 ! * TCP/IP illustrated Vol1 the protocols ! * and see the constants setup in this class ! * NOTE no validation of Codes is currently implemented ! * @author bevan_calliess ! * @author robert_hulford ! * @param InCode - The code of the message ! * @version v0.20 ! */ ! public void setMessageCode(int inCode){ ! mMessageCode = inCode; ! } ! /** ! * returns the message code for this packet ! * @author bevan_calliess ! * @author robert_hulford ! * @return integer representing the message code ! * @version v0.20 ! */ ! public int getMessageCode(){ ! return mMessageCode; ! } ! ! }//EOF --- 1,262 ---- ! /* ! ! 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.protocolsuite.tcp_ip; ! ! ! ! /** ! ! * This class is a representation of the Internets ARP packet. ! ! * ARP packets are userd for IP address resolution. Echo resquests and echo reply ! ! * are currently the only ones implemented. Packets type will need to be ! ! * implemented if you wish to futher this class. ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @since Sep 17, 2004 ! ! * @version v0.20 ! ! */ ! ! ! ! public class ARP_packet extends IP_packet{ ! ! public static final int ARP_REQUEST = 1; ! ! public static final int ARP_REPLY = 2; ! ! public static final int RARP_REQUEST = 3; ! ! public static final int RARP_REPLY = 4; ! ! private String ARP_message; ! ! private String sourceMac; ! ! private int mMessageCode; ! ! ! ! /** ! ! * This method passes the destination address into the super class ! ! * (IP_packet) ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inDestIPAddress ! ! * @version v0.20 ! ! */ ! ! public ARP_packet(String inDestIPAddress){ ! ! super (inDestIPAddress); ! ! } ! ! ! ! /** ! ! * This method passes sets the ARP_message ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inARP_message ! ! * @version v0.20 ! ! */ ! ! public void setARP_message(String inARP_message) ! ! { ! ! ARP_message = inARP_message; ! ! } ! ! /** ! ! * This method gets the ARP_message ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @version v0.20 ! ! */ ! ! public String getARP_message() ! ! { ! ! return ARP_message; ! ! } ! ! /** ! ! * This method sets the SourceMAC address ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inMac ! ! * @version v0.20 ! ! */ ! ! public void setSourceMAC(String inMac){ ! ! sourceMac = inMac; ! ! } ! ! /** ! ! * This method gets the SourceMAC address ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param inDestIPAddress ! ! * @version v0.20 ! ! */ ! ! public String getSourceMAC(){ ! ! return sourceMac; ! ! } ! ! /** ! ! * This method will take an integer value representing the ARP Packet ! ! * code that identifies the type of Packet. EG an ARP request packet is ! ! * type 1, ARP reply is 2 see page 57 ! ! * TCP/IP illustrated Vol1 the protocols ! ! * and see the constants setup in this class ! ! * NOTE no validation of Codes is currently implemented ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @param InCode - The code of the message ! ! * @version v0.20 ! ! */ ! ! public void setMessageCode(int inCode){ ! ! mMessageCode = inCode; ! ! } ! ! /** ! ! * returns the message code for this packet ! ! * @author bevan_calliess ! ! * @author robert_hulford ! ! * @return integer representing the message code ! ! * @version v0.20 ! ! */ ! ! public int getMessageCode(){ ! ! return mMessageCode; ! ! } ! ! ! ! }//EOF ! Index: UDP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/UDP_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UDP_packet.java 8 Nov 2005 16:10:47 -0000 1.1 --- UDP_packet.java 16 Nov 2005 20:25:40 -0000 1.2 *************** *** 1,45 **** ! /* ! 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.protocolsuite.tcp_ip; ! ! import core.Packet; ! ! ! /** ! * This if for design and future implementation of UDP_packet ! * @author luke_hamilton ! * @since Sep 17, 2004 ! * @version v0.20 ! */ ! ! ! ! public class UDP_packet extends Packet{ ! } --- 1,186 ---- ! /* ! ! 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.protocolsuite.tcp_ip; ! ! import core.Packet; ! import core.TransportLayerException; ! ! /** ! ! * This if for design and future implementation of UDP_packet ! ! * @author luke_hamilton ! ! * @since Sep 17, 2004 ! ! * Design and implementation of UDP_packet ! * @author gift ! * @since Nov 16, 2005 ! * @version v0.20 ! */ ! ! public class UDP_packet extends IP_packet ! { ! ! private int UDP_MessageLength; ! ! private int mMessageCode; ! ! private String UDP_message; ! ! private static final int CHECK_SUM = 1; //for future developing :) ! ! private static final int HEAD_LENGTH = 8; //UDP header is 8 bytes ! ! private static final int MAX_LENGTH = 65535; //bytes is UDP datagramm maximum length ! ! ! ! /** ! * This method passes the destination address into the super class ! * @author gift ! * @param destination IP address ! * @return Nothing. ! * @version v0.20 ! */ ! ! public UDP_packet(String inDestIPAddress) ! { ! super (inDestIPAddress); ! UDP_MessageLength = HEAD_LENGTH; ! UDP_message = ""; ! } ! ! /** ! * This method sets the UDP_message and calculates UDP_message length ! * @author gift ! * @param a string to be set as a UDP message ! * @return Nothing. ! * @exception TransportLayerException If UDP message exceeds maximum size of UDP message. ! * @version v0.20 ! * @see TransportLayerException ! */ ! ! public void setUDP_message(String inUDP_message) throws TransportLayerException ! { ! int length; ! ! length = HEAD_LENGTH + UDP_message.length(); ! ! if (length <= MAX_LENGTH) ! { ! UDP_message = inUDP_message; ! UDP_MessageLength = length; ! ! }else ! { ! throw new TransportLayerException("UDP Error: UDP message exceeds maximum size of " + MAX_LENGTH + " bytes."); ! } ! } ! ! /** ! * This method returns the string describing UDP message ! * @author gift ! * @param Unused. ! * @return the UDP message ! * @version v0.20 ! */ ! ! public String getUDP_message() ! { ! return UDP_message; ! } ! ! /** ! * This method returns integer describing UDP message length ! * @author gift ! * @param Unused. ! * @return the length of UDP message. ! * @version v0.20 ! */ ! ! public int getUDP_MessageLength() ! { ! return UDP_MessageLength; ! } ! ! /** ! * This method sets mMessageCode ! * @author gift ! * @param the value to be set as mMessageCode ! * @return Nothing. ! * @version v0.20 ! */ ! public void setMessageCode(int inCode) ! { ! mMessageCode = inCode; ! } ! ! /** ! * This method gets mMessageCode ! * @author gift ! * @param Unused. ! * @return message code. ! * @version v0.20 ! */ ! public int getMessageCode() ! { ! return mMessageCode; ! } ! ! ! }//EOF ! |
From: gift <gi...@us...> - 2005-11-16 20:25:55
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17792/core Modified Files: CommunicationException.java Added Files: TransportLayerException.java Log Message: well this is first thing I've done on CVS ;) Index: CommunicationException.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/CommunicationException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CommunicationException.java 8 Nov 2005 15:35:29 -0000 1.1 --- CommunicationException.java 16 Nov 2005 20:25:40 -0000 1.2 *************** *** 1,53 **** ! /* ! 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; ! ! /** ! * Communication Exception Class that extends from the Simulation Exception ! * class ! * @author bevan_calliess ! * @author angela_brown ! * @param inExceptionMsg The Exception Message ! * @version v0.20 ! */ ! ! public class CommunicationException extends SimulationException{ ! public CommunicationException(String inExceptionMsg) { ! super(inExceptionMsg); ! } ! /** ! * @author angela_brown ! * @author bevan_calliess ! * @return exceptionMsg ! * @version v0.20 ! */ ! public String toString(){ ! return exceptionMsg; ! } ! ! } --- 1,106 ---- ! /* ! ! 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; ! ! ! ! /** ! ! * Communication Exception Class that extends from the Simulation Exception ! ! * class ! ! * @author bevan_calliess ! ! * @author angela_brown ! ! * @param inExceptionMsg The Exception Message ! ! * @version v0.20 ! ! */ ! ! ! ! public class CommunicationException extends SimulationException{ ! ! public CommunicationException(String inExceptionMsg) { ! ! super(inExceptionMsg); ! ! } ! ! /** ! ! * @author angela_brown ! ! * @author bevan_calliess ! ! * @return exceptionMsg ! ! * @version v0.20 ! ! */ ! ! public String toString(){ ! ! return exceptionMsg; ! ! } ! ! ! ! } ! --- NEW FILE: TransportLayerException.java --- /* 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. */ /* * TransportLayerException.java * * Created on 16 November 2005, 22:41 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package core; /** * * @author gift * @param inExceptionMsg The Exception Message * @version v0.10 */ public class TransportLayerException extends SimulationException { /** Creates a new instance of TransportLayerException */ public TransportLayerException(String inExceptionMsg) { super(inExceptionMsg); } /** * @author gift * @return exceptionMsg * @version v0.10 */ public String toString() { return exceptionMsg; } } |
From: gift <gi...@us...> - 2005-11-15 19:35:30
|
Update of /cvsroot/javanetsim/javaNetSim/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11820/images Added Files: firewall.gif Log Message: --- NEW FILE: firewall.gif --- (This appears to be a binary file; contents omitted.) |