From: <bro...@us...> - 2008-02-22 02:10:41
|
Revision: 123 http://gridsim.svn.sourceforge.net/gridsim/?rev=123&view=rev Author: brobergj Date: 2008-02-21 18:10:46 -0800 (Thu, 21 Feb 2008) Log Message: ----------- *Added comments and javadoc Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-02-22 02:10:33 UTC (rev 122) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-02-22 02:10:46 UTC (rev 123) @@ -7,7 +7,7 @@ * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * FlowLink.java - Simulates a network link + * FlowLink.java - Simulates a network link with active flows * */ @@ -23,7 +23,7 @@ /** - * This class enables flow level networking over a shared link. It is based + * This class enables flow level networking over a shared link. It is partially based * on SimpleLink.java by Gokul Poduval & Chen-Khong Tham * * @invariant $none @@ -34,7 +34,7 @@ public class FlowLink extends Link { private Vector q_; - private HashMap flows_; + private HashMap flows_; // Stores references to flows that are currently active on this link private double lastUpdateTime_; // a timer to denote the last update time private int inEnd1_; private int outEnd1_; @@ -225,7 +225,7 @@ } // process the received event - System.out.println(super.get_name() + ".body(): processEvent() + at time = " + GridSim.clock()); + System.out.println(super.get_name() + ".body(): processEvent() at time = " + GridSim.clock()); processEvent(ev); sim_completed(ev); } @@ -253,8 +253,7 @@ { case GridSimTags.PKT_FORWARD: // for normal packets case GridSimTags.JUNK_PKT: // for background traffic - case GridSimTags.FLOW_UPDATE: - System.out.println(super.get_name() + ".processEvent(): enque() + at time = " + GridSim.clock()); + System.out.println(super.get_name() + ".processEvent(): enque() at time = " + GridSim.clock()); enque(ev); break; @@ -328,7 +327,7 @@ } /** - * Puts an event into a queue and sends an internal event to itself + * Puts an event into a queue, sends an internal event to itself and registers the flow * @param ev a Sim_event object * @pre ev != null * @post $none @@ -341,6 +340,7 @@ sendInternalEvent(super.delay_ / super.MILLI_SEC); // delay in ms } + // Register passing flow as active on this link if (((Packet)ev.get_data()).getTag() == GridSimTags.FLOW_SUBMIT) { registerFlow((Packet)ev.get_data()); } @@ -379,12 +379,13 @@ if (np.getTag() == GridSimTags.FLOW_RETURN) { System.out.println("Dereg flow # " + np.getID() +" here"); + // Deregister passing flow as it is npw de-active on this link deregisterFlow(np); } // sends the packet super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); - System.out.println(super.get_name() + " deque() + at time = " + GridSim.clock()); + System.out.println(super.get_name() + ".deque() + at time = " + GridSim.clock()); } @@ -416,13 +417,13 @@ /** * Registers active flow to link, and link to flow - * active flows + * @param np a packet * @pre $none * @post $none */ private synchronized void registerFlow(Packet np) { - FlowPacket tempFlow; + FlowPacket tempFlow = null; // Add flow to link flows_.put(np.getID(), np ); @@ -450,11 +451,14 @@ GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID())); } } - - - } + /** + * Deregisters active flow on link + * @param np a packet + * @pre $none + * @post $none + */ private synchronized void deregisterFlow(Packet np) { FlowPacket fp = null; FlowPacket tempFlow; @@ -464,12 +468,12 @@ System.out.println(super.get_name() + ".deregisterFlow() success flow # " + np.getID() + " " + fp.getBandwidth_()); - // Check if this affects any existing flows + // Check if this affects any existing flows Iterator<Integer> flowsIter = flows_.keySet().iterator(); while(flowsIter.hasNext()) { tempFlow = (FlowPacket) flows_.get(flowsIter.next()); // If change in bandwidth affects an existing flow i.e. is > current bottleneck - // AND this link is the flow's bottleneck + // AND this link is the particular flow's bottleneck if (this.getBaudRate() > tempFlow.getBandwidth_() && tempFlow.getID() != np.getID() && tempFlow.getBottleneckID() == this.get_id()) { // Need to notify flow This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |