|
From: <bro...@us...> - 2008-02-26 04:39:22
|
Revision: 128
http://gridsim.svn.sourceforge.net/gridsim/?rev=128&view=rev
Author: brobergj
Date: 2008-02-25 20:39:24 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
*FlowBuffer now handles the Acks for FlowPackets, after they have been held the appropriate duration
Modified Paths:
--------------
branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java
Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java
===================================================================
--- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java 2008-02-25 01:14:13 UTC (rev 127)
+++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java 2008-02-26 04:39:24 UTC (rev 128)
@@ -35,7 +35,7 @@
private Link link_; // a link to this output entity
private double baudRate_; // baud rate of this entity
private final int SIZE = 8; // 1 byte in bits
- private static int pktID_; // unique packet ID counter
+ private static int pktID_ = 0; // packet ID counter
private Vector outPacketList_; // store a list of packets
private HashMap<Integer, Packet> activeFlows_; // stores a list of active Flows
private Random random_; // selects to which junk packets go to
@@ -63,7 +63,7 @@
link_ = null;
outPacketList_ = null;
activeFlows_ = null;
- pktID_ = 0;
+ //pktID_ = 0;
outPort_ = new Sim_port("output_buffer");
super.add_port(outPort_);
@@ -74,7 +74,7 @@
random_ = null;
hasStarted_ = false;
- System.out.println("Initialising FB id " + super.get_id() + " name " + super.get_name());
+ System.out.println("Initialising FlowBuffer id " + super.get_id() + " name " + super.get_name());
}
/**
@@ -307,6 +307,10 @@
System.out.println(super.get_name() + ".body(): updateForecast() + at time = " + GridSim.clock());
updateForecast(ev);
break;
+
+ case GridSimTags.FLOW_RETURN:
+ submitAckToLink(ev);
+ break;
default:
defaultSend(ev, gisID, statID, shutdownID);
@@ -328,6 +332,7 @@
private synchronized void checkForecast(Sim_event ev) {
int pktID = (Integer) ev.get_data(); // ID of flow to be checked
FlowPacket fp = null; // Reference to flow packet that needs forecast update
+ FlowPacket fpAck = null;
System.out.println(super.get_name() + ".checkForecast(): checking pkt id # " + pktID);
@@ -337,7 +342,23 @@
IO_data io = new IO_data( data, fp.getSize(),
outPort_.get_src());
super.sim_schedule(outPort_, GridSimTags.SCHEDULE_NOW, fp.getTag() , io.getData());
- activeFlows_.remove(pktID);
+ activeFlows_.remove(pktID);
+
+ // Send ack to source of flow
+ System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID())
+ + " heading to " + GridSim.getEntityName(fp.getDestID()));
+ int oldDestID = fp.getDestID();
+ int oldSrcID = fp.getSrcID();
+
+ IO_data ackData = new IO_data(fp.getData(), fp.getSize(), oldSrcID - 1);
+ fpAck = new FlowPacket(ackData,fp.getID(),fp.getSize(),GridSimTags.FLOW_RETURN,super.get_id(),
+ oldSrcID - 1, fp.getNetServiceType(), 1, 1);
+ fpAck.setRemSize(0);
+ fpAck.setStartTime(fp.getStartTime());
+ fpAck.setLatency(fp.getLatency());
+
+ super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_RETURN, fpAck);
+
} else {
System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed");
@@ -550,7 +571,7 @@
return;
}
- // Identify ID of an entity which acts as Input/Buffer
+/* // Identify ID of an entity which acts as Input/Buffer
// entity of destination entity
int id = GridSim.getEntityId( "Input_" +
Sim_system.get_entity(destId).get_name() );
@@ -569,7 +590,7 @@
// NOTE: Below is a deprecated method for SimJava 2
//super.sim_hold(communicationDelay);
- super.sim_process(communicationDelay);
+ super.sim_process(communicationDelay);*/
}
/**
@@ -611,7 +632,15 @@
pktID_++; // increments packet ID
outEnque(np, GridSimTags.SCHEDULE_NOW);
}
+
+ private synchronized void submitAckToLink(Sim_event ev)
+ {
+ FlowPacket fp = (FlowPacket)ev.get_data();
+ System.out.println("Sending flow packet ack to link at time = " + GridSim.clock() + " id is " + pktID_);
+ outEnque(fp, GridSimTags.SCHEDULE_NOW);
+ }
+
/**
* Creates many dummy or null packets
* @param size packet size (in bytes)
@@ -782,12 +811,6 @@
ping = true;
tag = GridSimTags.INFOPKT_SUBMIT;
}
-
- //if (np instanceof FlowPacket && np.getTag() == GridSimTags.FLOW_SUBMIT ) {
- // ((FlowPacket)np).addBaudRate( link_.getBaudRate() );
- // ((FlowPacket)np).addLatency( link_.getDelay() );
- //}
-
// if an entity tries to send a packet to itself
if ( np.getDestID() == outPort_.get_dest() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|