Transcript project3QA

CDA6530: Performance Models of Computers and Networks
Project 3 Q&A


Structure definition in Matlab:


m = 300; n =300;
Node=struct('status', zeros(m,n), 'infectTime',
zeros(m,n), 'InfectOtherTime', zeros(m,n));
Or you can define:



NodeState = zeros(m,n);
NodeInfectTime = zeros(m,n);
NodeInfectOtherTime = zeros(m,n);
2
Multiple Way to Remember Infection Traffic

Define a queue variable to remember:



Generated infection traffic source (or
destination)
Active time (when the source passes the
traffic to all its neighbors, or when a vulnerble
node receives the traffic)
Quite complicated since the event queue
is very dynamic
3
Multiple Way to Remember Infection Traffic
(my approach)

Use each infected node variable to
remember when its outgoing infection
traffic reach its neighbors

NodeInfectOtherTime(i,j) save the time for infection
traffic reaching the node(i,j)’s neighbors
4

How to determine neighboring nodes?


You don’t need the code to remember the
topology since it is so regular
Node(a,b)’s 4 neighbors:
Upper node: (a-1,b), Down node: (a+1, b)
 Left node: (a,b-1), right node: (a, b+1)



Make sure you check if any of the above 4
nodes are non-exist
For S2, you also need to check if the node
is one of those 10 shortcut nodes

If yes, considering the 5th neighboring node
5

How to decide the simulation end time?

At current discrete time k, check all nodes:

If all (NodeInfectOtherTime(.,.) < k), then stop

It means there does not exist any future infection traffic
anymore
6
Infection Activity from
sending node angle

At current time t:

If the NodeState(j,k) == ‘infected’
If the NodeInfectOtherTime(j,k) == t,
%the node infection traffic reach its neighbors now!



Check all its neighbors to see if any neighbor is infected
now, if the neighbor node(a, b) is infected now:
 NodeState(a,b) = infected;
 NodeInfectTime(a,b) = t;
 generate Poisson distr. delay time x;
 NodeInfectOtherTime(a,b) = x +t +1;
If NodeState(j,k) == ‘vulnerable’

Do nothing
7
Two Actions for Every Infected Node

Act 1: when node(a,b) becomes infected at
current discrete time t


Change its status: NodeState(a,b) = INFECTED;
Assign:




NodeInfectTime(a,b) = t;
x = PoissonGenerator();
NodeInfectOtherTime(a,b) = t + x + 1;
Act 2: when an infected node delivers infection
traffic to its neighbors



When? if (NodeState(a,b) == INFECTED &&
t == NodeInfectOtherTime(a,b) )
Check each of its neighbor:
If neighbor node(c,d) is vulnerable and will be infected?

Run Act 1 for the node(c,d)
8
Record Your Simulation Time

startTime = cputime;

Run your simulation….

simulateCPUTime = cputime – startTime;
9