2010年1月14日星期四

2010年1月13日星期三

Range of nodes that affected on WirelessChannel

distCST_=550.0
radius=distCST+/*safety*/5=555.0

xmin = mn->X() - radius;
xmax = mn->X() + radius;
ymin = mn->Y() - radius;
ymax = mn->Y() + radius;

2010年1月6日星期三

struct if_head?

[ns] What's ifhead_.lh_first mean?

Hi,

> When I read ns source codes, in file channel.cc, I cannot understand
> the variable ifhead_.lh_first, what is it defined as?
> I know ifhead_ is a structor in c++, but can you tell me what's the
> detail of the structor? and what's ifhead_.lh_first ?

The if_head structure is defined in mac/phy.h (which is included by mac/channel.h)
as below.
--------------
58 LIST_HEAD(if_head, Phy);

LIST_HEAD macro is defined in lib/bsd-list.h as below.
--------------
92 /*
93 * List definitions.
94 */
95 #define LIST_HEAD(name, type) \
96 struct name { \
97 type *lh_first; /* first element */ \
98 }

So, if_head structure is defined as below.
--------------
struct if_head {
Phy *lh_first; /* first element */
}

So, ifhead.lh_first means "the firstly-added PHY element on this Channel."


A phy is added onto a channel by executing "addif" instance procedure of
the channel at TCL level. Below is the C++ code which is executed when
"addif" instance procedure is executed.

mac/channel.cc
--------------
98 int Channel::command(int argc, const char*const* argv)
99 {
100
101 if (argc == 3) {
102 TclObject *obj;
103
104 if( (obj = TclObject::lookup(argv[2])) == 0) {
105 fprintf(stderr, "%s lookup failed\n", argv[1]);
106 return TCL_ERROR;
107 }
108 if (strcmp(argv[1], "trace-target") == 0) {
109 trace_ = (Trace*) obj;
110 return (TCL_OK);
111 }
112 else if(strcmp(argv[1], "addif") == 0) {
113 ((Phy*) obj)->insertchnl(&ifhead_);
114 ((Phy*) obj)->setchnl(this);
115 return TCL_OK;
116 }

mac/phy.h
------------
87 // list of all network interfaces on a channel
88 Phy* nextchnl(void) const { return chnl_link_.le_next; }
89 inline void insertchnl(struct if_head *head) {
90 LIST_INSERT_HEAD(head, this, chnl_link_);
91 //channel_ = chnl;
92 }

lib/bsd-list.h
--------------
128 #define LIST_INSERT_HEAD(head, elm, field) { \
129 if (((elm)->field.le_next = (head)->lh_first) != NULL) \
130 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
131 (head)->lh_first = (elm); \
132 (elm)->field.le_prev = &(head)->lh_first; \
133 }


Could this be answer for your question?
Regards,
masuto

2009年12月24日星期四

Writing is for Thinking Better (转)

GT的Google Reader shared items 中总有一些很好的博客、网站链接,今天又发现了一个——Mind hacks (http://mindhacks.cn/).该博客中有许多有关学习和思维方法的文章,读了几篇感觉很受益。

在《书写是为了更好的思考》一文中,作者阐述了书写对于思考的帮助。正如作者所说:“很多人不书写的原因是觉得没有什么可写的”,可是“你越是不开始书写,总是拿有限的思维缓存去默想一个问题,就越是没有内容可以写,如果你逼着自己将一些不成熟的想法写下来,看着自己写的内容,试着进一步拓展它们,就有可能在理性的道路上走得很远,很远”

书写是为了更好的思考

“我经常在走路和睡前总结所学过的内容,思考遗留的问题,一段时间的阅读和思考之后,一个总体的知识框架就会逐渐浮现在脑海中。然后我会将它书写下来,然而,我往往非常惊讶地发现,当我书写的时候,新的内容仍然源源不断的冒出来,就像我的键盘自己也会思考一样。”

……
书写的好处有以下几点:

* 书写是对思维的备忘:……
* 书写是与自己的对话:……
* 书写是与别人的交流:……
* 有时候,语言自己也会思考:……


在开始书写你的想法之前,我知道很多人不书写的原因是因为觉得没有什么可写的,其实这是一个怪圈,你越是不开始书写,总是拿有限的思维缓存去默想一个问题,就越是没有内容可以写,如果你逼着自己将一些不成熟的想法写下来,看着自己写的内容,试着进一步拓展它们,就有可能在理性的道路上走得很远,很远。
……

2009年12月18日星期五

make again after modifying ns-lib.tcl

Using ns, you should make again after modifying "ns-lib.tcl";otherwise, your modification with ns-lib.tcl will not be effective.

2009年12月11日星期五

NS2 2.31(2) 重新编译问题 make error with “proxytrace2any.cc”(转)

NS2 2.32 make error with “proxytrace2any.cc”

Problem: NS2 2.32 make error with “proxytrace2any.cc”
proxytrace2any.cc: In function `int main(int, char**)':
proxytrace2any.cc:112: error: `IsLittleEndian' undeclared (first use this function)
proxytrace2any.cc:112: error: (Each undeclared identifier is reported only once for each function it appears in.)
proxytrace2any.cc:120: error: `ToOtherEndian' undeclared (first use this function)


Solution:
Modify file “ns-allinone-2.32/ns-2.32/indep-utils/webtrace-conv/dec/my-endian.h”

-#ifndef _ENDIAN_H_
-#define _ENDIAN_H_
+#ifndef _MY_ENDIAN_H_
+#define _MY_ENDIAN_H_

note:- remove
+ add