src/routing/aodv/model/aodv-neighbor.cc
author Josh Pelkey <jpelkey@gatech.edu>
Sun, 27 Feb 2011 01:00:17 -0500
changeset 6841 174e599d1003
permissions -rw-r--r--
modularize nix and aodv, thanks lalith
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6841
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     2
/*
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     4
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     8
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    13
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    17
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    18
 * Based on
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    19
 *      NS-2 AODV model developed by the CMU/MONARCH group and optimized and
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    20
 *      tuned by Samir Das and Mahesh Marina, University of Cincinnati;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    21
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    22
 *      AODV-UU implementation by Erik Nordström of Uppsala University
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    23
 *      http://core.it.uu.se/core/index.php/AODV-UU
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    24
 *
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    25
 * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    26
 *          Pavel Boyko <boyko@iitp.ru>
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    27
 */
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    28
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    29
#include "aodv-neighbor.h"
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    30
#include "ns3/log.h"
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    31
#include <algorithm>
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    32
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    33
NS_LOG_COMPONENT_DEFINE ("AodvNeighbors");
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    34
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    35
namespace ns3
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    36
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    37
namespace aodv
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    38
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    39
Neighbors::Neighbors (Time delay) : 
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    40
  m_ntimer (Timer::CANCEL_ON_DESTROY)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    41
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    42
  m_ntimer.SetDelay(delay);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    43
  m_ntimer.SetFunction(&Neighbors::Purge, this);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    44
  m_txErrorCallback = MakeCallback (& Neighbors::ProcessTxError, this);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    45
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    46
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    47
bool
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    48
Neighbors::IsNeighbor (Ipv4Address addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    49
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    50
  Purge ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    51
  for (std::vector<Neighbor>::const_iterator i = m_nb.begin ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    52
      i != m_nb.end (); ++i)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    53
    {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    54
      if (i->m_neighborAddress == addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    55
        return true;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    56
    }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    57
  return false;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    58
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    59
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    60
Time
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    61
Neighbors::GetExpireTime (Ipv4Address addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    62
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    63
  Purge ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    64
  for (std::vector<Neighbor>::const_iterator i = m_nb.begin (); i
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    65
      != m_nb.end (); ++i)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    66
    {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    67
      if (i->m_neighborAddress == addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    68
        return (i->m_expireTime - Simulator::Now ());
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    69
    }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    70
  return Seconds (0);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    71
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    72
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    73
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    74
Neighbors::Update (Ipv4Address addr, Time expire)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    75
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    76
  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    77
    if (i->m_neighborAddress == addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    78
      {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    79
        i->m_expireTime
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    80
            = std::max (expire + Simulator::Now (), i->m_expireTime);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    81
        if (i->m_hardwareAddress == Mac48Address ())
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    82
          i->m_hardwareAddress = LookupMacAddress (i->m_neighborAddress);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    83
        return;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    84
      }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    85
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    86
  NS_LOG_LOGIC ("Open link to " << addr);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    87
  Neighbor neighbor (addr, LookupMacAddress (addr), expire + Simulator::Now ());
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    88
  m_nb.push_back (neighbor);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    89
  Purge ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    90
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    91
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    92
struct CloseNeighbor
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    93
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    94
  bool operator() (const Neighbors::Neighbor & nb) const
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    95
  {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    96
    return ((nb.m_expireTime < Simulator::Now ()) || nb.close);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    97
  }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    98
};
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    99
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   100
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   101
Neighbors::Purge ()
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   102
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   103
  if (m_nb.empty ())
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   104
    return;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   105
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   106
  CloseNeighbor pred;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   107
  if (!m_handleLinkFailure.IsNull ())
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   108
    {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   109
      for (std::vector<Neighbor>::iterator j = m_nb.begin (); j != m_nb.end (); ++j)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   110
        {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   111
          if (pred (*j))
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   112
            {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   113
              NS_LOG_LOGIC ("Close link to " << j->m_neighborAddress);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   114
              m_handleLinkFailure (j->m_neighborAddress);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   115
            }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   116
        }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   117
    }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   118
  m_nb.erase (std::remove_if (m_nb.begin (), m_nb.end (), pred), m_nb.end ());
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   119
  m_ntimer.Cancel ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   120
  m_ntimer.Schedule ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   121
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   122
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   123
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   124
Neighbors::ScheduleTimer ()
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   125
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   126
  m_ntimer.Cancel ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   127
  m_ntimer.Schedule ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   128
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   129
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   130
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   131
Neighbors::AddArpCache (Ptr<ArpCache> a)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   132
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   133
  m_arp.push_back (a);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   134
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   135
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   136
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   137
Neighbors::DelArpCache (Ptr<ArpCache> a)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   138
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   139
  m_arp.erase (std::remove (m_arp.begin (), m_arp.end (), a), m_arp.end ());
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   140
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   141
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   142
Mac48Address
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   143
Neighbors::LookupMacAddress (Ipv4Address addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   144
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   145
  Mac48Address hwaddr;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   146
  for (std::vector<Ptr<ArpCache> >::const_iterator i = m_arp.begin ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   147
      i != m_arp.end (); ++i)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   148
    {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   149
      ArpCache::Entry * entry = (*i)->Lookup (addr);
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   150
      if (entry != 0 && entry->IsAlive () && !entry->IsExpired ())
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   151
        {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   152
          hwaddr = Mac48Address::ConvertFrom (entry->GetMacAddress ());
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   153
          break;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   154
        }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   155
    }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   156
  return hwaddr;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   157
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   158
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   159
void
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   160
Neighbors::ProcessTxError (WifiMacHeader const & hdr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   161
{
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   162
  Mac48Address addr = hdr.GetAddr1 ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   163
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   164
  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   165
    {
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   166
      if (i->m_hardwareAddress == addr)
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   167
        i->close = true;
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   168
    }
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   169
  Purge ();
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   170
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   171
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   172
}
174e599d1003 modularize nix and aodv, thanks lalith
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   173