Commit 6a3a2564 authored by uahhx's avatar uahhx

sync

TODO: buffer behaviour check.
parent 6a4561df
......@@ -6,6 +6,8 @@ import java.util.HashSet;
import FunnelNetSim.Nodes.*;
import FunnelNetSim.Strategies.Strategy;
import javax.xml.crypto.Data;
public class FunnelNet {
private Strategy strategy;
......@@ -20,7 +22,7 @@ public class FunnelNet {
public final int realTimeConstraint = 10000; //RTC in ns
public final int nodeClock = 125; //node Clockspeed in MHz
public final int rtcCycles = (realTimeConstraint*nodeClock)/1000;
public final int rtcCycles = 12;//(realTimeConstraint*nodeClock)/1000; //warning: put this back
private int numDownConnections = 1;//7; //total number of connections is this+1
private int numSlaves = 1; //7*7*7*7;
......@@ -33,6 +35,11 @@ public class FunnelNet {
public HashSet<Node> allNodes = new HashSet<Node>();
public ArrayList<ArrayList<Node>> layerNodes= new ArrayList<ArrayList<Node>>();
public HashSet<DataPacket> livePackets = new HashSet<DataPacket>();
public HashSet<DataPacket> droppedPackets = new HashSet<DataPacket>();
public HashSet<DataPacket> rejectedPackets = new HashSet<DataPacket>();
public HashSet<DataPacket> successfulPackets = new HashSet<DataPacket>();
public static int packetCounter = 0;
public FunnelNet(Strategy strategy, int numSlaves, int numDownConnections, int minNetLayers) {
......
......@@ -187,6 +187,11 @@ public abstract class Node {
if (curSubBuf.limitReached() == subSendEnableM[i]) { //if the limit is reached and the sub is currently allowed to send (or vice versa), send control packet
subSendEnableM[i] = !curSubBuf.limitReached();
selectedMessage = new DataPacket(-1, parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART); //send StartStop K-Flagged segment.
if(SimHost.verbose || true) {
System.out.println(nodeID() + " SubBuffer no." + i + (subSendEnableM[i] ? " free again" : " reached limit"));
if (superIncDest == i)
System.out.println("!!!!! This blocked message " + (curSuperBuf.isEmpty() ? superIncoming.getPacketID() : curSuperBuf.lookAtBuffer().getPacketID()));
}
}
else if (!curSuperBuf.isEmpty() || superIncDest == i) {
selectedMessage = curSuperBuf.isEmpty() ? superIncoming : curSuperBuf.takeFromBuffer();
......@@ -299,4 +304,32 @@ public abstract class Node {
this.superSendEnableS ^= true;
return this.superSendEnableS;
}
public ArrayList<SlinkyBuffer<DataPacket>> getSuperBuffers() {
return superBuffers;
}
public LinkedList<DataPacket> getSuperIncomingLine() {
return superIncomingLine;
}
public DataPacket getSuperIncoming() {
return superIncoming;
}
public ArrayList<SlinkyBuffer<DataPacket>> getSubBuffers() {
return subBuffers;
}
public ArrayList<LinkedList<DataPacket>> getSubIncomingLines() {
return subIncomingLines;
}
public DataPacket[] getSubIncoming() {
return subIncoming;
}
public boolean isSuperSendEnableS() {
return superSendEnableS;
}
}
......@@ -18,9 +18,18 @@ public class SlaveNode extends Node {
@Override
public void tick() {
super.tick();
if (superIncoming != null)
System.out.println("--------- Message no. " + superIncoming.getPacketID() + " from " + superIncoming.getOrigin() +
" returned to " + getNodeNumber() + " after " + (parentNet.getCycleCounter()-superIncoming.getTimeStamp()) + " cycles");
if (superIncoming != null) {
if (SimHost.verbose)
System.out.println("--------- Message no. " + superIncoming.getPacketID() + " from " + superIncoming.getOrigin() +
" returned to " + getNodeNumber() + " after " + (parentNet.getCycleCounter() - superIncoming.getTimeStamp()) + " cycles");
parentNet.livePackets.remove(superIncoming);
if (superIncoming.getMState() == DataPacket.messageState.REJECTED)
parentNet.rejectedPackets.add(superIncoming);
else if (superIncoming.getMState() == DataPacket.messageState.PROCESSED)
parentNet.successfulPackets.add(superIncoming);
else
System.out.println("Returned packet was of unexpected mState " + superIncoming.getMState().toString());
}
}
public void tick(boolean spawnPacket) {
......@@ -32,12 +41,13 @@ public class SlaveNode extends Node {
public boolean createPacket() {
if (superBuffers.isEmpty() && superSendEnableS) {
DataPacket newPacket = new DataPacket(this.getNodeNumber(), parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.REGULAR);
parentNet.livePackets.add(newPacket);
send(newPacket, superNeighbor);
if (SimHost.verbose)
System.out.println("created new Packet");
return true;
}
if (SimHost.verbose)
//if (SimHost.verbose)
System.out.println("!!!!!!!!! could not create new Packet!");
return false;
......
......@@ -61,13 +61,13 @@ public class SlinkyBuffer<T> {
//return buffer.size() + 2*FunnelNet.packetLatency -1 >= FunnelNet.bufferSize; //this actually makes it hit the buffer limit, better be careful around that
boolean result = buffer.size() + 2*latency >= FunnelNet.bufferSize;
if (SimHost.verbose) {
if (result && !hitLimit)
System.out.println("######### " + this.toString() + " reached its limit");
else if (!result && hitLimit)
System.out.println("$$$$$$$$$ " + this.toString() + " clear again");
}
hitLimit = result;
// if (SimHost.verbose) {
// if (result && !hitLimit)
// System.out.println("######### " + this.toString() + " reached its limit");
// else if (!result && hitLimit)
// System.out.println("$$$$$$$$$ " + this.toString() + " clear again");
// }
// hitLimit = result;
return result;
}
......
......@@ -10,7 +10,7 @@ import java.io.IOException;
public class SimHost {
public static final boolean verbose = true;//true;
public static final boolean verbose = false;//true;
public static void main(String[] args) {
// for (int i = 0; i < 10; i++) {
......@@ -27,7 +27,7 @@ public class SimHost {
private static void run() {
//FunnelNet net = new FunnelNet(new TestStrategy());
//FunnelNet net = new FunnelNet(new TestStrategy(), 8, 2, 1);
FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 4, 2, 1);
FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 9, 2, 1);
PseudoGraphics graph = new PseudoGraphics();
graph.draw(net.layerNodes);
int a = 2;
......@@ -53,6 +53,11 @@ public class SimHost {
for (int i = b; i < c; i++) {
System.out.println(net.tickNet());
}
System.out.println("no of live packets: " + net.livePackets.size());
System.out.println("no of successful packets: " + net.successfulPackets.size());
System.out.println("no of rejected packets: " + net.rejectedPackets.size());
System.out.println("no of dropped packets: " + net.droppedPackets.size());
}
}
......@@ -11,9 +11,9 @@ public class PseudoGraphics {
for (int i = 0; i < layerList.size(); i++) {
ArrayList<Node> currentLayer = layerList.get(i);
for (int j = 0; j < currentLayer.size(); j++) {
Node currentNode = currentLayer.get(i);
Node currentNode = currentLayer.get(j);
if (currentNode != null) {
currentNode.getSubIncoming();
}
else if (SimHost.verbose)
System.out.println("Layer " + i + ", Node " + j + " is null.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment