Professional Documents
Culture Documents
Προσομοίωση Worms
Προσομοίωση Worms
.
. S=N-I.
()
(t) . =(t)
+dI
(.
), S
.
:
.
pc (logisticequation:
)
.
.
.
pc . =1000
randomscanning
.
.
pc (numericalanalysis).
.
( randomscanning) . ip.
: ) ip (randomip)
) 1 (dI=1)
.
( ,
).
,
.
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
<time.h>
<conio.h>
#include <math.h>
#define N 1000
int main()
{
int pc[N];
intcounter,i,j,id,step;
double b=0.03;
/*--------INITIALIZATIONS------*/
/*rand function initialization*/
srand(time(NULL));
/*pc[N] initialization*/
for (i=0;i<N;i++)
{
pc[i]=0;
}
/*first node infected*/
FILE *fptr = fop en("out.csv", "w");
id=rand()%1000;
pc[id]=1;
counter=1;
step=1;
/*-------------------------------------------*/
printf("%d - %d\n",step,counter);
while (counter<N)
{
fprintf(fptr,"%d;%d\n",step,counter);
step++;
inttmpCount = counter;
for (i=1;i<=tmpCount;i++)
{
int index = rand()%1000;
if (pc[index]==0)
{
counter++;
pc[index] = 1;
}
}
printf("%d - %d\n",step,counter);
}
fclose(fptr);
system("PAUSE");
return 0;
}
,
:
.
(g(I)). :
. 0
g(I) 0 g(I) .
(repairtime=r). (
)
.
r
0
.
.
r
r ,
r 0=r * +r
r(t)=r *e -t +r
:
r0
rt
random scanning
localpreferences. .
. .
, traffic,
bandwith .
, ,
.
.
. Hook
()
=f e xt -f 0
f i nt + f s (
To
d(x)
k i Hook.
:
|
, , .. 20x20
.
0,001.
4.000,
, .
,
.
(. 50.000 run, 0,001, criticalnum 4,000,
, 0,25 ).
c++
(, , sensor).
. ,
( sensor) (.. pc)
,
main .
main
.
.
L=mxm x
. .
.
.
,
.
.
(coverage) . coverage
C=
,
t t=t t.
c=
.