[Javanetsim-cvs] javaNetSim/core Link.java, 1.2, 1.3 NetworkInterfacePort.java, 1.3, 1.4
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-09-13 13:39:00
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28933/core Modified Files: Link.java NetworkInterfacePort.java Log Message: Fix dev tree; fixed Java 1.66 bug in Set TCP/IP Properties dialog. Index: NetworkInterfacePort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/NetworkInterfacePort.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NetworkInterfacePort.java 19 Nov 2005 21:53:51 -0000 1.3 --- NetworkInterfacePort.java 13 Sep 2007 13:38:52 -0000 1.4 *************** *** 1,103 **** ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterfacePort represents the physical interface between ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! * ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! * ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author bevan_valliess ! * @since 13 Nov 2004 ! * @version v0.20 ! */ ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! /** ! * Constructs a NetworkInterfacePort object with the name inName ! * and a reference to it's parent Node. ! * @author baven_calliess ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.20 ! */ ! protected NetworkInterfacePort(String inName, Node inParent) { ! super(inName,inParent); ! } ! ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * @author bevan_calliess ! * @param inPacket - The packet being recived by this port ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! parentNode.receivePacket(inPacket, name); ! return; ! } ! ! /** ! * This method sends a packet to a connected link Depending ! * it is used by the datalinkLayer devices to tansport ! * packets without any validation or data checking. ! * @author bevan_calliess ! * @author angela_brown ! * @param outPacket - A Packet ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException{ ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! EthernetLink temp = (EthernetLink)connectedLink; ! ! if(temp!=null){ ! temp.transportPacket(tempPacket,getSourceName()); ! } ! } ! ! /** ! * This method returns information about this InterfacePort ! * @author bevan_calliess ! * @return String - The details of Interface name Mac and Links ! * @version v0.20 ! */ ! protected String getDetails(){ ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! } ! }//EOF --- 1,103 ---- ! /* ! Java Firewall Simulator (jFirewallSim) ! ! Copyright (c) 2004, jFirewallSim development team All rights reserved. ! ! Redistribution and use in source and binary forms, with or without modification, are ! permitted provided that the following conditions are met: ! ! - Redistributions of source code must retain the above copyright notice, this list ! of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright notice, this list ! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! - Neither the name of the Canberra Institute of Technology nor the names of its ! contributors may be used to endorse or promote products derived from this software ! without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ! EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! package core; ! import java.io.Serializable; ! /** ! * A NetworkInterfacePort represents the physical interface between ! * a DataLinkLayerDevice and a physical Link (network cable). Think of it as a port ! * ! * <P>Different DataLinkLayerDevices can contain different numbers of NetworkInterfacesPorts. ! * A Hub often has 4 or 8 and a switch has 8, 16 or 32.</P> ! * ! * <P>In order for a DataLinkLayerDevice to be able to send or receive network information (packets), ! * there must be a Link (network cable) between at least 2 NetworkInterfaces.</P> ! * ! * <P>NetworkInterfacePotrs receive and send packets to and from DatalinkProtocols and ! * the Link object they are connected to.</P> ! * ! * @author bevan_valliess ! * @since 13 Nov 2004 ! * @version v0.20 ! */ ! ! public class NetworkInterfacePort extends NetworkInterface{ ! ! /** ! * Constructs a NetworkInterfacePort object with the name inName ! * and a reference to it's parent Node. ! * @author baven_calliess ! * @param inName - The name to give the NetworkInterface eg: eth0 ! * @param inParent - The Node that the NetworkInterface is to be added to, it's parent. ! * @version v0.20 ! */ ! protected NetworkInterfacePort(String inName, Node inParent) { ! super(inName,inParent); ! } ! ! ! /** ! * This method recevie a packet from a connected link and then pass it ! * to the node's protocolstack. Depending on the network any ! * testing of the packets headers may need to be inserted here. ! * @author bevan_calliess ! * @param inPacket - The packet being recived by this port ! * @version v0.20 ! */ ! protected void receivePacket(Packet inPacket) throws LowLinkException { ! parentNode.receivePacket(inPacket, name); ! return; ! } ! ! /** ! * This method sends a packet to a connected link Depending ! * it is used by the datalinkLayer devices to tansport ! * packets without any validation or data checking. ! * @author bevan_calliess ! * @author angela_brown ! * @param outPacket - A Packet ! * @version v0.20 ! */ ! protected void sendPacket(Packet outPacket) throws LowLinkException{ ! Ethernet_packet tempPacket = (Ethernet_packet)outPacket; ! EthernetLink temp = (EthernetLink)connectedLink; ! ! if(temp!=null){ ! temp.transportPacket(tempPacket,getSourceName()); ! } ! } ! ! /** ! * This method returns information about this InterfacePort ! * @author bevan_calliess ! * @return String - The details of Interface name Mac and Links ! * @version v0.20 ! */ ! protected String getDetails(){ ! return "Interface: "+name+"\t\tMAC: Not Applicable \t\t"+ getConnectLinkDetails(); ! } ! }//EOF Index: Link.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Link.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Link.java 19 Nov 2005 16:55:37 -0000 1.2 --- Link.java 13 Sep 2007 13:38:52 -0000 1.3 *************** *** 1,146 **** ! /* ! 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.*; ! ! /** ! * A Link represents the physical link between Nodes in a network. Think of it as ! * the network cable that connects (or links) Nodes together. ! * ! * <P>After adding Nodes to a network you need some way to connect them. The Link class ! * and the NetworkInterface class handle these connections between Nodes and the sending ! * of data between Nodes.</P> ! * ! * <P>Note: There are no distinctions between connections currently. There's no such thing as UTP cable or ! * Coax in our simulation but if this functionality were ever to be implemented you ! * will need to modify this class and the NetworkInterface class, perhaps simply by adding type attributes to ! * each with a check in the addInterface method.</P> ! * ! * @author tristan_veness (Original Author) ! * @author luke_hamilton ! * @since 14 June 2004 ! * @version v0.20 ! */ ! ! abstract class Link implements Serializable{ ! /** The interfaceList holds all of the NetworkInterfaces that are connected to the Link */ ! ! /** ! * @link aggregation <{core.NetworkInterface}> ! * @directed directed ! * @supplierCardinality 0..* ! */ ! java.util.Vector NetworkInterfaces = null; ! ! /** Name of the link */ ! protected String name; ! ! protected double sievingCoefficient; ! ! ! /** *TODO*: javaDoc ! * ! */ ! public double getSC(){ ! return sievingCoefficient; ! } ! ! ! /** *TODO*: javaDoc ! * ! */ ! public void setSC(double SC){ ! sievingCoefficient = SC; ! } ! ! /** ! * Constructs a Link with the specified name. Conceptually this will simply create a cable ! * not connected to anything. You need to call the addInterface() method to 'plug' the cable ! * in to NetworkInterfaces. ! * @author luke_hamilton ! * @param inName - The name to give the Link. eg: LINK1 ! * @version v0.20 ! **/ ! protected Link(String inName) { ! NetworkInterfaces = new Vector(); ! name = inName; ! sievingCoefficient = 100; ! } ! ! protected String getName() ! { ! return name; ! } ! ! /** ! * This method returns true is the link is not connected to any ! * network interface ! * @author luke_hamilton ! * @return boolean ! * @version v0.20 ! */ ! protected boolean isNotConnected() { ! if(NetworkInterfaces.isEmpty()){ ! return true; ! } ! return false; ! } ! ! /** ! * This method will disconnect the link from any connect networkinterfaces ! * and then remove them from is Vector ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void disconnectLink() { ! ! for (int i = 0; i < NetworkInterfaces.size(); i++) { ! NetworkInterface temp = (NetworkInterface)NetworkInterfaces.elementAt(i); ! temp.resetConnectedLink(); ! } ! NetworkInterfaces.removeAllElements(); ! ! } ! ! /** ! * Displays all the interfaces in the interface list through System.out.println() calls. ! * @author tristan_veness ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void displayDetails(){ ! System.out.println(name); ! for (int i = 0; i < NetworkInterfaces.size(); i++) { ! NetworkInterface NIC = (NetworkInterface)NetworkInterfaces.elementAt(i); ! System.out.println("Connection " +i+ " "+NIC.getDetails()); ! } ! } ! }//EOF --- 1,146 ---- ! /* ! 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.*; ! ! /** ! * A Link represents the physical link between Nodes in a network. Think of it as ! * the network cable that connects (or links) Nodes together. ! * ! * <P>After adding Nodes to a network you need some way to connect them. The Link class ! * and the NetworkInterface class handle these connections between Nodes and the sending ! * of data between Nodes.</P> ! * ! * <P>Note: There are no distinctions between connections currently. There's no such thing as UTP cable or ! * Coax in our simulation but if this functionality were ever to be implemented you ! * will need to modify this class and the NetworkInterface class, perhaps simply by adding type attributes to ! * each with a check in the addInterface method.</P> ! * ! * @author tristan_veness (Original Author) ! * @author luke_hamilton ! * @since 14 June 2004 ! * @version v0.20 ! */ ! ! abstract class Link implements Serializable{ ! /** The interfaceList holds all of the NetworkInterfaces that are connected to the Link */ ! ! /** ! * @link aggregation <{core.NetworkInterface}> ! * @directed directed ! * @supplierCardinality 0..* ! */ ! java.util.Vector NetworkInterfaces = null; ! ! /** Name of the link */ ! protected String name; ! ! protected double sievingCoefficient; ! ! ! /** *TODO*: javaDoc ! * ! */ ! public double getSC(){ ! return sievingCoefficient; ! } ! ! ! /** *TODO*: javaDoc ! * ! */ ! public void setSC(double SC){ ! sievingCoefficient = SC; ! } ! ! /** ! * Constructs a Link with the specified name. Conceptually this will simply create a cable ! * not connected to anything. You need to call the addInterface() method to 'plug' the cable ! * in to NetworkInterfaces. ! * @author luke_hamilton ! * @param inName - The name to give the Link. eg: LINK1 ! * @version v0.20 ! **/ ! protected Link(String inName) { ! NetworkInterfaces = new Vector(); ! name = inName; ! sievingCoefficient = 100; ! } ! ! protected String getName() ! { ! return name; ! } ! ! /** ! * This method returns true is the link is not connected to any ! * network interface ! * @author luke_hamilton ! * @return boolean ! * @version v0.20 ! */ ! protected boolean isNotConnected() { ! if(NetworkInterfaces.isEmpty()){ ! return true; ! } ! return false; ! } ! ! /** ! * This method will disconnect the link from any connect networkinterfaces ! * and then remove them from is Vector ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void disconnectLink() { ! ! for (int i = 0; i < NetworkInterfaces.size(); i++) { ! NetworkInterface temp = (NetworkInterface)NetworkInterfaces.elementAt(i); ! temp.resetConnectedLink(); ! } ! NetworkInterfaces.removeAllElements(); ! ! } ! ! /** ! * Displays all the interfaces in the interface list through System.out.println() calls. ! * @author tristan_veness ! * @author luke_hamilton ! * @version v0.20 ! */ ! protected void displayDetails(){ ! System.out.println(name); ! for (int i = 0; i < NetworkInterfaces.size(); i++) { ! NetworkInterface NIC = (NetworkInterface)NetworkInterfaces.elementAt(i); ! System.out.println("Connection " +i+ " "+NIC.getDetails()); ! } ! } ! }//EOF |