Hii我生成了X个要在服务器周围的特定网络半径内均匀分布的节点数,如下所示。.NED文件中
network myNetwork
{
parameters:
double netR @unit(m) = default(1040.5m);
volatile double rndR = uniform(0,1);
volatile double rndTheta = uniform(0,1);
submodules:
server: Server{
netR = netR;
}
host[numHosts]: Host {
r= netR*(sqrt(rndR));
theta=2*3.14*rndTheta;
}
}
simple Host
{
parameters:
double r @unit(m);
double theta;
double x @unit(m)= r*cos(theta); // the x coordinate of the host
double y @unit(m) = r*sin(theta); // the y coordinate of the host
@display("p=$x,$y");
}
但是,随着节点数量的增加,主机在模拟器上的绘制错误。例如,如果numHosts = 1400,则一个节点超出了范围,如附图所示 [