http://hi.baidu.com/byzfz0818/blog/item/9f7b7d6413bbcdf8f63654f7.html
Archive for the ‘杂项’ Category
802.11帧格式参考资料
星期三, 28 10 月, 2009MAC参考资料
星期二, 27 10 月, 2009OMNeT++实现随机拓扑
星期二, 20 10 月, 2009核心代码如下:
MyOMNet.ned
network MyOMNeT
{
parameters:
int width; //布局宽
int height; //布局高
int numHosts; // number of hosts
@display(“bgi=maps/usa”);
submodules:
server: Server;
host[numHosts]: Host;
connections:
for i=0..numHosts-1 {
host[i].out –> { delay = 100ms; } –> server.in++;
}
}
Server.cc
void Server::initialize()
{
//设置网络布局大小
net = simulation.getModuleByPath(“MyOMNeT”);
if(!net) error(“net not found”);
//注释掉的方法需使用头文件中的全局变量
//net->getDisplayString().setTagArg(“bgb”, 0, width);
//net->getDisplayString().setTagArg(“bgb”, 1, height);
int width = net->par(“width”);
int height = net->par(“height”);
net->getDisplayString().setTagArg(“bgb”, 0, width);
net->getDisplayString().setTagArg(“bgb”, 1, height);
if (ev.isGUI())
getDisplayString().setTagArg(“i2″,0,”x_off”);
}
Host.h
//随机数种子
static long ltime = 0;
//块结构体
typedef struct _BLOCK {
int x;//x轴起始坐标,最初设计为const,但考虑到用户输入超过布局,故随机分配前判断并修改。
int y;//y轴起始坐标,同上。
int width;//宽,同上。
int height;//高,同上。
int num;//块内主机数
}BLOCK, *LPBLOCK;
//按块结构体设置各块参数,并修改.cc文件for循环中的i < 4为i < 当前块数。
BLOCK b[4] = {{0, 0, 100, 100, 1}, {0, 400, 100, 100, 1}, {400, 0, 100, 100, 1}, {400, 400, 100, 100, 1}};
Host.cc
void Host::initialize()
{
server = simulation.getModuleByPath(“server”);
if (!server) error(“server not found”);
if (ev.isGUI())
{
//块内随机
for(int i = 0; i < 4; i++)
{
//前面块内主机未完成随机分配,则不进行后面块内主机的随机分配。
if(0 != b[i].num)
{
//第一个主机进行随机分配时以当前时间为随机数种子,之后的随机数种子随机产生。
if(0 == ltime)
time(<ime);
srand(ltime);
//判断并修改超过布局大小的错误值
cModule* net = simulation.getModuleByPath(“MyOMNeT”);
if(!net) error(“net not found”);
int width = net->par(“width”);
int height = net->par(“height”);
if(b[i].x >= width) {
b[i].x = width – 1;
b[i].width = 1;
}
if(b[i].y >= height) {
b[i].y = height – 1;
b[i].height = 1;
}
if(b[i].x + b[i].width > width)
b[i].width = width – b[i].x;
if(b[i].y + b[i].height > height)
b[i].height = height – b[i].y;
//随机产生坐标和下一个随机数种子
long x = b[i].x + rand()%b[i].width;
long y = b[i].y + rand()%b[i].height;
ltime += rand();
this->getDisplayString().setTagArg(“p”,0,x);
this->getDisplayString().setTagArg(“p”,1,y);
b[i].num–;
break;
}
}
this->getDisplayString().setTagArg(“t”,2,”#808000″);
}
//cMessage *msg = new cMessage(“send”);
//sendDirect(msg, 10, 0, server->gate(“in”));
//send(msg, “out”);
//Sleep(500);如果使用当前时间为随机数种子,则需睡眠线程。
}
演示文档:OMNeT++实现随机拓扑
用例分析
星期四, 24 9 月, 2009http://hi.baidu.com/anqing/blog/item/d5c85c60d78c04d88cb10d41.html
http://hi.baidu.com/laopin10/blog/item/a4ca59f5c4949e67dcc47479.html
一个用例的特征:
一、这件事是相对独立的。
二、这件事的执行结果对参与者来说是可观测的和有意义的。
三、这件事必须由一个参与者发起。
新教务系统BUG
星期一, 31 8 月, 2009明早8点要选课,学校老教务系统的恶劣环境可是臭名昭著的,新教务系统貌似强点,今晚先探路。
BUG不明显,在此公布一个,可查任何学号在具体学期内存在的人的成绩。
先用自己的学号、密码登陆新教务系统http://xjwxt.***.cn:8042/student/。
登陆后,在不关闭登陆页面的前提下,在浏览器新窗口输入网址:
http://xjwxt.***.cn:8042/student/jiaowu/cjgl/xscjcxAction.do?method=getXscjxx&xnxqh=2008-2009-2&xh=
“=”后填写正确学号即可。
虽然用户名仍然是自己,但是成绩是别人的。现在,你不用用辅导员、学院甚至学校管理员的帐号就可以查看本年级、本年学院甚至本学校任何人的成绩了。