From: <bro...@us...> - 2008-02-26 04:47:42
|
Revision: 132 http://gridsim.svn.sourceforge.net/gridsim/?rev=132&view=rev Author: brobergj Date: 2008-02-25 20:47:39 -0800 (Mon, 25 Feb 2008) Log Message: ----------- *Added delay parameter so multiple instances can be created that start sending flows at different times. Modified Paths: -------------- branches/gridsim4.0-branch2/examples/FlowNetEx01/FlowNetUser.java Modified: branches/gridsim4.0-branch2/examples/FlowNetEx01/FlowNetUser.java =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx01/FlowNetUser.java 2008-02-26 04:45:39 UTC (rev 131) +++ branches/gridsim4.0-branch2/examples/FlowNetEx01/FlowNetUser.java 2008-02-26 04:47:39 UTC (rev 132) @@ -29,6 +29,7 @@ private String name_; // my entity name private String destName_; // destination name private int destID_; // destination id + private double wait_; // Delay until I begin sending /** Custom tag that denotes sending a message */ public static final int SEND_MSG = 1; @@ -43,7 +44,7 @@ * @throws Exception This happens when name is null or haven't * initialized GridSim. */ - public FlowNetUser(String name, String destName, Link link) throws Exception + public FlowNetUser(String name, String destName, Link link, double wait) throws Exception { super(name, link); @@ -54,12 +55,15 @@ this.myID_ = super.get_id(); // get the destination entity name - destName_ = destName; + this.destName_ = destName; + + // get the waiting time before sending + this.wait_ = wait; } - public FlowNetUser(String name, String destName) throws Exception + public FlowNetUser(String name, String destName, double wait) throws Exception { - // 10 485 760 bits = 10Mb + // 10,485,760 baud = 10Mb/s super(name, new FlowLink(name+"_link",10485760,450,Integer.MAX_VALUE)); // get this entity name from Sim_entity @@ -70,6 +74,9 @@ // get the destination entity name destName_ = destName; + + // get the waiting time before sending + this.wait_ = wait; } /** @@ -78,7 +85,7 @@ public void body() { int packetSize = 5242880; // packet size in bytes [5MB] - int size = 2; // number of packets sent + int size = 1; // number of packets sent int i = 0; // get the destination entity ID @@ -87,6 +94,7 @@ // sends messages over the other side of the link for (i = 0; i < size; i++) { + super.sim_pause(this.wait_); String msg = "Message_" + i; IO_data data = new IO_data(msg, packetSize, destID_); System.out.println(name_ + ".body(): Sending " + msg + @@ -96,7 +104,6 @@ super.send(super.output, GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_SUBMIT, data); - super.sim_pause(10); } //////////////////////////////////////////////////////// @@ -106,37 +113,16 @@ { // waiting for incoming event in the Input buffer obj = super.receiveEventObject(); - System.out.println(name_ + ".body(): Receives Ack for " + obj); + if (obj instanceof IO_data) { + System.out.println(name_ + ".body(): Receives Ack for " + ((IO_data)obj).getData()); + } } + // Wait for other FlowNetUser instances to finish + //super.sim_pause(600); - super.sim_pause(20); - //////////////////////////////////////////////////////// - // ping functionality - //InfoPacket pkt = null; - - // There are 2 ways to ping an entity: - // a. non-blocking call, i.e. - //super.ping(destID_, size); // (i) ping - //super.gridSimHold(10); // (ii) do something else - //pkt = super.getPingResult(); // (iii) get the result back - - // b. blocking call, i.e. ping and wait for a result - //System.out.println(name_ + ".body(): Sending ping,at time = " + GridSim.clock() ); - //pkt = super.pingBlockingCall(destID_, 1500); - - // print the result - //System.out.println("\n-------- " + name_ + " ----------------"); - //System.out.println(pkt); - //System.out.println("-------- " + name_ + " ----------------\n"); - - //////////////////////////////////////////////////////// - // sends back denoting end of simulation - - //super.gridSimHold(3000); - - + super.send(destID_, GridSimTags.SCHEDULE_NOW, GridSimTags.END_OF_SIMULATION); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |