[Javanetsim-cvs] javaNetSim/core EthernetLink.java,1.3,1.4 Hub.java,1.2,1.3 Simulation.java,1.7,1.8
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-12-08 18:07:50
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13963/core Modified Files: EthernetLink.java Hub.java Simulation.java Log Message: Hub bug FIX, new save file format, route tables s/l and more... Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EthernetLink.java 20 Nov 2005 20:30:53 -0000 1.3 --- EthernetLink.java 8 Dec 2005 18:07:39 -0000 1.4 *************** *** 59,62 **** --- 59,71 ---- inSecondNodeInterface.setConnectedLink(this); } + + public EthernetLink(String inName, NetworkInterface inFirstNodeInterface, NetworkInterface inSecondNodeInterface, double sieveCoeff)throws InvalidLinkConnectionException { + super(inName); + NetworkInterfaces.add(inFirstNodeInterface); + NetworkInterfaces.add(inSecondNodeInterface); + inFirstNodeInterface.setConnectedLink(this); + inSecondNodeInterface.setConnectedLink(this); + this.setSC(sieveCoeff); + } /** Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Hub.java 20 Nov 2005 20:30:53 -0000 1.2 --- Hub.java 8 Dec 2005 18:07:39 -0000 1.3 *************** *** 100,109 **** } ! }catch(Throwable th) ! { sz=1; throw new LowLinkException("Hub buffer overflow (packet loop flood?)."); ! } ! } } } --- 100,114 ---- } ! ! }catch(Throwable th) ! { ! if(th.toString().contains("Packet lost due to physical link problems!")){ ! throw new LowLinkException(th.toString()); ! }else{ sz=1; throw new LowLinkException("Hub buffer overflow (packet loop flood?)."); ! } ! } ! } } } Index: Simulation.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Simulation.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Simulation.java 8 Dec 2005 16:45:08 -0000 1.7 --- Simulation.java 8 Dec 2005 18:07:39 -0000 1.8 *************** *** 607,611 **** * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { --- 607,611 ---- * @version v0.20 **/ ! public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface, String sieveCoeff) throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { *************** *** 622,626 **** //Create link and add it to hashtable ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2)); }else{ throw new InvalidNodeNameException("Invalid node name"); --- 622,626 ---- //Create link and add it to hashtable ! linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2, Double.valueOf(sieveCoeff).doubleValue())); }else{ throw new InvalidNodeNameException("Invalid node name"); *************** *** 630,633 **** --- 630,656 ---- } + public void addEthernetLink(String inLinkName,String inFirstNodeName,String inFirstNodeInterface,String inSecondNodeName,String inSecondNodeInterface) + throws InvalidLinkNameException, InvalidLinkConnectionException, InvalidNetworkInterfaceNameException, InvalidNodeNameException { + + if (!linkTable.containsKey(inLinkName)) { + + //test if node's exist within hashtable + if(nodeTable.containsKey(inFirstNodeName) && nodeTable.containsKey(inSecondNodeName)){ + Node tempNode1 = (Node) nodeTable.get(inFirstNodeName); + Node tempNode2 = (Node) nodeTable.get(inSecondNodeName); + + //Return NetworkInterface from Node objects + NetworkInterface interface1 = tempNode1.getNetworkInterface(inFirstNodeInterface); + NetworkInterface interface2 = tempNode2.getNetworkInterface(inSecondNodeInterface); + + //Create link and add it to hashtable + linkTable.put(inLinkName,new EthernetLink(inLinkName, interface1, interface2)); + }else{ + throw new InvalidNodeNameException("Invalid node name"); + } + } else + throw new InvalidLinkNameException("Link already exists with same name."); + } + /** * This method checks to see if the hash Table (nodeTable) is empty. If not |