Skip to content

Commit

Permalink
Added Statistics for Blocking Probability. Tested for a 5x5 mesh with…
Browse files Browse the repository at this point in the history
… 25 nodes, unidirectional flow with no local delivery and full peering.
  • Loading branch information
Anshul Thakur committed Nov 7, 2015
1 parent ef1c02d commit 93237ce
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 10 deletions.
7 changes: 5 additions & 2 deletions Random_Mesh_Analyser/Packet.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
hop_count;

wait_times;
delivered = 1; %Reached end node, or lost in blocking?
end

properties(Dependent=true)
Expand Down Expand Up @@ -68,8 +69,10 @@
age = current_time - round(obj.birth_time);
end

function destroy(obj)
notify(obj, 'deletePacket');
function destroy(obj, exception)
obj.delivered = ~exception;
notify(obj, 'deletePacket');
clear obj;
end
end

Expand Down
1 change: 1 addition & 0 deletions Random_Mesh_Analyser/Queue.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function add( obj, el )
if((obj.nextInsert - obj.nextRemove) == obj.capacity)
%Queue is full. Reject!
notify(obj, 'Drop');
el.destroy(1); %Exception is true
%error('Queue is full');
return;
end
Expand Down
19 changes: 17 additions & 2 deletions Random_Mesh_Analyser/Scheduler.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
servers;
free_servers;
queue;
free_server_count;
free_server_count;

num_dropped;
num_admitted;
end

% properties (Dependent=true)
Expand All @@ -24,10 +27,12 @@
obj.free_servers = stations;
obj.queue = queue;
obj.free_server_count = length(obj.free_servers);

end

function routeToServer(obj, queue)
%current_time = SimScheduler.getScheduler().getTime();
obj.num_admitted = obj.num_admitted +1;

%dequeue from object and assign to a server
if(obj.free_server_count > 0)
Expand All @@ -42,9 +47,15 @@ function routeToServer(obj, queue)
end
end

function dropPacket(obj, queue)
obj.num_dropped = obj.num_dropped +1;
end

function obj = JoinQueue(self, queue)
obj = addlistener(queue, 'Enqueue',...
obj(1) = addlistener(queue, 'Enqueue',...
@(src, ~)self.routeToServer(src));
obj(2) = addlistener(queue, 'Drop',...
@(src, ~)self.dropPacket(src));
end

function runScheduler(obj, station, ~)
Expand All @@ -67,6 +78,10 @@ function runScheduler(obj, station, ~)
obj = addlistener(station, 'serviceDone',...
@(src, data)self.runScheduler(src, data));
end

function p = getBlockingProbability(obj)
p = obj.num_dropped/(obj.num_dropped + obj.num_admitted);
end
end

end
Expand Down
38 changes: 36 additions & 2 deletions Random_Mesh_Analyser/SimScheduler.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
packet_lifetimes;
packet_hopcounts;
packet_wait_times;

num_packets_dropped = 0;
num_packets_delivered = 0;
end

properties (Access = private)
Expand Down Expand Up @@ -122,7 +125,11 @@ function PacketStatUpdate(obj, packet)
round(packet.hop_count)];
obj.packet_wait_times = [obj.packet_wait_times, ...
packet.wait_times];
clear packet;
if(~packet.delivered)
obj.num_packets_dropped = obj.num_packets_dropped +1;
else
obj.num_packets_delivered = obj.num_packets_delivered +1;
end
end

function hdl = RegisterPacketDestroy(obj, packet)
Expand Down Expand Up @@ -234,7 +241,34 @@ function visualizeServiceTime(obj, scope, id)
end
end


function p = getBlockingProbability(obj, scope, id)
if(strcmp(scope,'local'))
for i=1:length(obj.systems)
if(obj.systems{i}.id == id)
p = obj.systems{i}.getBlockingProbability();
fprintf('\n[Server %d]: Blocking Probability: %d',...
obj.systems{i}.id, p);
break;
end
end
elseif(strcmp(scope,'network'))
p = obj.num_packets_dropped/(obj.num_packets_dropped + ...
obj.num_packets_delivered);
fprintf('\nNetwork: Blocking Probability: %d', p);
else %Display all.
for i=1:length(obj.systems)
if(obj.systems{i}.id == id)
p = obj.systems{i}.getBlockingProbability();
fprintf('\n[Server %d]: Blocking Probability: %d',...
obj.systems{i}.id, p);
break;
end
end
p = obj.num_packets_dropped/(obj.num_packets_dropped + ...
obj.num_packets_delivered);
fprintf('\nNetwork: Blocking Probability: %d', p);
end
end

end

Expand Down
7 changes: 6 additions & 1 deletion Random_Mesh_Analyser/System.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
stations;
scheduler;
transmitter;
streams;
streams;
end

properties (Transient)
Expand Down Expand Up @@ -35,6 +35,7 @@

%Attach scheduler to queue
obj.queue_handle = obj.scheduler.JoinQueue(obj.queue);

%Attach scheduler and transmitter to servers
for i=1:length(obj.stations)
obj.server_handles{i} = ...
Expand Down Expand Up @@ -90,6 +91,10 @@ function installAdjacencies(obj, neighbours, drop_policy)
utilization(i) = 1 - (obj.stations{i}.idle_period/SimScheduler.getScheduler().getTime());
end
end

function p = getBlockingProbabilities(obj)
p = obj.scheduler.getBlockingProbability();
end
end

end
Expand Down
4 changes: 2 additions & 2 deletions Random_Mesh_Analyser/Transmit.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ function transmit(obj)
%drop packet
%fprintf('\n[%d][System %d]:Drop packet.',...
% current_time, obj.id);
packet.destroy();
packet.destroy(0);
end
else %If we can't drop, then determine if we have neighbours or not.
if(isempty(obj.neighbours))
%drop packet
%fprintf('\n[%d][System %d]:Drop packet.',...
% current_time, obj.id);
packet.destroy();
packet.destroy(0);
else
obj.neighbours{egress}.system.enqueue(packet);
end
Expand Down
3 changes: 2 additions & 1 deletion Random_Mesh_Analyser/simulateSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

%Install Systems on Grid
drop_policy = 'left'; %for no drop in non-edge nodes, or 'random'.
topology.installSystems(0, 2, drop_policy, [3 3]); %capacity(inf), num_servers per system, policy, rates
topology.installSystems(20, 2, drop_policy, [3 3]); %capacity(inf), num_servers per system, policy, rates

%Install Adjacencies
topology.installAdjacencies();
Expand Down Expand Up @@ -63,6 +63,7 @@

scheduler.getUtilization('network',0);

scheduler.getBlockingProbability('network',0);
%Cleanup the system.
scheduler.destroy();
topology.destroy();
Expand Down

0 comments on commit 93237ce

Please sign in to comment.