⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 多路径DSR
💻 TXT
字号:
Hello ns-users,

I have been working on modifying the DSR to enble the use of 2 same length
paths of same destination (similar length multipath). I will insert the portion
I modified in hope that it will help some users who are thinking of doing
multipath with DSR or even inserting manual paths into DSR. My coding can be
improved upon since I am only started using C++ when I started using ns :)

Okay, here is what need to be modified in /ns-2.27/dsr/dsragent.cc

--------------- dsragent.cc ---------------------------------
// We need to disable the prefer_default_flow or that will revert
// our given path back to the old single path
static const bool dsragent_prefer_default_flow = false;

// We should initially set verbose to 1 or true. This provides additional
// info in our trace file to see the flow of events/results in dsr.
static const int verbose = 1;

// My own static global definitions to catch all the address
// This was placed right after the static const int declaration at the
// top.
// The following variables are used to catch the address of the IDs of
// each node in the multipaths excluding source and dest nodes. Obviously
// I have not found a better way to do this. God doesn't seem to give
// address of neighbouring nodes too.
static ID nod1;
static ID nod2;
static ID nod3;
static ID nod5;
static ID nod6;
static ID nod7;
// The following variables were used to initialise multipath and to 
// alternate between paths.
static int counter = 0;
static int previous_pathTCP = 1;
static int previous_pathACK = 1;
// I added a portion of code to modify the following subroutine/program

void
DSRAgent::handlePktWithoutSR(SRPacket& p, bool retry)
.
.
  if (route_cache->findRoute(p.dest, p.route, 1))
    { // we've got a route...
// My modified coding in attempt to manual route for TCP agent at node 0
// and ACK reply at TCP sink at node 4. This is not the best 
// optimisation. But it works for now!
      hdr_cmn *cmh =  hdr_cmn::access(p.pkt);
      hdr_sr *srh =  hdr_sr::access(p.pkt);
      char *TCPdest = "4";
      char *TCPsource = "0";
      char *ACKdest = "0";
      char *ACKsource = "4";
      if (counter != 0) {
        // the following handles multipath for TCP packets
        if (strcmp(p.dest.dump(), TCPdest) == 0) {
          if (strcmp(net_id.dump(), TCPsource) == 0) {
            if (previous_pathTCP == 1) {
              // the following sets up the desired route manually.
              // This was made available by Bryan's tips in
              // http://www.geocities.com/b_j_hogan/
              // I created the route manually (Anyone got better ways?)
              Path new_route2 = p.route;
              new_route2.reset();
              new_route2.appendToPath(net_id);
              new_route2.appendToPath(nod7);
              new_route2.appendToPath(nod6);
              new_route2.appendToPath(nod5);
              new_route2.appendToPath(p.dest);
              p.route = new_route2;
              p.route.resetIterator();
              cmh->size() -= srh->size();
              p.route.fillSR(srh);
              previous_pathTCP++;
            }
            else {
              Path new_route1 = p.route;
              new_route1.reset();
              new_route1.appendToPath(net_id);
              new_route1.appendToPath(nod1);
              new_route1.appendToPath(nod2);
              new_route1.appendToPath(nod3);
              new_route1.appendToPath(p.dest);
              p.route = new_route1;
              p.route.resetIterator();
              cmh->size() -= srh->size();
              p.route.fillSR(srh);
              previous_pathTCP = 1;
            }
          }
        }
        // The following handles ACK packets for multipath
        // I have omitted this since it's the same for TCP packets but
        // different nodes for the routes etc..
      }
      counter++;
// =============================================================
// The following verbose will print out the route of the packet to 
// verify if the above code works.        
      if (verbose)
	trace("S$hit %.5f _%s_ %s -> %s %s",
	      Scheduler::instance().clock(), net_id.dump(),
	      p.src.dump(), p.dest.dump(), p.route.dump());      
.
.
// end of handlePktWithoutSR
// Next we go to where I catch the addressed for the nodes. This should
// catch all the address once a route request reaches the dest.
// This is not so good since it will always run but only only during 
// route request. But my simulation at this stage on requires 1 route 
// request throughout.

void
DSRAgent::handleRouteRequest(SRPacket &p)
  /* process a route request that isn't targeted at us */
.
.
    //=========================================
    // My coding to catch the address of all nodes in the multipath 
    // other than source and dest for TCP
    char *one = "1";
    char *two = "2";
    char *three = "3";
    char *five = "5";
    char *six = "6";
    char *seven = "7";
    if (strcmp(net_id.dump(), one) == 0) 
    {
      nod1 = net_id; 
    }
    if (strcmp(net_id.dump(), two) == 0) 
    {
      nod2 = net_id;  
    }
    if (strcmp(net_id.dump(), three) == 0) 
    {
      nod3 = net_id;
    }
    if (strcmp(net_id.dump(), five) == 0) 
    {
      nod5 = net_id;
    }
    if (strcmp(net_id.dump(), six) == 0) 
    {
      nod6 = net_id;
    }
    if (strcmp(net_id.dump(), seven) == 0) 
    {
      nod7 = net_id;
    }
    //=======================================


..................end of dsragent.cc........................

Okay, I recommend for complete multipath functionality using DSR. to modify
"findRoute" subroutine/function in /ns-2.27/dsr/mobicache.cc can be modified to
select multipaths instead of shortest path. Hence, the modified code in
"handlePktWithoutSR" above does not need to be implemented. I find that looking
at DSRAgent.cc does help a lot to understand how dsr works. Hope this helps
those who have been asking about multipath in wireless. I think DSR is better
since it does not involve considering other classifications such as in DSDV
(see the structure of DSR and DSDV in the manual).

Cheers.

==============================================================================================
==============================================================================================
can somebody explain the route structures
> corresponding to the node ids ? Studing the dump()
> method of Path class I realize that the construction
> of path is as follows:
>
>  *ptr++ = '[';
>   for (int c = 0 ; c < len ; c ++)
>     {
>       if (c == cur_index) *ptr++ = '(';
>       ptr += sprintf(ptr,"%s%s ",path[c].dump(), c ==
> cur_index ? ")" : "");
>     }
>   *ptr++ = ']';
>   *ptr++ = '\0';


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -