View | Details | Raw Unified | Return to bug 2246
Collapse All | Expand All

(-)a/src/dsr/examples/dsr.cc (-2 / +2 lines)
 Lines 66-74    Link Here 
66
  LogComponentEnable ("DsrFsHeader", LOG_LEVEL_ALL);
66
  LogComponentEnable ("DsrFsHeader", LOG_LEVEL_ALL);
67
  LogComponentEnable ("DsrGraReplyTable", LOG_LEVEL_ALL);
67
  LogComponentEnable ("DsrGraReplyTable", LOG_LEVEL_ALL);
68
  LogComponentEnable ("DsrSendBuffer", LOG_LEVEL_ALL);
68
  LogComponentEnable ("DsrSendBuffer", LOG_LEVEL_ALL);
69
  LogComponentEnable ("RouteCache", LOG_LEVEL_ALL);
69
  LogComponentEnable ("DsrRouteCache", LOG_LEVEL_ALL);
70
  LogComponentEnable ("DsrMaintainBuffer", LOG_LEVEL_ALL);
70
  LogComponentEnable ("DsrMaintainBuffer", LOG_LEVEL_ALL);
71
  LogComponentEnable ("RreqTable", LOG_LEVEL_ALL);
71
  LogComponentEnable ("DsrRreqTable", LOG_LEVEL_ALL);
72
  LogComponentEnable ("DsrErrorBuffer", LOG_LEVEL_ALL);
72
  LogComponentEnable ("DsrErrorBuffer", LOG_LEVEL_ALL);
73
  LogComponentEnable ("DsrNetworkQueue", LOG_LEVEL_ALL);
73
  LogComponentEnable ("DsrNetworkQueue", LOG_LEVEL_ALL);
74
#endif
74
#endif
(-)a/src/dsr/model/dsr-errorbuff.cc (-15 / +15 lines)
 Lines 43-59    Link Here 
43
namespace dsr {
43
namespace dsr {
44
44
45
uint32_t
45
uint32_t
46
ErrorBuffer::GetSize ()
46
DsrErrorBuffer::GetSize ()
47
{
47
{
48
  Purge ();
48
  Purge ();
49
  return m_errorBuffer.size ();
49
  return m_errorBuffer.size ();
50
}
50
}
51
51
52
bool
52
bool
53
ErrorBuffer::Enqueue (ErrorBuffEntry & entry)
53
DsrErrorBuffer::Enqueue (DsrErrorBuffEntry & entry)
54
{
54
{
55
  Purge ();
55
  Purge ();
56
  for (std::vector<ErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
56
  for (std::vector<DsrErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
57
       != m_errorBuffer.end (); ++i)
57
       != m_errorBuffer.end (); ++i)
58
    {
58
    {
59
      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
59
      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
 Lines 82-88    Link Here 
82
}
82
}
83
83
84
void
84
void
85
ErrorBuffer::DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop)
85
DsrErrorBuffer::DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop)
86
{
86
{
87
  NS_LOG_FUNCTION (this << source << nextHop);
87
  NS_LOG_FUNCTION (this << source << nextHop);
88
  Purge ();
88
  Purge ();
 Lines 93-99    Link Here 
93
  /*
93
  /*
94
   * Drop the packet with the error link source----------nextHop
94
   * Drop the packet with the error link source----------nextHop
95
   */
95
   */
96
  for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
96
  for (std::vector<DsrErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
97
       != m_errorBuffer.end (); ++i)
97
       != m_errorBuffer.end (); ++i)
98
    {
98
    {
99
      if (LinkEqual (*i, link))
99
      if (LinkEqual (*i, link))
 Lines 102-118    Link Here 
102
        }
102
        }
103
    }
103
    }
104
  m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (),
104
  m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (),
105
                                       std::bind2nd (std::ptr_fun (ErrorBuffer::LinkEqual), link)), m_errorBuffer.end ());
105
                                       std::bind2nd (std::ptr_fun (DsrErrorBuffer::LinkEqual), link)), m_errorBuffer.end ());
106
}
106
}
107
107
108
bool
108
bool
109
ErrorBuffer::Dequeue (Ipv4Address dst, ErrorBuffEntry & entry)
109
DsrErrorBuffer::Dequeue (Ipv4Address dst, DsrErrorBuffEntry & entry)
110
{
110
{
111
  Purge ();
111
  Purge ();
112
  /*
112
  /*
113
   * Dequeue the entry with destination address dst
113
   * Dequeue the entry with destination address dst
114
   */
114
   */
115
  for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i != m_errorBuffer.end (); ++i)
115
  for (std::vector<DsrErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i != m_errorBuffer.end (); ++i)
116
    {
116
    {
117
      if (i->GetDestination () == dst)
117
      if (i->GetDestination () == dst)
118
        {
118
        {
 Lines 126-137    Link Here 
126
}
126
}
127
127
128
bool
128
bool
129
ErrorBuffer::Find (Ipv4Address dst)
129
DsrErrorBuffer::Find (Ipv4Address dst)
130
{
130
{
131
  /*
131
  /*
132
   * Make sure if the send buffer contains entry with certain dst
132
   * Make sure if the send buffer contains entry with certain dst
133
   */
133
   */
134
  for (std::vector<ErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
134
  for (std::vector<DsrErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
135
       != m_errorBuffer.end (); ++i)
135
       != m_errorBuffer.end (); ++i)
136
    {
136
    {
137
      if (i->GetDestination () == dst)
137
      if (i->GetDestination () == dst)
 Lines 146-152    Link Here 
146
struct IsExpired
146
struct IsExpired
147
{
147
{
148
  bool
148
  bool
149
  operator() (ErrorBuffEntry const & e) const
149
  operator() (DsrErrorBuffEntry const & e) const
150
  {
150
  {
151
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
151
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
152
    return (e.GetExpireTime () < Seconds (0));
152
    return (e.GetExpireTime () < Seconds (0));
 Lines 154-167    Link Here 
154
};
154
};
155
155
156
void
156
void
157
ErrorBuffer::Purge ()
157
DsrErrorBuffer::Purge ()
158
{
158
{
159
  /*
159
  /*
160
   * Purge the buffer to eliminate expired entries
160
   * Purge the buffer to eliminate expired entries
161
   */
161
   */
162
  NS_LOG_DEBUG ("The error buffer size " << m_errorBuffer.size ());
162
  NS_LOG_DEBUG ("The error buffer size " << m_errorBuffer.size ());
163
  IsExpired pred;
163
  IsExpired pred;
164
  for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
164
  for (std::vector<DsrErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
165
       != m_errorBuffer.end (); ++i)
165
       != m_errorBuffer.end (); ++i)
166
    {
166
    {
167
      if (pred (*i))
167
      if (pred (*i))
 Lines 175-181    Link Here 
175
}
175
}
176
176
177
void
177
void
178
ErrorBuffer::Drop (ErrorBuffEntry en, std::string reason)
178
DsrErrorBuffer::Drop (DsrErrorBuffEntry en, std::string reason)
179
{
179
{
180
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
180
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
181
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
181
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
 Lines 184-190    Link Here 
184
}
184
}
185
185
186
void
186
void
187
ErrorBuffer::DropLink (ErrorBuffEntry en, std::string reason)
187
DsrErrorBuffer::DropLink (DsrErrorBuffEntry en, std::string reason)
188
{
188
{
189
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetSource () << " " << en.GetNextHop ());
189
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetSource () << " " << en.GetNextHop ());
190
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
190
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
(-)a/src/dsr/model/dsr-errorbuff.h (-14 / +14 lines)
 Lines 42-52    Link Here 
42
 * \ingroup dsr
42
 * \ingroup dsr
43
 * \brief DSR Error Buffer Entry
43
 * \brief DSR Error Buffer Entry
44
 */
44
 */
45
class ErrorBuffEntry
45
class DsrErrorBuffEntry
46
{
46
{
47
public:
47
public:
48
  /**
48
  /**
49
   * Create an ErrorBuffEntry with the given parameters.
49
   * Create an DsrErrorBuffEntry with the given parameters.
50
   *
50
   *
51
   * \param pa packet
51
   * \param pa packet
52
   * \param d IPv4 address of the destination
52
   * \param d IPv4 address of the destination
 Lines 55-61    Link Here 
55
   * \param exp expiration time
55
   * \param exp expiration time
56
   * \param p protocol number
56
   * \param p protocol number
57
   */
57
   */
58
  ErrorBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
58
  DsrErrorBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
59
                  Ipv4Address n = Ipv4Address (), Time exp = Simulator::Now (), uint8_t p = 0)
59
                  Ipv4Address n = Ipv4Address (), Time exp = Simulator::Now (), uint8_t p = 0)
60
    : m_packet (pa),
60
    : m_packet (pa),
61
      m_dst (d),
61
      m_dst (d),
 Lines 67-76    Link Here 
67
  }
67
  }
68
  /**
68
  /**
69
   * Compare send buffer entries
69
   * Compare send buffer entries
70
   * \param o another ErrorBuffEntry
70
   * \param o another DsrErrorBuffEntry
71
   * \return true if equal
71
   * \return true if equal
72
   */
72
   */
73
  bool operator== (ErrorBuffEntry const & o) const
73
  bool operator== (DsrErrorBuffEntry const & o) const
74
  {
74
  {
75
    return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
75
    return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
76
  }
76
  }
 Lines 145-163    Link Here 
145
 * \brief DSR error buffer
145
 * \brief DSR error buffer
146
 */
146
 */
147
/************************************************************************************************************************/
147
/************************************************************************************************************************/
148
class ErrorBuffer
148
class DsrErrorBuffer
149
{
149
{
150
public:
150
public:
151
  /**
151
  /**
152
   * Default constructor
152
   * Default constructor
153
   */
153
   */
154
  ErrorBuffer ()
154
  DsrErrorBuffer ()
155
  {
155
  {
156
  }
156
  }
157
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
157
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
158
  bool Enqueue (ErrorBuffEntry & entry);
158
  bool Enqueue (DsrErrorBuffEntry & entry);
159
  /// Return first found (the earliest) entry for given destination
159
  /// Return first found (the earliest) entry for given destination
160
  bool Dequeue (Ipv4Address dst, ErrorBuffEntry & entry);
160
  bool Dequeue (Ipv4Address dst, DsrErrorBuffEntry & entry);
161
  /// Remove all packets with the error link
161
  /// Remove all packets with the error link
162
  void DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop);
162
  void DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop);
163
  /// Finds whether a packet with destination dst exists in the queue
163
  /// Finds whether a packet with destination dst exists in the queue
 Lines 183-208    Link Here 
183
    m_errorBufferTimeout = t;
183
    m_errorBufferTimeout = t;
184
  }
184
  }
185
185
186
  std::vector<ErrorBuffEntry> & GetBuffer ()
186
  std::vector<DsrErrorBuffEntry> & GetBuffer ()
187
  {
187
  {
188
    return m_errorBuffer;
188
    return m_errorBuffer;
189
  }
189
  }
190
190
191
private:
191
private:
192
  /// The send buffer to cache unsent packet
192
  /// The send buffer to cache unsent packet
193
  std::vector<ErrorBuffEntry> m_errorBuffer;
193
  std::vector<DsrErrorBuffEntry> m_errorBuffer;
194
  /// Remove all expired entries
194
  /// Remove all expired entries
195
  void Purge ();
195
  void Purge ();
196
  /// Notify that packet is dropped from queue by timeout
196
  /// Notify that packet is dropped from queue by timeout
197
  void Drop (ErrorBuffEntry en, std::string reason);
197
  void Drop (DsrErrorBuffEntry en, std::string reason);
198
  /// Notify that packet is dropped from queue by timeout
198
  /// Notify that packet is dropped from queue by timeout
199
  void DropLink (ErrorBuffEntry en, std::string reason);
199
  void DropLink (DsrErrorBuffEntry en, std::string reason);
200
  /// The maximum number of packets that we allow a routing protocol to buffer.
200
  /// The maximum number of packets that we allow a routing protocol to buffer.
201
  uint32_t m_maxLen;
201
  uint32_t m_maxLen;
202
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
202
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
203
  Time m_errorBufferTimeout;
203
  Time m_errorBufferTimeout;
204
  /// Check if the send buffer entry is the same or not
204
  /// Check if the send buffer entry is the same or not
205
  static bool LinkEqual (ErrorBuffEntry en, const std::vector<Ipv4Address> link)
205
  static bool LinkEqual (DsrErrorBuffEntry en, const std::vector<Ipv4Address> link)
206
  {
206
  {
207
    return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
207
    return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
208
  }
208
  }
(-)a/src/dsr/model/dsr-gratuitous-reply-table.cc (-9 / +9 lines)
 Lines 39-67    Link Here 
39
  
39
  
40
namespace dsr {
40
namespace dsr {
41
41
42
NS_OBJECT_ENSURE_REGISTERED (GraReply);
42
NS_OBJECT_ENSURE_REGISTERED (DsrGraReply);
43
43
44
TypeId GraReply::GetTypeId ()
44
TypeId DsrGraReply::GetTypeId ()
45
{
45
{
46
  static TypeId tid = TypeId ("ns3::dsr::GraReply")
46
  static TypeId tid = TypeId ("ns3::dsr::DsrGraReply")
47
    .SetParent<Object> ()
47
    .SetParent<Object> ()
48
    .SetGroupName ("Dsr")
48
    .SetGroupName ("Dsr")
49
    .AddConstructor<GraReply> ()
49
    .AddConstructor<DsrGraReply> ()
50
  ;
50
  ;
51
  return tid;
51
  return tid;
52
}
52
}
53
53
54
GraReply::GraReply ()
54
DsrGraReply::DsrGraReply ()
55
{
55
{
56
}
56
}
57
57
58
GraReply::~GraReply ()
58
DsrGraReply::~DsrGraReply ()
59
{
59
{
60
  NS_LOG_FUNCTION_NOARGS ();
60
  NS_LOG_FUNCTION_NOARGS ();
61
}
61
}
62
62
63
bool
63
bool
64
GraReply::FindAndUpdate (Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
64
DsrGraReply::FindAndUpdate (Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
65
{
65
{
66
  Purge ();  // purge the gratuitous reply table
66
  Purge ();  // purge the gratuitous reply table
67
  for (std::vector<GraReplyEntry>::iterator i = m_graReply.begin ();
67
  for (std::vector<GraReplyEntry>::iterator i = m_graReply.begin ();
 Lines 78-91    Link Here 
78
}
78
}
79
79
80
bool
80
bool
81
GraReply::AddEntry (GraReplyEntry & graTableEntry)
81
DsrGraReply::AddEntry (GraReplyEntry & graTableEntry)
82
{
82
{
83
  m_graReply.push_back (graTableEntry);
83
  m_graReply.push_back (graTableEntry);
84
  return true;
84
  return true;
85
}
85
}
86
86
87
void
87
void
88
GraReply::Purge ()
88
DsrGraReply::Purge ()
89
{
89
{
90
  /*
90
  /*
91
   * Purge the expired gratuitous reply entries
91
   * Purge the expired gratuitous reply entries
(-)a/src/dsr/model/dsr-gratuitous-reply-table.h (-3 / +3 lines)
 Lines 62-75    Link Here 
62
 * \ingroup dsr
62
 * \ingroup dsr
63
 * \brief maintain the gratuitous reply
63
 * \brief maintain the gratuitous reply
64
 */
64
 */
65
class GraReply  : public Object
65
class DsrGraReply  : public Object
66
{
66
{
67
public:
67
public:
68
68
69
  static TypeId GetTypeId ();
69
  static TypeId GetTypeId ();
70
70
71
  GraReply ();
71
  DsrGraReply ();
72
  virtual ~GraReply ();
72
  virtual ~DsrGraReply ();
73
73
74
  /// Set the gratuitous reply table size
74
  /// Set the gratuitous reply table size
75
  void SetGraTableSize (uint32_t g)
75
  void SetGraTableSize (uint32_t g)
(-)a/src/dsr/model/dsr-maintain-buff.cc (-19 / +19 lines)
 Lines 43-59    Link Here 
43
namespace dsr {
43
namespace dsr {
44
44
45
uint32_t
45
uint32_t
46
MaintainBuffer::GetSize ()
46
DsrMaintainBuffer::GetSize ()
47
{
47
{
48
  Purge ();
48
  Purge ();
49
  return m_maintainBuffer.size ();
49
  return m_maintainBuffer.size ();
50
}
50
}
51
51
52
bool
52
bool
53
MaintainBuffer::Enqueue (MaintainBuffEntry & entry)
53
DsrMaintainBuffer::Enqueue (DsrMaintainBuffEntry & entry)
54
{
54
{
55
  Purge ();
55
  Purge ();
56
  for (std::vector<MaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
56
  for (std::vector<DsrMaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
57
       != m_maintainBuffer.end (); ++i)
57
       != m_maintainBuffer.end (); ++i)
58
    {
58
    {
59
//      NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our add " << i->GetOurAdd () << " " << entry.GetOurAdd ()
59
//      NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our add " << i->GetOurAdd () << " " << entry.GetOurAdd ()
 Lines 80-99    Link Here 
80
}
80
}
81
81
82
void
82
void
83
MaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop)
83
DsrMaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop)
84
{
84
{
85
  NS_LOG_FUNCTION (this << nextHop);
85
  NS_LOG_FUNCTION (this << nextHop);
86
  Purge ();
86
  Purge ();
87
  NS_LOG_INFO ("Drop Packet With next hop " << nextHop);
87
  NS_LOG_INFO ("Drop Packet With next hop " << nextHop);
88
  m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (),
88
  m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (),
89
                                          std::bind2nd (std::ptr_fun (MaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ());
89
                                          std::bind2nd (std::ptr_fun (DsrMaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ());
90
}
90
}
91
91
92
bool
92
bool
93
MaintainBuffer::Dequeue (Ipv4Address nextHop, MaintainBuffEntry & entry)
93
DsrMaintainBuffer::Dequeue (Ipv4Address nextHop, DsrMaintainBuffEntry & entry)
94
{
94
{
95
  Purge ();
95
  Purge ();
96
  for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i != m_maintainBuffer.end (); ++i)
96
  for (std::vector<DsrMaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i != m_maintainBuffer.end (); ++i)
97
    {
97
    {
98
      if (i->GetNextHop () == nextHop)
98
      if (i->GetNextHop () == nextHop)
99
        {
99
        {
 Lines 107-115    Link Here 
107
}
107
}
108
108
109
bool
109
bool
110
MaintainBuffer::Find (Ipv4Address nextHop)
110
DsrMaintainBuffer::Find (Ipv4Address nextHop)
111
{
111
{
112
  for (std::vector<MaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
112
  for (std::vector<DsrMaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
113
       != m_maintainBuffer.end (); ++i)
113
       != m_maintainBuffer.end (); ++i)
114
    {
114
    {
115
      if (i->GetNextHop () == nextHop)
115
      if (i->GetNextHop () == nextHop)
 Lines 122-130    Link Here 
122
}
122
}
123
123
124
bool
124
bool
125
MaintainBuffer::AllEqual (MaintainBuffEntry & entry)
125
DsrMaintainBuffer::AllEqual (DsrMaintainBuffEntry & entry)
126
{
126
{
127
  for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
127
  for (std::vector<DsrMaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
128
       != m_maintainBuffer.end (); ++i)
128
       != m_maintainBuffer.end (); ++i)
129
    {
129
    {
130
//      NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
130
//      NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
 Lines 143-151    Link Here 
143
}
143
}
144
144
145
bool
145
bool
146
MaintainBuffer::NetworkEqual (MaintainBuffEntry & entry)
146
DsrMaintainBuffer::NetworkEqual (DsrMaintainBuffEntry & entry)
147
{
147
{
148
  for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
148
  for (std::vector<DsrMaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
149
       != m_maintainBuffer.end (); ++i)
149
       != m_maintainBuffer.end (); ++i)
150
    {
150
    {
151
//      NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
151
//      NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
 Lines 164-173    Link Here 
164
}
164
}
165
165
166
bool
166
bool
167
MaintainBuffer::PromiscEqual (MaintainBuffEntry & entry)
167
DsrMaintainBuffer::PromiscEqual (DsrMaintainBuffEntry & entry)
168
{
168
{
169
  NS_LOG_DEBUG ("The maintenance buffer size " << m_maintainBuffer.size ());
169
  NS_LOG_DEBUG ("The maintenance buffer size " << m_maintainBuffer.size ());
170
  for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
170
  for (std::vector<DsrMaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
171
       != m_maintainBuffer.end (); ++i)
171
       != m_maintainBuffer.end (); ++i)
172
    {
172
    {
173
//      NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
173
//      NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
 Lines 187-196    Link Here 
187
}
187
}
188
188
189
bool
189
bool
190
MaintainBuffer::LinkEqual (MaintainBuffEntry & entry)
190
DsrMaintainBuffer::LinkEqual (DsrMaintainBuffEntry & entry)
191
{
191
{
192
  NS_LOG_DEBUG ("The maintenance buffer size " << m_maintainBuffer.size ());
192
  NS_LOG_DEBUG ("The maintenance buffer size " << m_maintainBuffer.size ());
193
  for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
193
  for (std::vector<DsrMaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
194
       != m_maintainBuffer.end (); ++i)
194
       != m_maintainBuffer.end (); ++i)
195
    {
195
    {
196
//      NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
196
//      NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
 Lines 212-218    Link Here 
212
struct IsExpired
212
struct IsExpired
213
{
213
{
214
  bool
214
  bool
215
  operator() (MaintainBuffEntry const & e) const
215
  operator() (DsrMaintainBuffEntry const & e) const
216
  {
216
  {
217
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
217
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
218
    return (e.GetExpireTime () < Seconds (0));
218
    return (e.GetExpireTime () < Seconds (0));
 Lines 220-226    Link Here 
220
};
220
};
221
221
222
void
222
void
223
MaintainBuffer::Purge ()
223
DsrMaintainBuffer::Purge ()
224
{
224
{
225
  NS_LOG_DEBUG ("Purging Maintenance Buffer");
225
  NS_LOG_DEBUG ("Purging Maintenance Buffer");
226
  IsExpired pred;
226
  IsExpired pred;
(-)a/src/dsr/model/dsr-maintain-buff.h (-13 / +13 lines)
 Lines 129-139    Link Here 
129
 * \ingroup dsr
129
 * \ingroup dsr
130
 * \brief DSR Maintain Buffer Entry
130
 * \brief DSR Maintain Buffer Entry
131
 */
131
 */
132
class MaintainBuffEntry
132
class DsrMaintainBuffEntry
133
{
133
{
134
public:
134
public:
135
  /**
135
  /**
136
   * Construct a MaintainBuffEntry with the given parameters
136
   * Construct a DsrMaintainBuffEntry with the given parameters
137
   *
137
   *
138
   * \param pa packet
138
   * \param pa packet
139
   * \param us our IPv4 address
139
   * \param us our IPv4 address
 Lines 144-150    Link Here 
144
   * \param segs number of segments left
144
   * \param segs number of segments left
145
   * \param exp expiration time
145
   * \param exp expiration time
146
   */
146
   */
147
  MaintainBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address us = Ipv4Address (),
147
  DsrMaintainBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address us = Ipv4Address (),
148
                     Ipv4Address n = Ipv4Address (), Ipv4Address s = Ipv4Address (), Ipv4Address dst = Ipv4Address (),
148
                     Ipv4Address n = Ipv4Address (), Ipv4Address s = Ipv4Address (), Ipv4Address dst = Ipv4Address (),
149
                     uint16_t ackId = 0, uint8_t segs = 0, Time exp = Simulator::Now ())
149
                     uint16_t ackId = 0, uint8_t segs = 0, Time exp = Simulator::Now ())
150
    : m_packet (pa),
150
    : m_packet (pa),
 Lines 247-265    Link Here 
247
 * \brief DSR maintain buffer
247
 * \brief DSR maintain buffer
248
 */
248
 */
249
/************************************************************************************************************************/
249
/************************************************************************************************************************/
250
class MaintainBuffer
250
class DsrMaintainBuffer
251
{
251
{
252
public:
252
public:
253
  /**
253
  /**
254
   * Default constructor
254
   * Default constructor
255
   */
255
   */
256
  MaintainBuffer ()
256
  DsrMaintainBuffer ()
257
  {
257
  {
258
  }
258
  }
259
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
259
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
260
  bool Enqueue (MaintainBuffEntry & entry);
260
  bool Enqueue (DsrMaintainBuffEntry & entry);
261
  /// Return first found (the earliest) entry for given destination
261
  /// Return first found (the earliest) entry for given destination
262
  bool Dequeue (Ipv4Address dst, MaintainBuffEntry & entry);
262
  bool Dequeue (Ipv4Address dst, DsrMaintainBuffEntry & entry);
263
  /// Remove all packets with destination IP address dst
263
  /// Remove all packets with destination IP address dst
264
  void DropPacketWithNextHop (Ipv4Address nextHop);
264
  void DropPacketWithNextHop (Ipv4Address nextHop);
265
  /// Finds whether a packet with destination dst exists in the queue
265
  /// Finds whether a packet with destination dst exists in the queue
 Lines 285-301    Link Here 
285
    m_maintainBufferTimeout = t;
285
    m_maintainBufferTimeout = t;
286
  }
286
  }
287
  /// Verify if all the elements in the maintainence buffer entry is the same
287
  /// Verify if all the elements in the maintainence buffer entry is the same
288
  bool AllEqual (MaintainBuffEntry & entry);
288
  bool AllEqual (DsrMaintainBuffEntry & entry);
289
  /// Verify if the maintain buffer entry is the same in every field for link ack
289
  /// Verify if the maintain buffer entry is the same in every field for link ack
290
  bool LinkEqual (MaintainBuffEntry & entry);
290
  bool LinkEqual (DsrMaintainBuffEntry & entry);
291
  /// Verify if the maintain buffer entry is the same in every field for network ack
291
  /// Verify if the maintain buffer entry is the same in every field for network ack
292
  bool NetworkEqual (MaintainBuffEntry & entry);
292
  bool NetworkEqual (DsrMaintainBuffEntry & entry);
293
  /// Verify if the maintain buffer entry is the same in every field for promiscuous ack
293
  /// Verify if the maintain buffer entry is the same in every field for promiscuous ack
294
  bool PromiscEqual (MaintainBuffEntry & entry);
294
  bool PromiscEqual (DsrMaintainBuffEntry & entry);
295
295
296
private:
296
private:
297
  /// The vector of maintain buffer entries
297
  /// The vector of maintain buffer entries
298
  std::vector<MaintainBuffEntry> m_maintainBuffer;
298
  std::vector<DsrMaintainBuffEntry> m_maintainBuffer;
299
  std::vector<NetworkKey> m_allNetworkKey;
299
  std::vector<NetworkKey> m_allNetworkKey;
300
  /// Remove all expired entries
300
  /// Remove all expired entries
301
  void Purge ();
301
  void Purge ();
 Lines 304-310    Link Here 
304
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
304
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
305
  Time m_maintainBufferTimeout;
305
  Time m_maintainBufferTimeout;
306
  /// Verify if the maintain buffer is equal or not
306
  /// Verify if the maintain buffer is equal or not
307
  static bool IsEqual (MaintainBuffEntry en, const Ipv4Address nextHop)
307
  static bool IsEqual (DsrMaintainBuffEntry en, const Ipv4Address nextHop)
308
  {
308
  {
309
    return (en.GetNextHop () == nextHop);
309
    return (en.GetNextHop () == nextHop);
310
  }
310
  }
(-)a/src/dsr/model/dsr-options.cc (-6 / +6 lines)
 Lines 609-618    Link Here 
609
  else
609
  else
610
    {
610
    {
611
      // A node ignores all RREQs received from any node in its blacklist
611
      // A node ignores all RREQs received from any node in its blacklist
612
      RouteCacheEntry toPrev;
612
      DsrRouteCacheEntry toPrev;
613
      bool isRouteInCache = dsr->LookupRoute (targetAddress,
613
      bool isRouteInCache = dsr->LookupRoute (targetAddress,
614
                                              toPrev);
614
                                              toPrev);
615
      RouteCacheEntry::IP_VECTOR ip = toPrev.GetVector (); // The route from our own route cache to dst
615
      DsrRouteCacheEntry::IP_VECTOR ip = toPrev.GetVector (); // The route from our own route cache to dst
616
      PrintVector (ip);
616
      PrintVector (ip);
617
      std::vector<Ipv4Address> saveRoute (nodeList);
617
      std::vector<Ipv4Address> saveRoute (nodeList);
618
      PrintVector (saveRoute);
618
      PrintVector (saveRoute);
 Lines 687-693    Link Here 
687
              bool addRoute = false;
687
              bool addRoute = false;
688
              if (numberAddress > 0)
688
              if (numberAddress > 0)
689
                {
689
                {
690
                  RouteCacheEntry toSource (/*IP_VECTOR=*/ m_finalRoute, /*dst=*/
690
                  DsrRouteCacheEntry toSource (/*IP_VECTOR=*/ m_finalRoute, /*dst=*/
691
                                                           dst, /*expire time=*/ ActiveRouteTimeout);
691
                                                           dst, /*expire time=*/ ActiveRouteTimeout);
692
                  if (dsr->IsLinkCache ())
692
                  if (dsr->IsLinkCache ())
693
                    {
693
                    {
 Lines 792-798    Link Here 
792
                  NS_LOG_DEBUG ("This is the route save in route cache");
792
                  NS_LOG_DEBUG ("This is the route save in route cache");
793
                  PrintVector (saveRoute);
793
                  PrintVector (saveRoute);
794
794
795
                  RouteCacheEntry toSource (/*IP_VECTOR=*/ saveRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
795
                  DsrRouteCacheEntry toSource (/*IP_VECTOR=*/ saveRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
796
                  NS_ASSERT (saveRoute.front () == ipv4Address);
796
                  NS_ASSERT (saveRoute.front () == ipv4Address);
797
                  // Add the route entry in the route cache
797
                  // Add the route entry in the route cache
798
                  if (dsr->IsLinkCache ())
798
                  if (dsr->IsLinkCache ())
 Lines 1039-1045    Link Here 
1039
       * The route looks like:
1039
       * The route looks like:
1040
       * \\ "srcAddress" + "intermediate node address" + "targetAddress"
1040
       * \\ "srcAddress" + "intermediate node address" + "targetAddress"
1041
       */
1041
       */
1042
      RouteCacheEntry toDestination (/*IP_VECTOR=*/ nodeList, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
1042
      DsrRouteCacheEntry toDestination (/*IP_VECTOR=*/ nodeList, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
1043
      NS_ASSERT (nodeList.front () == ipv4Address);
1043
      NS_ASSERT (nodeList.front () == ipv4Address);
1044
      bool addRoute = false;
1044
      bool addRoute = false;
1045
      if (dsr->IsLinkCache ())
1045
      if (dsr->IsLinkCache ())
 Lines 1106-1112    Link Here 
1106
        {
1106
        {
1107
          Ipv4Address dst = cutRoute.back ();
1107
          Ipv4Address dst = cutRoute.back ();
1108
          NS_LOG_DEBUG ("The route destination after cut " << dst);
1108
          NS_LOG_DEBUG ("The route destination after cut " << dst);
1109
          RouteCacheEntry toDestination (/*IP_VECTOR=*/ cutRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
1109
          DsrRouteCacheEntry toDestination (/*IP_VECTOR=*/ cutRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
1110
          NS_ASSERT (cutRoute.front () == ipv4Address);
1110
          NS_ASSERT (cutRoute.front () == ipv4Address);
1111
          bool addRoute = false;
1111
          bool addRoute = false;
1112
          if (dsr->IsLinkCache ())
1112
          if (dsr->IsLinkCache ())
(-)a/src/dsr/model/dsr-options.h (-7 / +7 lines)
 Lines 236-246    Link Here 
236
  /**
236
  /**
237
   * \brief The route request table.
237
   * \brief The route request table.
238
   */
238
   */
239
  Ptr<dsr::RreqTable> m_rreqTable;
239
  Ptr<dsr::DsrRreqTable> m_rreqTable;
240
  /**
240
  /**
241
   * \brief The route cache table.
241
   * \brief The route cache table.
242
   */
242
   */
243
  Ptr<dsr::RouteCache> m_routeCache;
243
  Ptr<dsr::DsrRouteCache> m_routeCache;
244
  /**
244
  /**
245
   * \brief The ipv4 route.
245
   * \brief The ipv4 route.
246
   */
246
   */
 Lines 346-352    Link Here 
346
  /**
346
  /**
347
   * \brief The route cache.
347
   * \brief The route cache.
348
   */
348
   */
349
  Ptr<dsr::RouteCache> m_routeCache;
349
  Ptr<dsr::DsrRouteCache> m_routeCache;
350
  /**
350
  /**
351
   * \brief The ipv4.
351
   * \brief The ipv4.
352
   */
352
   */
 Lines 382-388    Link Here 
382
  /**
382
  /**
383
   * \brief The route cache.
383
   * \brief The route cache.
384
   */
384
   */
385
  Ptr<dsr::RouteCache> m_routeCache;
385
  Ptr<dsr::DsrRouteCache> m_routeCache;
386
  /**
386
  /**
387
   * \brief The ip layer 3.
387
   * \brief The ip layer 3.
388
   */
388
   */
 Lines 461-467    Link Here 
461
  /**
461
  /**
462
   * \brief The route cache.
462
   * \brief The route cache.
463
   */
463
   */
464
  Ptr<dsr::RouteCache> m_routeCache;
464
  Ptr<dsr::DsrRouteCache> m_routeCache;
465
  /**
465
  /**
466
   * \brief The ipv4 layer 3.
466
   * \brief The ipv4 layer 3.
467
   */
467
   */
 Lines 497-503    Link Here 
497
  /**
497
  /**
498
   * \brief The route cache.
498
   * \brief The route cache.
499
   */
499
   */
500
  Ptr<dsr::RouteCache> m_routeCache;
500
  Ptr<dsr::DsrRouteCache> m_routeCache;
501
  /**
501
  /**
502
   * \brief The ipv4 layer 3.
502
   * \brief The ipv4 layer 3.
503
   */
503
   */
 Lines 533-539    Link Here 
533
  /**
533
  /**
534
   * \brief The route cache.
534
   * \brief The route cache.
535
   */
535
   */
536
  Ptr<dsr::RouteCache> m_routeCache;
536
  Ptr<dsr::DsrRouteCache> m_routeCache;
537
  /**
537
  /**
538
   * \brief The ipv4 layer 3.
538
   * \brief The ipv4 layer 3.
539
   */
539
   */
(-)a/src/dsr/model/dsr-passive-buff.cc (-21 / +21 lines)
 Lines 38-79    Link Here 
38
38
39
namespace ns3 {
39
namespace ns3 {
40
40
41
NS_LOG_COMPONENT_DEFINE ("PassiveBuffer");
41
NS_LOG_COMPONENT_DEFINE ("DsrPassiveBuffer");
42
  
42
  
43
namespace dsr {
43
namespace dsr {
44
44
45
NS_OBJECT_ENSURE_REGISTERED (PassiveBuffer);
45
NS_OBJECT_ENSURE_REGISTERED (DsrPassiveBuffer);
46
46
47
TypeId PassiveBuffer::GetTypeId ()
47
TypeId DsrPassiveBuffer::GetTypeId ()
48
{
48
{
49
  static TypeId tid = TypeId ("ns3::dsr::PassiveBuffer")
49
  static TypeId tid = TypeId ("ns3::dsr::DsrPassiveBuffer")
50
    .SetParent<Object> ()
50
    .SetParent<Object> ()
51
    .SetGroupName ("Dsr")
51
    .SetGroupName ("Dsr")
52
    .AddConstructor<PassiveBuffer> ()
52
    .AddConstructor<DsrPassiveBuffer> ()
53
  ;
53
  ;
54
  return tid;
54
  return tid;
55
}
55
}
56
56
57
PassiveBuffer::PassiveBuffer ()
57
DsrPassiveBuffer::DsrPassiveBuffer ()
58
{
58
{
59
}
59
}
60
60
61
PassiveBuffer::~PassiveBuffer ()
61
DsrPassiveBuffer::~DsrPassiveBuffer ()
62
{
62
{
63
}
63
}
64
64
65
uint32_t
65
uint32_t
66
PassiveBuffer::GetSize ()
66
DsrPassiveBuffer::GetSize ()
67
{
67
{
68
  Purge ();
68
  Purge ();
69
  return m_passiveBuffer.size ();
69
  return m_passiveBuffer.size ();
70
}
70
}
71
71
72
bool
72
bool
73
PassiveBuffer::Enqueue (PassiveBuffEntry & entry)
73
DsrPassiveBuffer::Enqueue (DsrPassiveBuffEntry & entry)
74
{
74
{
75
  Purge ();
75
  Purge ();
76
  for (std::vector<PassiveBuffEntry>::const_iterator i = m_passiveBuffer.begin (); i
76
  for (std::vector<DsrPassiveBuffEntry>::const_iterator i = m_passiveBuffer.begin (); i
77
       != m_passiveBuffer.end (); ++i)
77
       != m_passiveBuffer.end (); ++i)
78
    {
78
    {
79
//      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
79
//      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
 Lines 104-112    Link Here 
104
}
104
}
105
105
106
bool
106
bool
107
PassiveBuffer::AllEqual (PassiveBuffEntry & entry)
107
DsrPassiveBuffer::AllEqual (DsrPassiveBuffEntry & entry)
108
{
108
{
109
  for (std::vector<PassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i
109
  for (std::vector<DsrPassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i
110
       != m_passiveBuffer.end (); ++i)
110
       != m_passiveBuffer.end (); ++i)
111
    {
111
    {
112
//      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
112
//      NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
 Lines 126-138    Link Here 
126
}
126
}
127
127
128
bool
128
bool
129
PassiveBuffer::Dequeue (Ipv4Address dst, PassiveBuffEntry & entry)
129
DsrPassiveBuffer::Dequeue (Ipv4Address dst, DsrPassiveBuffEntry & entry)
130
{
130
{
131
  Purge ();
131
  Purge ();
132
  /*
132
  /*
133
   * Dequeue the entry with destination address dst
133
   * Dequeue the entry with destination address dst
134
   */
134
   */
135
  for (std::vector<PassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i != m_passiveBuffer.end (); ++i)
135
  for (std::vector<DsrPassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i != m_passiveBuffer.end (); ++i)
136
    {
136
    {
137
      if (i->GetDestination () == dst)
137
      if (i->GetDestination () == dst)
138
        {
138
        {
 Lines 146-157    Link Here 
146
}
146
}
147
147
148
bool
148
bool
149
PassiveBuffer::Find (Ipv4Address dst)
149
DsrPassiveBuffer::Find (Ipv4Address dst)
150
{
150
{
151
  /*
151
  /*
152
   * Make sure if the send buffer contains entry with certain dst
152
   * Make sure if the send buffer contains entry with certain dst
153
   */
153
   */
154
  for (std::vector<PassiveBuffEntry>::const_iterator i = m_passiveBuffer.begin (); i
154
  for (std::vector<DsrPassiveBuffEntry>::const_iterator i = m_passiveBuffer.begin (); i
155
       != m_passiveBuffer.end (); ++i)
155
       != m_passiveBuffer.end (); ++i)
156
    {
156
    {
157
      if (i->GetDestination () == dst)
157
      if (i->GetDestination () == dst)
 Lines 166-172    Link Here 
166
struct IsExpired
166
struct IsExpired
167
{
167
{
168
  bool
168
  bool
169
  operator() (PassiveBuffEntry const & e) const
169
  operator() (DsrPassiveBuffEntry const & e) const
170
  {
170
  {
171
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
171
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
172
    return (e.GetExpireTime () < Seconds (0));
172
    return (e.GetExpireTime () < Seconds (0));
 Lines 174-187    Link Here 
174
};
174
};
175
175
176
void
176
void
177
PassiveBuffer::Purge ()
177
DsrPassiveBuffer::Purge ()
178
{
178
{
179
  /*
179
  /*
180
   * Purge the buffer to eliminate expired entries
180
   * Purge the buffer to eliminate expired entries
181
   */
181
   */
182
  NS_LOG_DEBUG ("The passive buffer size " << m_passiveBuffer.size ());
182
  NS_LOG_DEBUG ("The passive buffer size " << m_passiveBuffer.size ());
183
  IsExpired pred;
183
  IsExpired pred;
184
  for (std::vector<PassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i
184
  for (std::vector<DsrPassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i
185
       != m_passiveBuffer.end (); ++i)
185
       != m_passiveBuffer.end (); ++i)
186
    {
186
    {
187
      if (pred (*i))
187
      if (pred (*i))
 Lines 195-201    Link Here 
195
}
195
}
196
196
197
void
197
void
198
PassiveBuffer::Drop (PassiveBuffEntry en, std::string reason)
198
DsrPassiveBuffer::Drop (DsrPassiveBuffEntry en, std::string reason)
199
{
199
{
200
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
200
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
201
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
201
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
 Lines 204-210    Link Here 
204
}
204
}
205
205
206
void
206
void
207
PassiveBuffer::DropLink (PassiveBuffEntry en, std::string reason)
207
DsrPassiveBuffer::DropLink (DsrPassiveBuffEntry en, std::string reason)
208
{
208
{
209
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetSource () << " " << en.GetNextHop ());
209
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetSource () << " " << en.GetNextHop ());
210
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
210
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
(-)a/src/dsr/model/dsr-passive-buff.h (-14 / +14 lines)
 Lines 42-52    Link Here 
42
 * \ingroup dsr
42
 * \ingroup dsr
43
 * \brief DSR Passive Buffer Entry
43
 * \brief DSR Passive Buffer Entry
44
 */
44
 */
45
class PassiveBuffEntry
45
class DsrPassiveBuffEntry
46
{
46
{
47
public:
47
public:
48
  /**
48
  /**
49
   * Construct a PassiveBuffEntry with the given parameters
49
   * Construct a DsrPassiveBuffEntry with the given parameters
50
   *
50
   *
51
   * \param pa packet
51
   * \param pa packet
52
   * \param d IPv4 address of the destination
52
   * \param d IPv4 address of the destination
 Lines 58-64    Link Here 
58
   * \param exp expiration time
58
   * \param exp expiration time
59
   * \param p protocol number
59
   * \param p protocol number
60
   */
60
   */
61
  PassiveBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
61
  DsrPassiveBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
62
                  Ipv4Address n = Ipv4Address (), uint16_t i = 0, uint16_t f = 0, uint8_t seg = 0, Time exp = Simulator::Now (),
62
                  Ipv4Address n = Ipv4Address (), uint16_t i = 0, uint16_t f = 0, uint8_t seg = 0, Time exp = Simulator::Now (),
63
                  uint8_t p = 0)
63
                  uint8_t p = 0)
64
    : m_packet (pa),
64
    : m_packet (pa),
 Lines 76-82    Link Here 
76
   * Compare send buffer entries
76
   * Compare send buffer entries
77
   * \return true if equal
77
   * \return true if equal
78
   */
78
   */
79
  bool operator== (PassiveBuffEntry const & o) const
79
  bool operator== (DsrPassiveBuffEntry const & o) const
80
  {
80
  {
81
    return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
81
    return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
82
  }
82
  }
 Lines 179-201    Link Here 
179
 * \brief DSR passive buffer
179
 * \brief DSR passive buffer
180
 */
180
 */
181
/************************************************************************************************************************/
181
/************************************************************************************************************************/
182
class PassiveBuffer  : public Object
182
class DsrPassiveBuffer  : public Object
183
{
183
{
184
public:
184
public:
185
185
186
  static TypeId GetTypeId ();
186
  static TypeId GetTypeId ();
187
187
188
  PassiveBuffer ();
188
  DsrPassiveBuffer ();
189
  virtual ~PassiveBuffer ();
189
  virtual ~DsrPassiveBuffer ();
190
190
191
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
191
  /// Push entry in queue, if there is no entry with the same packet and destination address in queue.
192
  bool Enqueue (PassiveBuffEntry & entry);
192
  bool Enqueue (DsrPassiveBuffEntry & entry);
193
  /// Return first found (the earliest) entry for given destination
193
  /// Return first found (the earliest) entry for given destination
194
  bool Dequeue (Ipv4Address dst, PassiveBuffEntry & entry);
194
  bool Dequeue (Ipv4Address dst, DsrPassiveBuffEntry & entry);
195
  /// Finds whether a packet with destination dst exists in the queue
195
  /// Finds whether a packet with destination dst exists in the queue
196
  bool Find (Ipv4Address dst);
196
  bool Find (Ipv4Address dst);
197
  /// Check if all the entries in passive buffer entry is all equal or not
197
  /// Check if all the entries in passive buffer entry is all equal or not
198
  bool AllEqual (PassiveBuffEntry & entry);
198
  bool AllEqual (DsrPassiveBuffEntry & entry);
199
  /// Number of entries
199
  /// Number of entries
200
  uint32_t GetSize ();
200
  uint32_t GetSize ();
201
201
 Lines 219-237    Link Here 
219
219
220
private:
220
private:
221
  /// The send buffer to cache unsent packet
221
  /// The send buffer to cache unsent packet
222
  std::vector<PassiveBuffEntry> m_passiveBuffer;
222
  std::vector<DsrPassiveBuffEntry> m_passiveBuffer;
223
  /// Remove all expired entries
223
  /// Remove all expired entries
224
  void Purge ();
224
  void Purge ();
225
  /// Notify that packet is dropped from queue by timeout
225
  /// Notify that packet is dropped from queue by timeout
226
  void Drop (PassiveBuffEntry en, std::string reason);
226
  void Drop (DsrPassiveBuffEntry en, std::string reason);
227
  /// Notify that packet is dropped from queue by timeout
227
  /// Notify that packet is dropped from queue by timeout
228
  void DropLink (PassiveBuffEntry en, std::string reason);
228
  void DropLink (DsrPassiveBuffEntry en, std::string reason);
229
  /// The maximum number of packets that we allow a routing protocol to buffer.
229
  /// The maximum number of packets that we allow a routing protocol to buffer.
230
  uint32_t m_maxLen;
230
  uint32_t m_maxLen;
231
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
231
  /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
232
  Time m_passiveBufferTimeout;
232
  Time m_passiveBufferTimeout;
233
  /// Check if the send buffer entry is the same or not
233
  /// Check if the send buffer entry is the same or not
234
  static bool LinkEqual (PassiveBuffEntry en, const std::vector<Ipv4Address> link)
234
  static bool LinkEqual (DsrPassiveBuffEntry en, const std::vector<Ipv4Address> link)
235
  {
235
  {
236
    return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
236
    return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));
237
  }
237
  }
(-)a/src/dsr/model/dsr-rcache.cc (-116 / +116 lines)
 Lines 49-59    Link Here 
49
49
50
namespace ns3 {
50
namespace ns3 {
51
51
52
NS_LOG_COMPONENT_DEFINE ("RouteCache");
52
NS_LOG_COMPONENT_DEFINE ("DsrRouteCache");
53
  
53
  
54
namespace dsr {
54
namespace dsr {
55
55
56
bool CompareRoutesBoth (const RouteCacheEntry &a, const RouteCacheEntry &b)
56
bool CompareRoutesBoth (const DsrRouteCacheEntry &a, const DsrRouteCacheEntry &b)
57
{
57
{
58
  // compare based on both with hop count considered priority
58
  // compare based on both with hop count considered priority
59
  return (a.GetVector ().size () < b.GetVector ().size ())
59
  return (a.GetVector ().size () < b.GetVector ().size ())
 Lines 61-73    Link Here 
61
  ;
61
  ;
62
}
62
}
63
63
64
bool CompareRoutesHops (const RouteCacheEntry &a, const RouteCacheEntry &b)
64
bool CompareRoutesHops (const DsrRouteCacheEntry &a, const DsrRouteCacheEntry &b)
65
{
65
{
66
  // compare based on hops
66
  // compare based on hops
67
  return a.GetVector ().size () < b.GetVector ().size ();
67
  return a.GetVector ().size () < b.GetVector ().size ();
68
}
68
}
69
69
70
bool CompareRoutesExpire (const RouteCacheEntry &a, const RouteCacheEntry &b)
70
bool CompareRoutesExpire (const DsrRouteCacheEntry &a, const DsrRouteCacheEntry &b)
71
{
71
{
72
  // compare based on expire time
72
  // compare based on expire time
73
  return a.GetExpireTime () > b.GetExpireTime ();
73
  return a.GetExpireTime () > b.GetExpireTime ();
 Lines 78-109    Link Here 
78
  NS_LOG_DEBUG (m_low << "----" << m_high);
78
  NS_LOG_DEBUG (m_low << "----" << m_high);
79
}
79
}
80
80
81
NodeStab::NodeStab (Time nodeStab)
81
DsrNodeStab::DsrNodeStab (Time nodeStab)
82
  : m_nodeStability (nodeStab + Simulator::Now ())
82
  : m_nodeStability (nodeStab + Simulator::Now ())
83
{
83
{
84
}
84
}
85
85
86
NodeStab::~NodeStab ()
86
DsrNodeStab::~DsrNodeStab ()
87
{
87
{
88
}
88
}
89
89
90
LinkStab::LinkStab (Time linkStab)
90
DsrLinkStab::DsrLinkStab (Time linkStab)
91
  : m_linkStability (linkStab + Simulator::Now ())
91
  : m_linkStability (linkStab + Simulator::Now ())
92
{
92
{
93
}
93
}
94
94
95
LinkStab::~LinkStab ()
95
DsrLinkStab::~DsrLinkStab ()
96
{
96
{
97
}
97
}
98
98
99
void LinkStab::Print ( ) const
99
void DsrLinkStab::Print ( ) const
100
{
100
{
101
  NS_LOG_LOGIC ("LifeTime: " << GetLinkStability ().GetSeconds ());
101
  NS_LOG_LOGIC ("LifeTime: " << GetLinkStability ().GetSeconds ());
102
}
102
}
103
103
104
typedef std::list<RouteCacheEntry>::value_type route_pair;
104
typedef std::list<DsrRouteCacheEntry>::value_type route_pair;
105
105
106
RouteCacheEntry::RouteCacheEntry (IP_VECTOR const  & ip, Ipv4Address dst, Time exp)
106
DsrRouteCacheEntry::DsrRouteCacheEntry (IP_VECTOR const  & ip, Ipv4Address dst, Time exp)
107
  : m_ackTimer (Timer::CANCEL_ON_DESTROY),
107
  : m_ackTimer (Timer::CANCEL_ON_DESTROY),
108
    m_dst (dst),
108
    m_dst (dst),
109
    m_path (ip),
109
    m_path (ip),
 Lines 114-150    Link Here 
114
{
114
{
115
}
115
}
116
116
117
RouteCacheEntry::~RouteCacheEntry ()
117
DsrRouteCacheEntry::~DsrRouteCacheEntry ()
118
{
118
{
119
}
119
}
120
120
121
void
121
void
122
RouteCacheEntry::Invalidate (Time badLinkLifetime)
122
DsrRouteCacheEntry::Invalidate (Time badLinkLifetime)
123
{
123
{
124
  m_reqCount = 0;
124
  m_reqCount = 0;
125
  m_expire = badLinkLifetime + Simulator::Now ();
125
  m_expire = badLinkLifetime + Simulator::Now ();
126
}
126
}
127
127
128
void
128
void
129
RouteCacheEntry::Print (std::ostream & os) const
129
DsrRouteCacheEntry::Print (std::ostream & os) const
130
{
130
{
131
  os << m_dst << "\t" << (m_expire - Simulator::Now ()).GetSeconds ()
131
  os << m_dst << "\t" << (m_expire - Simulator::Now ()).GetSeconds ()
132
     << "\t";
132
     << "\t";
133
}
133
}
134
134
135
NS_OBJECT_ENSURE_REGISTERED (RouteCache);
135
NS_OBJECT_ENSURE_REGISTERED (DsrRouteCache);
136
136
137
TypeId RouteCache::GetTypeId ()
137
TypeId DsrRouteCache::GetTypeId ()
138
{
138
{
139
  static TypeId tid = TypeId ("ns3::dsr::RouteCache")
139
  static TypeId tid = TypeId ("ns3::dsr::DsrRouteCache")
140
    .SetParent<Object> ()
140
    .SetParent<Object> ()
141
    .SetGroupName ("Dsr")
141
    .SetGroupName ("Dsr")
142
    .AddConstructor<RouteCache> ()
142
    .AddConstructor<DsrRouteCache> ()
143
  ;
143
  ;
144
  return tid;
144
  return tid;
145
}
145
}
146
146
147
RouteCache::RouteCache ()
147
DsrRouteCache::DsrRouteCache ()
148
  : m_vector (0),
148
  : m_vector (0),
149
    m_maxEntriesEachDst (3),
149
    m_maxEntriesEachDst (3),
150
    m_isLinkCache (false),
150
    m_isLinkCache (false),
 Lines 155-165    Link Here 
155
   * The timer to set layer 2 notification, not fully supported by ns3 yet
155
   * The timer to set layer 2 notification, not fully supported by ns3 yet
156
   */
156
   */
157
  m_ntimer.SetDelay (m_delay);
157
  m_ntimer.SetDelay (m_delay);
158
  m_ntimer.SetFunction (&RouteCache::PurgeMac, this);
158
  m_ntimer.SetFunction (&DsrRouteCache::PurgeMac, this);
159
  m_txErrorCallback = MakeCallback (&RouteCache::ProcessTxError, this);
159
  m_txErrorCallback = MakeCallback (&DsrRouteCache::ProcessTxError, this);
160
}
160
}
161
161
162
RouteCache::~RouteCache ()
162
DsrRouteCache::~DsrRouteCache ()
163
{
163
{
164
  NS_LOG_FUNCTION_NOARGS ();
164
  NS_LOG_FUNCTION_NOARGS ();
165
  // clear the route cache when done
165
  // clear the route cache when done
 Lines 167-173    Link Here 
167
}
167
}
168
168
169
void
169
void
170
RouteCache::RemoveLastEntry (std::list<RouteCacheEntry> & rtVector)
170
DsrRouteCache::RemoveLastEntry (std::list<DsrRouteCacheEntry> & rtVector)
171
{
171
{
172
  NS_LOG_FUNCTION (this);
172
  NS_LOG_FUNCTION (this);
173
  // Release the last entry of route list
173
  // Release the last entry of route list
 Lines 175-184    Link Here 
175
}
175
}
176
176
177
bool
177
bool
178
RouteCache::UpdateRouteEntry (Ipv4Address dst)
178
DsrRouteCache::UpdateRouteEntry (Ipv4Address dst)
179
{
179
{
180
  NS_LOG_FUNCTION (this << dst);
180
  NS_LOG_FUNCTION (this << dst);
181
  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i =
181
  std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::const_iterator i =
182
    m_sortedRoutes.find (dst);
182
    m_sortedRoutes.find (dst);
183
  if (i == m_sortedRoutes.end ())
183
  if (i == m_sortedRoutes.end ())
184
    {
184
    {
 Lines 187-194    Link Here 
187
    }
187
    }
188
  else
188
  else
189
    {
189
    {
190
      std::list<RouteCacheEntry> rtVector = i->second;
190
      std::list<DsrRouteCacheEntry> rtVector = i->second;
191
      RouteCacheEntry successEntry = rtVector.front ();
191
      DsrRouteCacheEntry successEntry = rtVector.front ();
192
      successEntry.SetExpireTime (RouteCacheTimeout);
192
      successEntry.SetExpireTime (RouteCacheTimeout);
193
      rtVector.pop_front ();
193
      rtVector.pop_front ();
194
      rtVector.push_back (successEntry);
194
      rtVector.push_back (successEntry);
 Lines 197-203    Link Here 
197
      /*
197
      /*
198
       * Save the new route cache along with the destination address in map
198
       * Save the new route cache along with the destination address in map
199
       */
199
       */
200
      std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
200
      std::pair<std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator, bool> result =
201
        m_sortedRoutes.insert (std::make_pair (dst, rtVector));
201
        m_sortedRoutes.insert (std::make_pair (dst, rtVector));
202
      return result.second;
202
      return result.second;
203
    }
203
    }
 Lines 205-211    Link Here 
205
}
205
}
206
206
207
bool
207
bool
208
RouteCache::LookupRoute (Ipv4Address id, RouteCacheEntry & rt)
208
DsrRouteCache::LookupRoute (Ipv4Address id, DsrRouteCacheEntry & rt)
209
{
209
{
210
  NS_LOG_FUNCTION (this << id);
210
  NS_LOG_FUNCTION (this << id);
211
  if (IsLinkCache ())
211
  if (IsLinkCache ())
 Lines 220-243    Link Here 
220
          NS_LOG_LOGIC ("Route to " << id << " not found; m_sortedRoutes is empty");
220
          NS_LOG_LOGIC ("Route to " << id << " not found; m_sortedRoutes is empty");
221
          return false;
221
          return false;
222
        }
222
        }
223
      std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i = m_sortedRoutes.find (id);
223
      std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::const_iterator i = m_sortedRoutes.find (id);
224
      if (i == m_sortedRoutes.end ())
224
      if (i == m_sortedRoutes.end ())
225
        {
225
        {
226
          NS_LOG_LOGIC ("No Direct Route to " << id << " found");
226
          NS_LOG_LOGIC ("No Direct Route to " << id << " found");
227
          for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator j =
227
          for (std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::const_iterator j =
228
                 m_sortedRoutes.begin (); j != m_sortedRoutes.end (); ++j)
228
                 m_sortedRoutes.begin (); j != m_sortedRoutes.end (); ++j)
229
            {
229
            {
230
              std::list<RouteCacheEntry> rtVector = j->second; // The route cache vector linked with destination address
230
              std::list<DsrRouteCacheEntry> rtVector = j->second; // The route cache vector linked with destination address
231
              /*
231
              /*
232
               * Loop through the possibly multiple routes within the route vector
232
               * Loop through the possibly multiple routes within the route vector
233
               */
233
               */
234
              for (std::list<RouteCacheEntry>::const_iterator k = rtVector.begin (); k != rtVector.end (); ++k)
234
              for (std::list<DsrRouteCacheEntry>::const_iterator k = rtVector.begin (); k != rtVector.end (); ++k)
235
                {
235
                {
236
                  // return the first route in the route vector
236
                  // return the first route in the route vector
237
                  RouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
237
                  DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
238
                  RouteCacheEntry::IP_VECTOR changeVector;
238
                  DsrRouteCacheEntry::IP_VECTOR changeVector;
239
239
240
                  for (RouteCacheEntry::IP_VECTOR::iterator l = routeVector.begin (); l != routeVector.end (); ++l)
240
                  for (DsrRouteCacheEntry::IP_VECTOR::iterator l = routeVector.begin (); l != routeVector.end (); ++l)
241
                    {
241
                    {
242
                      if (*l != id)
242
                      if (*l != id)
243
                        {
243
                        {
 Lines 255-267    Link Here 
255
                   */
255
                   */
256
                  if ((changeVector.size () < routeVector.size ())  && (changeVector.size () > 1))
256
                  if ((changeVector.size () < routeVector.size ())  && (changeVector.size () > 1))
257
                    {
257
                    {
258
                      RouteCacheEntry changeEntry; // Create the route entry
258
                      DsrRouteCacheEntry changeEntry; // Create the route entry
259
                      changeEntry.SetVector (changeVector);
259
                      changeEntry.SetVector (changeVector);
260
                      changeEntry.SetDestination (id);
260
                      changeEntry.SetDestination (id);
261
                      // Use the expire time from original route entry
261
                      // Use the expire time from original route entry
262
                      changeEntry.SetExpireTime (k->GetExpireTime ());
262
                      changeEntry.SetExpireTime (k->GetExpireTime ());
263
                      // We need to add new route entry here
263
                      // We need to add new route entry here
264
                      std::list<RouteCacheEntry> newVector;
264
                      std::list<DsrRouteCacheEntry> newVector;
265
                      newVector.push_back (changeEntry);
265
                      newVector.push_back (changeEntry);
266
                      newVector.sort (CompareRoutesExpire);  // sort the route vector first
266
                      newVector.sort (CompareRoutesExpire);  // sort the route vector first
267
                      m_sortedRoutes[id] = newVector;   // Only get the first sub route and add it in route cache
267
                      m_sortedRoutes[id] = newVector;   // Only get the first sub route and add it in route cache
 Lines 271-277    Link Here 
271
            }
271
            }
272
        }
272
        }
273
      NS_LOG_INFO ("Here we check the route cache again after updated the sub routes");
273
      NS_LOG_INFO ("Here we check the route cache again after updated the sub routes");
274
      std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator m = m_sortedRoutes.find (id);
274
      std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::const_iterator m = m_sortedRoutes.find (id);
275
      if (m == m_sortedRoutes.end ())
275
      if (m == m_sortedRoutes.end ())
276
        {
276
        {
277
          NS_LOG_LOGIC ("No updated route till last time");
277
          NS_LOG_LOGIC ("No updated route till last time");
 Lines 280-286    Link Here 
280
      /*
280
      /*
281
       * We have a direct route to the destination address
281
       * We have a direct route to the destination address
282
       */
282
       */
283
      std::list<RouteCacheEntry> rtVector = m->second;
283
      std::list<DsrRouteCacheEntry> rtVector = m->second;
284
      rt = rtVector.front ();  // use the first entry in the route vector
284
      rt = rtVector.front ();  // use the first entry in the route vector
285
      NS_LOG_LOGIC ("Route to " << id << " with route size " << rtVector.size ());
285
      NS_LOG_LOGIC ("Route to " << id << " with route size " << rtVector.size ());
286
      return true;
286
      return true;
 Lines 288-294    Link Here 
288
}
288
}
289
289
290
void
290
void
291
RouteCache::SetCacheType (std::string type)
291
DsrRouteCache::SetCacheType (std::string type)
292
{
292
{
293
  NS_LOG_FUNCTION (this << type);
293
  NS_LOG_FUNCTION (this << type);
294
  if (type == std::string ("LinkCache"))
294
  if (type == std::string ("LinkCache"))
 Lines 307-320    Link Here 
307
}
307
}
308
308
309
bool
309
bool
310
RouteCache::IsLinkCache ()
310
DsrRouteCache::IsLinkCache ()
311
{
311
{
312
  NS_LOG_FUNCTION (this);
312
  NS_LOG_FUNCTION (this);
313
  return m_isLinkCache;
313
  return m_isLinkCache;
314
}
314
}
315
315
316
void
316
void
317
RouteCache::RebuildBestRouteTable (Ipv4Address source)
317
DsrRouteCache::RebuildBestRouteTable (Ipv4Address source)
318
{
318
{
319
  NS_LOG_FUNCTION (this << source);
319
  NS_LOG_FUNCTION (this << source);
320
  /**
320
  /**
 Lines 381-388    Link Here 
381
               */
381
               */
382
              else if (d[k->first] == d[tempip] + k->second)
382
              else if (d[k->first] == d[tempip] + k->second)
383
                {
383
                {
384
                  std::map<Link, LinkStab>::iterator oldlink = m_linkCache.find (Link (k->first, pre[k->first]));
384
                  std::map<Link, DsrLinkStab>::iterator oldlink = m_linkCache.find (Link (k->first, pre[k->first]));
385
                  std::map<Link, LinkStab>::iterator newlink = m_linkCache.find (Link (k->first, tempip));
385
                  std::map<Link, DsrLinkStab>::iterator newlink = m_linkCache.find (Link (k->first, tempip));
386
                  if (oldlink != m_linkCache.end () && newlink != m_linkCache.end ())
386
                  if (oldlink != m_linkCache.end () && newlink != m_linkCache.end ())
387
                    {
387
                    {
388
                      if (oldlink->second.GetLinkStability () < newlink->second.GetLinkStability ())
388
                      if (oldlink->second.GetLinkStability () < newlink->second.GetLinkStability ())
 Lines 405-411    Link Here 
405
  for (std::map<Ipv4Address, Ipv4Address>::iterator i = pre.begin (); i != pre.end (); ++i)
405
  for (std::map<Ipv4Address, Ipv4Address>::iterator i = pre.begin (); i != pre.end (); ++i)
406
    {
406
    {
407
      // loop for all vertexes
407
      // loop for all vertexes
408
      RouteCacheEntry::IP_VECTOR route;
408
      DsrRouteCacheEntry::IP_VECTOR route;
409
      Ipv4Address iptemp = i->first;
409
      Ipv4Address iptemp = i->first;
410
410
411
      if (!i->second.IsBroadcast () && iptemp != source)
411
      if (!i->second.IsBroadcast () && iptemp != source)
 Lines 417-424    Link Here 
417
            }
417
            }
418
          route.push_back (source);
418
          route.push_back (source);
419
          // Reverse the route
419
          // Reverse the route
420
          RouteCacheEntry::IP_VECTOR reverseroute;
420
          DsrRouteCacheEntry::IP_VECTOR reverseroute;
421
          for (RouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin (); j != route.rend (); ++j)
421
          for (DsrRouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin (); j != route.rend (); ++j)
422
            {
422
            {
423
              reverseroute.push_back (*j);
423
              reverseroute.push_back (*j);
424
            }
424
            }
 Lines 430-441    Link Here 
430
}
430
}
431
431
432
bool
432
bool
433
RouteCache::LookupRoute_Link (Ipv4Address id, RouteCacheEntry & rt)
433
DsrRouteCache::LookupRoute_Link (Ipv4Address id, DsrRouteCacheEntry & rt)
434
{
434
{
435
  NS_LOG_FUNCTION (this << id);
435
  NS_LOG_FUNCTION (this << id);
436
  /// We need to purge the link node cache
436
  /// We need to purge the link node cache
437
  PurgeLinkNode ();
437
  PurgeLinkNode ();
438
  std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR>::const_iterator i = m_bestRoutesTable_link.find (id);
438
  std::map<Ipv4Address, DsrRouteCacheEntry::IP_VECTOR>::const_iterator i = m_bestRoutesTable_link.find (id);
439
  if (i == m_bestRoutesTable_link.end ())
439
  if (i == m_bestRoutesTable_link.end ())
440
    {
440
    {
441
      NS_LOG_INFO ("No route find to " << id);
441
      NS_LOG_INFO ("No route find to " << id);
 Lines 449-455    Link Here 
449
          return false;
449
          return false;
450
        }
450
        }
451
451
452
      RouteCacheEntry newEntry; // Create the route entry
452
      DsrRouteCacheEntry newEntry; // Create the route entry
453
      newEntry.SetVector (i->second);
453
      newEntry.SetVector (i->second);
454
      newEntry.SetDestination (id);
454
      newEntry.SetDestination (id);
455
      newEntry.SetExpireTime (RouteCacheTimeout);
455
      newEntry.SetExpireTime (RouteCacheTimeout);
 Lines 462-474    Link Here 
462
}
462
}
463
463
464
void
464
void
465
RouteCache::PurgeLinkNode ()
465
DsrRouteCache::PurgeLinkNode ()
466
{
466
{
467
  NS_LOG_FUNCTION (this);
467
  NS_LOG_FUNCTION (this);
468
  for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); )
468
  for (std::map<Link, DsrLinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); )
469
    {
469
    {
470
      NS_LOG_DEBUG ("The link stability " << i->second.GetLinkStability ().GetSeconds ());
470
      NS_LOG_DEBUG ("The link stability " << i->second.GetLinkStability ().GetSeconds ());
471
      std::map<Link, LinkStab>::iterator itmp = i;
471
      std::map<Link, DsrLinkStab>::iterator itmp = i;
472
      if (i->second.GetLinkStability () <= Seconds (0))
472
      if (i->second.GetLinkStability () <= Seconds (0))
473
        {
473
        {
474
          ++i;
474
          ++i;
 Lines 480-489    Link Here 
480
        }
480
        }
481
    }
481
    }
482
  /// may need to remove them after verify
482
  /// may need to remove them after verify
483
  for (std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.begin (); i != m_nodeCache.end (); )
483
  for (std::map<Ipv4Address, DsrNodeStab>::iterator i = m_nodeCache.begin (); i != m_nodeCache.end (); )
484
    {
484
    {
485
      NS_LOG_DEBUG ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
485
      NS_LOG_DEBUG ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
486
      std::map<Ipv4Address, NodeStab>::iterator itmp = i;
486
      std::map<Ipv4Address, DsrNodeStab>::iterator itmp = i;
487
      if (i->second.GetNodeStability () <= Seconds (0))
487
      if (i->second.GetNodeStability () <= Seconds (0))
488
        {
488
        {
489
          ++i;
489
          ++i;
 Lines 497-507    Link Here 
497
}
497
}
498
498
499
void
499
void
500
RouteCache::UpdateNetGraph ()
500
DsrRouteCache::UpdateNetGraph ()
501
{
501
{
502
  NS_LOG_FUNCTION (this);
502
  NS_LOG_FUNCTION (this);
503
  m_netGraph.clear ();
503
  m_netGraph.clear ();
504
  for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); ++i)
504
  for (std::map<Link, DsrLinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); ++i)
505
    {
505
    {
506
      // Here the weight is set as 1
506
      // Here the weight is set as 1
507
      /// \todo May need to set different weight for different link here later
507
      /// \todo May need to set different weight for different link here later
 Lines 512-525    Link Here 
512
}
512
}
513
513
514
bool
514
bool
515
RouteCache::IncStability (Ipv4Address node)
515
DsrRouteCache::IncStability (Ipv4Address node)
516
{
516
{
517
  NS_LOG_FUNCTION (this << node);
517
  NS_LOG_FUNCTION (this << node);
518
  std::map<Ipv4Address, NodeStab>::const_iterator i = m_nodeCache.find (node);
518
  std::map<Ipv4Address, DsrNodeStab>::const_iterator i = m_nodeCache.find (node);
519
  if (i == m_nodeCache.end ())
519
  if (i == m_nodeCache.end ())
520
    {
520
    {
521
      NS_LOG_INFO ("The initial stability " << m_initStability.GetSeconds ());
521
      NS_LOG_INFO ("The initial stability " << m_initStability.GetSeconds ());
522
      NodeStab ns (m_initStability);
522
      DsrNodeStab ns (m_initStability);
523
      m_nodeCache[node] = ns;
523
      m_nodeCache[node] = ns;
524
      return false;
524
      return false;
525
    }
525
    }
 Lines 528-534    Link Here 
528
      /// \todo get rid of the debug here
528
      /// \todo get rid of the debug here
529
      NS_LOG_INFO ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
529
      NS_LOG_INFO ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
530
      NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () * m_stabilityIncrFactor).GetSeconds ());
530
      NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () * m_stabilityIncrFactor).GetSeconds ());
531
      NodeStab ns (Time (i->second.GetNodeStability () * m_stabilityIncrFactor));
531
      DsrNodeStab ns (Time (i->second.GetNodeStability () * m_stabilityIncrFactor));
532
      m_nodeCache[node] = ns;
532
      m_nodeCache[node] = ns;
533
      return true;
533
      return true;
534
    }
534
    }
 Lines 536-548    Link Here 
536
}
536
}
537
537
538
bool
538
bool
539
RouteCache::DecStability (Ipv4Address node)
539
DsrRouteCache::DecStability (Ipv4Address node)
540
{
540
{
541
  NS_LOG_FUNCTION (this << node);
541
  NS_LOG_FUNCTION (this << node);
542
  std::map<Ipv4Address, NodeStab>::const_iterator i = m_nodeCache.find (node);
542
  std::map<Ipv4Address, DsrNodeStab>::const_iterator i = m_nodeCache.find (node);
543
  if (i == m_nodeCache.end ())
543
  if (i == m_nodeCache.end ())
544
    {
544
    {
545
      NodeStab ns (m_initStability);
545
      DsrNodeStab ns (m_initStability);
546
      m_nodeCache[node] = ns;
546
      m_nodeCache[node] = ns;
547
      return false;
547
      return false;
548
    }
548
    }
 Lines 551-557    Link Here 
551
      /// \todo remove it here
551
      /// \todo remove it here
552
      NS_LOG_INFO ("The stability here " << i->second.GetNodeStability ().GetSeconds ());
552
      NS_LOG_INFO ("The stability here " << i->second.GetNodeStability ().GetSeconds ());
553
      NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () / m_stabilityDecrFactor).GetSeconds ());
553
      NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () / m_stabilityDecrFactor).GetSeconds ());
554
      NodeStab ns (Time (i->second.GetNodeStability () / m_stabilityDecrFactor));
554
      DsrNodeStab ns (Time (i->second.GetNodeStability () / m_stabilityDecrFactor));
555
      m_nodeCache[node] = ns;
555
      m_nodeCache[node] = ns;
556
      return true;
556
      return true;
557
    }
557
    }
 Lines 559-565    Link Here 
559
}
559
}
560
560
561
bool
561
bool
562
RouteCache::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
562
DsrRouteCache::AddRoute_Link (DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
563
{
563
{
564
  NS_LOG_FUNCTION (this << source);
564
  NS_LOG_FUNCTION (this << source);
565
  NS_LOG_LOGIC ("Use Link Cache");
565
  NS_LOG_LOGIC ("Use Link Cache");
 Lines 567-573    Link Here 
567
  PurgeLinkNode ();
567
  PurgeLinkNode ();
568
  for (uint32_t i = 0; i < nodelist.size () - 1; i++)
568
  for (uint32_t i = 0; i < nodelist.size () - 1; i++)
569
    {
569
    {
570
      NodeStab ns;                /// This is the node stability
570
      DsrNodeStab ns;                /// This is the node stability
571
      ns.SetNodeStability (m_initStability);
571
      ns.SetNodeStability (m_initStability);
572
572
573
      if (m_nodeCache.find (nodelist[i]) == m_nodeCache.end ())
573
      if (m_nodeCache.find (nodelist[i]) == m_nodeCache.end ())
 Lines 579-585    Link Here 
579
          m_nodeCache[nodelist[i + 1]] = ns;
579
          m_nodeCache[nodelist[i + 1]] = ns;
580
        }
580
        }
581
      Link link (nodelist[i], nodelist[i + 1]);         /// Link represent the one link for the route
581
      Link link (nodelist[i], nodelist[i + 1]);         /// Link represent the one link for the route
582
      LinkStab stab;                /// Link stability
582
      DsrLinkStab stab;                /// Link stability
583
      stab.SetLinkStability (m_initStability);
583
      stab.SetLinkStability (m_initStability);
584
      /// Set the link stability as the smallest node stability
584
      /// Set the link stability as the smallest node stability
585
      if (m_nodeCache[nodelist[i]].GetNodeStability () < m_nodeCache[nodelist[i + 1]].GetNodeStability ())
585
      if (m_nodeCache[nodelist[i]].GetNodeStability () < m_nodeCache[nodelist[i + 1]].GetNodeStability ())
 Lines 608-614    Link Here 
608
}
608
}
609
609
610
void
610
void
611
RouteCache::UseExtends (RouteCacheEntry::IP_VECTOR rt)
611
DsrRouteCache::UseExtends (DsrRouteCacheEntry::IP_VECTOR rt)
612
{
612
{
613
  NS_LOG_FUNCTION (this);
613
  NS_LOG_FUNCTION (this);
614
  /// Purge the link node cache first
614
  /// Purge the link node cache first
 Lines 618-624    Link Here 
618
      NS_LOG_INFO ("The route is too short");
618
      NS_LOG_INFO ("The route is too short");
619
      return;
619
      return;
620
    }
620
    }
621
  for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end () - 1; ++i)
621
  for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end () - 1; ++i)
622
    {
622
    {
623
      Link link (*i, *(i + 1));
623
      Link link (*i, *(i + 1));
624
      if (m_linkCache.find (link) != m_linkCache.end ())
624
      if (m_linkCache.find (link) != m_linkCache.end ())
 Lines 636-642    Link Here 
636
        }
636
        }
637
    }
637
    }
638
  /// Increase the stability of the node cache
638
  /// Increase the stability of the node cache
639
  for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end (); ++i)
639
  for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end (); ++i)
640
    {
640
    {
641
      if (m_nodeCache.find (*i) != m_nodeCache.end ())
641
      if (m_nodeCache.find (*i) != m_nodeCache.end ())
642
        {
642
        {
 Lines 654-669    Link Here 
654
}
654
}
655
655
656
bool
656
bool
657
RouteCache::AddRoute (RouteCacheEntry & rt)
657
DsrRouteCache::AddRoute (DsrRouteCacheEntry & rt)
658
{
658
{
659
  NS_LOG_FUNCTION (this);
659
  NS_LOG_FUNCTION (this);
660
  Purge ();
660
  Purge ();
661
  std::list<RouteCacheEntry> rtVector;   // Declare the route cache entry vector
661
  std::list<DsrRouteCacheEntry> rtVector;   // Declare the route cache entry vector
662
  Ipv4Address dst = rt.GetDestination ();
662
  Ipv4Address dst = rt.GetDestination ();
663
  std::vector<Ipv4Address> route = rt.GetVector ();
663
  std::vector<Ipv4Address> route = rt.GetVector ();
664
664
665
  NS_LOG_DEBUG ("The route destination we have " << dst);
665
  NS_LOG_DEBUG ("The route destination we have " << dst);
666
  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i =
666
  std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::const_iterator i =
667
    m_sortedRoutes.find (dst);
667
    m_sortedRoutes.find (dst);
668
668
669
  if (i == m_sortedRoutes.end ())
669
  if (i == m_sortedRoutes.end ())
 Lines 673-679    Link Here 
673
      /**
673
      /**
674
       * Save the new route cache along with the destination address in map
674
       * Save the new route cache along with the destination address in map
675
       */
675
       */
676
      std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
676
      std::pair<std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator, bool> result =
677
        m_sortedRoutes.insert (std::make_pair (dst, rtVector));
677
        m_sortedRoutes.insert (std::make_pair (dst, rtVector));
678
      return result.second;
678
      return result.second;
679
    }
679
    }
 Lines 711-717    Link Here 
711
              /**
711
              /**
712
               * Save the new route cache along with the destination address in map
712
               * Save the new route cache along with the destination address in map
713
               */
713
               */
714
              std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
714
              std::pair<std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator, bool> result =
715
                m_sortedRoutes.insert (std::make_pair (dst, rtVector));
715
                m_sortedRoutes.insert (std::make_pair (dst, rtVector));
716
              return result.second;
716
              return result.second;
717
            }
717
            }
 Lines 724-737    Link Here 
724
  return false;
724
  return false;
725
}
725
}
726
726
727
bool RouteCache::FindSameRoute (RouteCacheEntry & rt, std::list<RouteCacheEntry> & rtVector)
727
bool DsrRouteCache::FindSameRoute (DsrRouteCacheEntry & rt, std::list<DsrRouteCacheEntry> & rtVector)
728
{
728
{
729
  NS_LOG_FUNCTION (this);
729
  NS_LOG_FUNCTION (this);
730
  for (std::list<RouteCacheEntry>::iterator i = rtVector.begin (); i != rtVector.end (); ++i)
730
  for (std::list<DsrRouteCacheEntry>::iterator i = rtVector.begin (); i != rtVector.end (); ++i)
731
    {
731
    {
732
      // return the first route in the route vector
732
      // return the first route in the route vector
733
      RouteCacheEntry::IP_VECTOR routeVector = i->GetVector ();
733
      DsrRouteCacheEntry::IP_VECTOR routeVector = i->GetVector ();
734
      RouteCacheEntry::IP_VECTOR newVector = rt.GetVector ();
734
      DsrRouteCacheEntry::IP_VECTOR newVector = rt.GetVector ();
735
735
736
      if (routeVector == newVector)
736
      if (routeVector == newVector)
737
        {
737
        {
 Lines 748-754    Link Here 
748
          /*
748
          /*
749
           * Save the new route cache along with the destination address in map
749
           * Save the new route cache along with the destination address in map
750
           */
750
           */
751
          std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
751
          std::pair<std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator, bool> result =
752
            m_sortedRoutes.insert (std::make_pair (rt.GetDestination (), rtVector));
752
            m_sortedRoutes.insert (std::make_pair (rt.GetDestination (), rtVector));
753
          return result.second;
753
          return result.second;
754
        }
754
        }
 Lines 757-763    Link Here 
757
}
757
}
758
758
759
bool
759
bool
760
RouteCache::DeleteRoute (Ipv4Address dst)
760
DsrRouteCache::DeleteRoute (Ipv4Address dst)
761
{
761
{
762
  NS_LOG_FUNCTION (this << dst);
762
  NS_LOG_FUNCTION (this << dst);
763
  Purge (); // purge the route cache first to remove timeout entries
763
  Purge (); // purge the route cache first to remove timeout entries
 Lines 771-777    Link Here 
771
}
771
}
772
772
773
void
773
void
774
RouteCache::DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
774
DsrRouteCache::DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
775
{
775
{
776
  NS_LOG_FUNCTION (this << errorSrc << unreachNode << node);
776
  NS_LOG_FUNCTION (this << errorSrc << unreachNode << node);
777
  if (IsLinkCache ())
777
  if (IsLinkCache ())
 Lines 792-798    Link Here 
792
      m_linkCache.erase (link2);
792
      m_linkCache.erase (link2);
793
      NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
793
      NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
794
794
795
      std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.find (errorSrc);
795
      std::map<Ipv4Address, DsrNodeStab>::iterator i = m_nodeCache.find (errorSrc);
796
      if (i == m_nodeCache.end ())
796
      if (i == m_nodeCache.end ())
797
        {
797
        {
798
          NS_LOG_LOGIC ("Update the node stability unsuccessfully");
798
          NS_LOG_LOGIC ("Update the node stability unsuccessfully");
 Lines 827-850    Link Here 
827
      /*
827
      /*
828
       * Loop all the routes saved in the route cache
828
       * Loop all the routes saved in the route cache
829
       */
829
       */
830
      for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator j =
830
      for (std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator j =
831
             m_sortedRoutes.begin (); j != m_sortedRoutes.end (); )
831
             m_sortedRoutes.begin (); j != m_sortedRoutes.end (); )
832
        {
832
        {
833
          std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator jtmp = j;
833
          std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator jtmp = j;
834
          Ipv4Address address = j->first;
834
          Ipv4Address address = j->first;
835
          std::list<RouteCacheEntry> rtVector = j->second;
835
          std::list<DsrRouteCacheEntry> rtVector = j->second;
836
          /*
836
          /*
837
           * Loop all the routes for a single destination
837
           * Loop all the routes for a single destination
838
           */
838
           */
839
          for (std::list<RouteCacheEntry>::iterator k = rtVector.begin (); k != rtVector.end (); )
839
          for (std::list<DsrRouteCacheEntry>::iterator k = rtVector.begin (); k != rtVector.end (); )
840
            {
840
            {
841
              // return the first route in the route vector
841
              // return the first route in the route vector
842
              RouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
842
              DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
843
              RouteCacheEntry::IP_VECTOR changeVector;
843
              DsrRouteCacheEntry::IP_VECTOR changeVector;
844
              /*
844
              /*
845
               * Loop the ip addresses within a single route entry
845
               * Loop the ip addresses within a single route entry
846
               */
846
               */
847
              for (RouteCacheEntry::IP_VECTOR::iterator i = routeVector.begin (); i != routeVector.end (); ++i)
847
              for (DsrRouteCacheEntry::IP_VECTOR::iterator i = routeVector.begin (); i != routeVector.end (); ++i)
848
                {
848
                {
849
                  if (*i != errorSrc)
849
                  if (*i != errorSrc)
850
                    {
850
                    {
 Lines 881-887    Link Here 
881
                       * Remove the route first
881
                       * Remove the route first
882
                       */
882
                       */
883
                      k = rtVector.erase (k);
883
                      k = rtVector.erase (k);
884
                      RouteCacheEntry changeEntry;
884
                      DsrRouteCacheEntry changeEntry;
885
                      changeEntry.SetVector (changeVector);
885
                      changeEntry.SetVector (changeVector);
886
                      Ipv4Address destination = changeVector.back ();
886
                      Ipv4Address destination = changeVector.back ();
887
                      NS_LOG_DEBUG ("The destination of the newly formed route " << destination << " and the size of the route " << changeVector.size ());
887
                      NS_LOG_DEBUG ("The destination of the newly formed route " << destination << " and the size of the route " << changeVector.size ());
 Lines 929-935    Link Here 
929
}
929
}
930
930
931
void
931
void
932
RouteCache::PrintVector (std::vector<Ipv4Address>& vec)
932
DsrRouteCache::PrintVector (std::vector<Ipv4Address>& vec)
933
{
933
{
934
  NS_LOG_FUNCTION (this);
934
  NS_LOG_FUNCTION (this);
935
  /*
935
  /*
 Lines 950-959    Link Here 
950
}
950
}
951
951
952
void
952
void
953
RouteCache::PrintRouteVector (std::list<RouteCacheEntry> route)
953
DsrRouteCache::PrintRouteVector (std::list<DsrRouteCacheEntry> route)
954
{
954
{
955
  NS_LOG_FUNCTION (this);
955
  NS_LOG_FUNCTION (this);
956
  for (std::list<RouteCacheEntry>::iterator i = route.begin (); i != route.end (); i++)
956
  for (std::list<DsrRouteCacheEntry>::iterator i = route.begin (); i != route.end (); i++)
957
    {
957
    {
958
      std::vector<Ipv4Address> path = i->GetVector ();
958
      std::vector<Ipv4Address> path = i->GetVector ();
959
      NS_LOG_INFO ("Route NO. ");
959
      NS_LOG_INFO ("Route NO. ");
 Lines 962-968    Link Here 
962
}
962
}
963
963
964
void
964
void
965
RouteCache::Purge ()
965
DsrRouteCache::Purge ()
966
{
966
{
967
  NS_LOG_FUNCTION (this);
967
  NS_LOG_FUNCTION (this);
968
  //Trying to purge the route cache
968
  //Trying to purge the route cache
 Lines 971-990    Link Here 
971
      NS_LOG_DEBUG ("The route cache is empty");
971
      NS_LOG_DEBUG ("The route cache is empty");
972
      return;
972
      return;
973
    }
973
    }
974
  for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator i =
974
  for (std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator i =
975
         m_sortedRoutes.begin (); i != m_sortedRoutes.end (); )
975
         m_sortedRoutes.begin (); i != m_sortedRoutes.end (); )
976
    {
976
    {
977
      // Loop of route cache entry with the route size
977
      // Loop of route cache entry with the route size
978
      std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator itmp = i;
978
      std::map<Ipv4Address, std::list<DsrRouteCacheEntry> >::iterator itmp = i;
979
      /*
979
      /*
980
       * The route cache entry vector
980
       * The route cache entry vector
981
       */
981
       */
982
      Ipv4Address dst = i->first;
982
      Ipv4Address dst = i->first;
983
      std::list<RouteCacheEntry> rtVector = i->second;
983
      std::list<DsrRouteCacheEntry> rtVector = i->second;
984
      NS_LOG_DEBUG ("The route vector size of 1 " << dst << " " << rtVector.size ());
984
      NS_LOG_DEBUG ("The route vector size of 1 " << dst << " " << rtVector.size ());
985
      if (rtVector.size ())
985
      if (rtVector.size ())
986
        {
986
        {
987
          for (std::list<RouteCacheEntry>::iterator j = rtVector.begin (); j != rtVector.end (); )
987
          for (std::list<DsrRouteCacheEntry>::iterator j = rtVector.begin (); j != rtVector.end (); )
988
            {
988
            {
989
              NS_LOG_DEBUG ("The expire time of every entry with expire time " << j->GetExpireTime ());
989
              NS_LOG_DEBUG ("The expire time of every entry with expire time " << j->GetExpireTime ());
990
              /*
990
              /*
 Lines 1029-1041    Link Here 
1029
}
1029
}
1030
1030
1031
void
1031
void
1032
RouteCache::Print (std::ostream &os)
1032
DsrRouteCache::Print (std::ostream &os)
1033
{
1033
{
1034
  NS_LOG_FUNCTION (this);
1034
  NS_LOG_FUNCTION (this);
1035
  Purge ();
1035
  Purge ();
1036
  os << "\nDSR Route Cache\n"
1036
  os << "\nDSR Route Cache\n"
1037
     << "Destination\tGateway\t\tInterface\tFlag\tExpire\tHops\n";
1037
     << "Destination\tGateway\t\tInterface\tFlag\tExpire\tHops\n";
1038
  for (std::list<RouteCacheEntry>::const_iterator i =
1038
  for (std::list<DsrRouteCacheEntry>::const_iterator i =
1039
         m_routeEntryVector.begin (); i != m_routeEntryVector.end (); ++i)
1039
         m_routeEntryVector.begin (); i != m_routeEntryVector.end (); ++i)
1040
    {
1040
    {
1041
      i->Print (os);
1041
      i->Print (os);
 Lines 1048-1054    Link Here 
1048
 * This part of code maintains an Acknowledgment id cache for next hop and remove duplicate ids
1048
 * This part of code maintains an Acknowledgment id cache for next hop and remove duplicate ids
1049
 */
1049
 */
1050
uint16_t
1050
uint16_t
1051
RouteCache::CheckUniqueAckId (Ipv4Address nextHop)
1051
DsrRouteCache::CheckUniqueAckId (Ipv4Address nextHop)
1052
{
1052
{
1053
  NS_LOG_FUNCTION (this);
1053
  NS_LOG_FUNCTION (this);
1054
  std::map<Ipv4Address, uint16_t>::const_iterator i =
1054
  std::map<Ipv4Address, uint16_t>::const_iterator i =
 Lines 1070-1076    Link Here 
1070
}
1070
}
1071
1071
1072
uint16_t
1072
uint16_t
1073
RouteCache::GetAckSize ()
1073
DsrRouteCache::GetAckSize ()
1074
{
1074
{
1075
  return m_ackIdCache.size ();
1075
  return m_ackIdCache.size ();
1076
}
1076
}
 Lines 1080-1086    Link Here 
1080
 * This part maintains a neighbor list to handle unidirectional links and link-layer acks
1080
 * This part maintains a neighbor list to handle unidirectional links and link-layer acks
1081
 */
1081
 */
1082
bool
1082
bool
1083
RouteCache::IsNeighbor (Ipv4Address addr)
1083
DsrRouteCache::IsNeighbor (Ipv4Address addr)
1084
{
1084
{
1085
  NS_LOG_FUNCTION (this);
1085
  NS_LOG_FUNCTION (this);
1086
  PurgeMac ();  // purge the mac cache
1086
  PurgeMac ();  // purge the mac cache
 Lines 1096-1102    Link Here 
1096
}
1096
}
1097
1097
1098
Time
1098
Time
1099
RouteCache::GetExpireTime (Ipv4Address addr)
1099
DsrRouteCache::GetExpireTime (Ipv4Address addr)
1100
{
1100
{
1101
  NS_LOG_FUNCTION (this);
1101
  NS_LOG_FUNCTION (this);
1102
  PurgeMac ();
1102
  PurgeMac ();
 Lines 1112-1118    Link Here 
1112
}
1112
}
1113
1113
1114
void
1114
void
1115
RouteCache::UpdateNeighbor (std::vector<Ipv4Address> nodeList, Time expire)
1115
DsrRouteCache::UpdateNeighbor (std::vector<Ipv4Address> nodeList, Time expire)
1116
{
1116
{
1117
  NS_LOG_FUNCTION (this);
1117
  NS_LOG_FUNCTION (this);
1118
  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
1118
  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
 Lines 1140-1146    Link Here 
1140
}
1140
}
1141
1141
1142
void
1142
void
1143
RouteCache::AddNeighbor (std::vector<Ipv4Address> nodeList, Ipv4Address ownAddress, Time expire)
1143
DsrRouteCache::AddNeighbor (std::vector<Ipv4Address> nodeList, Ipv4Address ownAddress, Time expire)
1144
{
1144
{
1145
  NS_LOG_LOGIC ("Add neighbor number " << nodeList.size ());
1145
  NS_LOG_LOGIC ("Add neighbor number " << nodeList.size ());
1146
  for (std::vector<Ipv4Address>::iterator j = nodeList.begin (); j != nodeList.end ();)
1146
  for (std::vector<Ipv4Address>::iterator j = nodeList.begin (); j != nodeList.end ();)
 Lines 1163-1176    Link Here 
1163
1163
1164
struct CloseNeighbor
1164
struct CloseNeighbor
1165
{
1165
{
1166
  bool operator() (const RouteCache::Neighbor & nb) const
1166
  bool operator() (const DsrRouteCache::Neighbor & nb) const
1167
  {
1167
  {
1168
    return ((nb.m_expireTime < Simulator::Now ()) || nb.close);
1168
    return ((nb.m_expireTime < Simulator::Now ()) || nb.close);
1169
  }
1169
  }
1170
};
1170
};
1171
1171
1172
void
1172
void
1173
RouteCache::PurgeMac ()
1173
DsrRouteCache::PurgeMac ()
1174
{
1174
{
1175
  if (m_nb.empty ())
1175
  if (m_nb.empty ())
1176
    {
1176
    {
 Lines 1196-1221    Link Here 
1196
}
1196
}
1197
1197
1198
void
1198
void
1199
RouteCache::ScheduleTimer ()
1199
DsrRouteCache::ScheduleTimer ()
1200
{
1200
{
1201
  m_ntimer.Cancel ();
1201
  m_ntimer.Cancel ();
1202
  m_ntimer.Schedule ();
1202
  m_ntimer.Schedule ();
1203
}
1203
}
1204
1204
1205
void
1205
void
1206
RouteCache::AddArpCache (Ptr<ArpCache> a)
1206
DsrRouteCache::AddArpCache (Ptr<ArpCache> a)
1207
{
1207
{
1208
  m_arp.push_back (a);
1208
  m_arp.push_back (a);
1209
}
1209
}
1210
1210
1211
void
1211
void
1212
RouteCache::DelArpCache (Ptr<ArpCache> a)
1212
DsrRouteCache::DelArpCache (Ptr<ArpCache> a)
1213
{
1213
{
1214
  m_arp.erase (std::remove (m_arp.begin (), m_arp.end (), a), m_arp.end ());
1214
  m_arp.erase (std::remove (m_arp.begin (), m_arp.end (), a), m_arp.end ());
1215
}
1215
}
1216
1216
1217
Mac48Address
1217
Mac48Address
1218
RouteCache::LookupMacAddress (Ipv4Address addr)
1218
DsrRouteCache::LookupMacAddress (Ipv4Address addr)
1219
{
1219
{
1220
  Mac48Address hwaddr;
1220
  Mac48Address hwaddr;
1221
  for (std::vector<Ptr<ArpCache> >::const_iterator i = m_arp.begin ();
1221
  for (std::vector<Ptr<ArpCache> >::const_iterator i = m_arp.begin ();
 Lines 1232-1238    Link Here 
1232
}
1232
}
1233
1233
1234
void
1234
void
1235
RouteCache::ProcessTxError (WifiMacHeader const & hdr)
1235
DsrRouteCache::ProcessTxError (WifiMacHeader const & hdr)
1236
{
1236
{
1237
  Mac48Address addr = hdr.GetAddr1 ();
1237
  Mac48Address addr = hdr.GetAddr1 ();
1238
1238
(-)a/src/dsr/model/dsr-rcache.h (-28 / +28 lines)
 Lines 118-134    Link Here 
118
  void Print () const;
118
  void Print () const;
119
};
119
};
120
120
121
class LinkStab
121
class DsrLinkStab
122
{
122
{
123
public:
123
public:
124
  /**
124
  /**
125
   * \brief Constructor
125
   * \brief Constructor
126
   */
126
   */
127
  LinkStab (Time linkStab = Simulator::Now ());
127
  DsrLinkStab (Time linkStab = Simulator::Now ());
128
  /**
128
  /**
129
   * \brief Destructor
129
   * \brief Destructor
130
   */
130
   */
131
  virtual ~LinkStab ();
131
  virtual ~DsrLinkStab ();
132
132
133
  /**
133
  /**
134
   * \brief set/get the link stability
134
   * \brief set/get the link stability
 Lines 152-163    Link Here 
152
  Time m_linkStability;
152
  Time m_linkStability;
153
};
153
};
154
154
155
class NodeStab
155
class DsrNodeStab
156
{
156
{
157
public:
157
public:
158
158
159
  NodeStab (Time nodeStab = Simulator::Now ());
159
  DsrNodeStab (Time nodeStab = Simulator::Now ());
160
  virtual ~NodeStab ();
160
  virtual ~DsrNodeStab ();
161
161
162
  void SetNodeStability (Time nodeStab)
162
  void SetNodeStability (Time nodeStab)
163
  {
163
  {
 Lines 171-184    Link Here 
171
  Time m_nodeStability;
171
  Time m_nodeStability;
172
};
172
};
173
173
174
class RouteCacheEntry
174
class DsrRouteCacheEntry
175
{
175
{
176
public:
176
public:
177
  typedef std::vector<Ipv4Address> IP_VECTOR;                ///< Define the vector to hold Ip address
177
  typedef std::vector<Ipv4Address> IP_VECTOR;                ///< Define the vector to hold Ip address
178
  typedef std::vector<Ipv4Address>::iterator Iterator;       ///< Define the iterator
178
  typedef std::vector<Ipv4Address>::iterator Iterator;       ///< Define the iterator
179
179
180
  RouteCacheEntry (IP_VECTOR const  & ip = IP_VECTOR (), Ipv4Address dst = Ipv4Address (), Time exp = Simulator::Now ());
180
  DsrRouteCacheEntry (IP_VECTOR const  & ip = IP_VECTOR (), Ipv4Address dst = Ipv4Address (), Time exp = Simulator::Now ());
181
  virtual ~RouteCacheEntry ();
181
  virtual ~DsrRouteCacheEntry ();
182
182
183
  /// Mark entry as "down" (i.e. disable it)
183
  /// Mark entry as "down" (i.e. disable it)
184
  void Invalidate (Time badLinkLifetime);
184
  void Invalidate (Time badLinkLifetime);
 Lines 233-239    Link Here 
233
   * \brief Compare the route cache entry
233
   * \brief Compare the route cache entry
234
   * \return true if equal
234
   * \return true if equal
235
   */
235
   */
236
  bool operator== (RouteCacheEntry const & o) const
236
  bool operator== (DsrRouteCacheEntry const & o) const
237
  {
237
  {
238
    if (m_path.size () != o.m_path.size ())
238
    if (m_path.size () != o.m_path.size ())
239
      {
239
      {
 Lines 282-304    Link Here 
282
 * \brief DSR route request queue
282
 * \brief DSR route request queue
283
 * Since DSR is an on demand routing we queue requests while looking for route.
283
 * Since DSR is an on demand routing we queue requests while looking for route.
284
 */
284
 */
285
class RouteCache : public Object
285
class DsrRouteCache : public Object
286
{
286
{
287
public:
287
public:
288
288
289
  static TypeId GetTypeId ();
289
  static TypeId GetTypeId ();
290
290
291
  RouteCache ();
291
  DsrRouteCache ();
292
  virtual ~RouteCache ();
292
  virtual ~DsrRouteCache ();
293
293
294
  /**
294
  /**
295
   * \brief Remove the aged route cache entries when the route cache is full
295
   * \brief Remove the aged route cache entries when the route cache is full
296
   */
296
   */
297
  void RemoveLastEntry (std::list<RouteCacheEntry> & rtVector);
297
  void RemoveLastEntry (std::list<DsrRouteCacheEntry> & rtVector);
298
  /**
298
  /**
299
   * \brief Define the vector of route entries.
299
   * \brief Define the vector of route entries.
300
   */
300
   */
301
  typedef std::list<RouteCacheEntry::IP_VECTOR> routeVector;
301
  typedef std::list<DsrRouteCacheEntry::IP_VECTOR> routeVector;
302
302
303
  // Fields
303
  // Fields
304
  bool GetSubRoute () const
304
  bool GetSubRoute () const
 Lines 393-406    Link Here 
393
   * \param rt route cache entry
393
   * \param rt route cache entry
394
   * \return true in success
394
   * \return true in success
395
   */
395
   */
396
  bool AddRoute (RouteCacheEntry & rt);
396
  bool AddRoute (DsrRouteCacheEntry & rt);
397
  /**
397
  /**
398
   * \brief Lookup route cache entry with destination address dst
398
   * \brief Lookup route cache entry with destination address dst
399
   * \param id destination address
399
   * \param id destination address
400
   * \param rt entry with destination address id, if exists
400
   * \param rt entry with destination address id, if exists
401
   * \return true on success
401
   * \return true on success
402
   */
402
   */
403
  bool LookupRoute (Ipv4Address id, RouteCacheEntry & rt);
403
  bool LookupRoute (Ipv4Address id, DsrRouteCacheEntry & rt);
404
  /**
404
  /**
405
   * \brief Print the route vector elements
405
   * \brief Print the route vector elements
406
   * \param vec the route vector
406
   * \param vec the route vector
 Lines 410-422    Link Here 
410
   * \brief Print all the route vector elements from the route list
410
   * \brief Print all the route vector elements from the route list
411
   * \param route the route list
411
   * \param route the route list
412
   */
412
   */
413
  void PrintRouteVector (std::list<RouteCacheEntry> route);
413
  void PrintRouteVector (std::list<DsrRouteCacheEntry> route);
414
  /**
414
  /**
415
   * \brief Find the same route in the route cache
415
   * \brief Find the same route in the route cache
416
   * \param rt entry with destination address dst, if exists
416
   * \param rt entry with destination address dst, if exists
417
   * \param rtVector the route vector
417
   * \param rtVector the route vector
418
   */
418
   */
419
  bool FindSameRoute (RouteCacheEntry & rt, std::list<RouteCacheEntry> & rtVector);
419
  bool FindSameRoute (DsrRouteCacheEntry & rt, std::list<DsrRouteCacheEntry> & rtVector);
420
  /**
420
  /**
421
   * \brief Delete the route with certain destination address
421
   * \brief Delete the route with certain destination address
422
   * \param dst the destination address of the routes that should be deleted
422
   * \param dst the destination address of the routes that should be deleted
 Lines 533-540    Link Here 
533
  }
533
  }
534
534
535
private:
535
private:
536
  RouteCache & operator= (RouteCache const &);
536
  DsrRouteCache & operator= (DsrRouteCache const &);
537
  RouteCacheEntry::IP_VECTOR m_vector;                  ///< The route vector to save the ip addresses for intermediate nodes.
537
  DsrRouteCacheEntry::IP_VECTOR m_vector;               ///< The route vector to save the ip addresses for intermediate nodes.
538
  uint32_t m_maxCacheLen;                               ///< The maximum number of packets that we allow a routing protocol to buffer.
538
  uint32_t m_maxCacheLen;                               ///< The maximum number of packets that we allow a routing protocol to buffer.
539
  Time     RouteCacheTimeout;                           ///< The maximum period of time that dsr is allowed to for an unused route.
539
  Time     RouteCacheTimeout;                           ///< The maximum period of time that dsr is allowed to for an unused route.
540
  Time     m_badLinkLifetime;                           ///< The time for which the neighboring node is put into the blacklist.
540
  Time     m_badLinkLifetime;                           ///< The time for which the neighboring node is put into the blacklist.
 Lines 549-555    Link Here 
549
  /**
549
  /**
550
   * Define the route cache data structure
550
   * Define the route cache data structure
551
   */
551
   */
552
  typedef std::list<RouteCacheEntry> routeEntryVector;
552
  typedef std::list<DsrRouteCacheEntry> routeEntryVector;
553
553
554
  std::map<Ipv4Address, routeEntryVector> m_sortedRoutes;       ///< Map the ipv4Address to route entry vector
554
  std::map<Ipv4Address, routeEntryVector> m_sortedRoutes;       ///< Map the ipv4Address to route entry vector
555
555
 Lines 574-588    Link Here 
574
   */
574
   */
575
  std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> > m_netGraph;
575
  std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> > m_netGraph;
576
576
577
  std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR> m_bestRoutesTable_link;     ///< for link route cache
577
  std::map<Ipv4Address, DsrRouteCacheEntry::IP_VECTOR> m_bestRoutesTable_link;     ///< for link route cache
578
  std::map<Link, LinkStab> m_linkCache;                                         ///< The data structure to store link info
578
  std::map<Link, DsrLinkStab> m_linkCache;                                         ///< The data structure to store link info
579
  std::map<Ipv4Address, NodeStab> m_nodeCache;                                  ///< The data structure to store node info
579
  std::map<Ipv4Address, DsrNodeStab> m_nodeCache;                                  ///< The data structure to store node info
580
  /**
580
  /**
581
   * \brief used by LookupRoute when LinkCache
581
   * \brief used by LookupRoute when LinkCache
582
   * \param id the ip address we are looking for
582
   * \param id the ip address we are looking for
583
   * \param rt the route cache entry to store the found one
583
   * \param rt the route cache entry to store the found one
584
   */
584
   */
585
  bool LookupRoute_Link (Ipv4Address id, RouteCacheEntry & rt);
585
  bool LookupRoute_Link (Ipv4Address id, DsrRouteCacheEntry & rt);
586
  /**
586
  /**
587
   * \brief increase the stability of the node
587
   * \brief increase the stability of the node
588
   * \param node the ip address of the node we want to increase stability
588
   * \param node the ip address of the node we want to increase stability
 Lines 602-608    Link Here 
602
   */
602
   */
603
  void SetCacheType (std::string type);
603
  void SetCacheType (std::string type);
604
  bool IsLinkCache ();
604
  bool IsLinkCache ();
605
  bool AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node);
605
  bool AddRoute_Link (DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node);
606
  /**
606
  /**
607
   *  \brief USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS
607
   *  \brief USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS
608
   *  \param source The source address the routes based on
608
   *  \param source The source address the routes based on
 Lines 615-621    Link Here 
615
   * amount of time since that link was last used. When a link is used in a route chosen for a packet originated or
615
   * amount of time since that link was last used. When a link is used in a route chosen for a packet originated or
616
   * salvaged by this node, the link's lifetime is set to be at least UseExtends into the future
616
   * salvaged by this node, the link's lifetime is set to be at least UseExtends into the future
617
   */
617
   */
618
  void UseExtends (RouteCacheEntry::IP_VECTOR rt);
618
  void UseExtends (DsrRouteCacheEntry::IP_VECTOR rt);
619
  /**
619
  /**
620
   *  \brief Update the Net Graph for the link and node cache has changed
620
   *  \brief Update the Net Graph for the link and node cache has changed
621
   */
621
   */
(-)a/src/dsr/model/dsr-routing.cc (-51 / +51 lines)
 Lines 116-135    Link Here 
116
                   PointerValue (0),
116
                   PointerValue (0),
117
                   MakePointerAccessor (&DsrRouting::SetRouteCache,
117
                   MakePointerAccessor (&DsrRouting::SetRouteCache,
118
                                        &DsrRouting::GetRouteCache),
118
                                        &DsrRouting::GetRouteCache),
119
                   MakePointerChecker<RouteCache> ())
119
                   MakePointerChecker<DsrRouteCache> ())
120
    .AddAttribute ("RreqTable",
120
    .AddAttribute ("RreqTable",
121
                   "The request table to manage route requests.",
121
                   "The request table to manage route requests.",
122
                   PointerValue (0),
122
                   PointerValue (0),
123
                   MakePointerAccessor (&DsrRouting::SetRequestTable,
123
                   MakePointerAccessor (&DsrRouting::SetRequestTable,
124
                                        &DsrRouting::GetRequestTable),
124
                                        &DsrRouting::GetRequestTable),
125
                   MakePointerChecker<RreqTable> ())
125
                   MakePointerChecker<DsrRreqTable> ())
126
    .AddAttribute ("PassiveBuffer",
126
    .AddAttribute ("PassiveBuffer",
127
                   "The passive buffer to manage "
127
                   "The passive buffer to manage "
128
                   "promisucously received passive ack.",
128
                   "promisucously received passive ack.",
129
                   PointerValue (0),
129
                   PointerValue (0),
130
                   MakePointerAccessor (&DsrRouting::SetPassiveBuffer,
130
                   MakePointerAccessor (&DsrRouting::SetPassiveBuffer,
131
                                        &DsrRouting::GetPassiveBuffer),
131
                                        &DsrRouting::GetPassiveBuffer),
132
                   MakePointerChecker<PassiveBuffer> ())
132
                   MakePointerChecker<DsrPassiveBuffer> ())
133
    .AddAttribute ("MaxSendBuffLen",
133
    .AddAttribute ("MaxSendBuffLen",
134
                   "Maximum number of packets that can be stored "
134
                   "Maximum number of packets that can be stored "
135
                   "in send buffer.",
135
                   "in send buffer.",
 Lines 433-439    Link Here 
433
      std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator, bool> result_i = m_priorityQueue.insert (std::make_pair (i, queue_i));
433
      std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator, bool> result_i = m_priorityQueue.insert (std::make_pair (i, queue_i));
434
      NS_ASSERT_MSG (result_i.second, "Error in creating queues");
434
      NS_ASSERT_MSG (result_i.second, "Error in creating queues");
435
    }
435
    }
436
  Ptr<dsr::RreqTable> rreqTable = CreateObject<dsr::RreqTable> ();
436
  Ptr<dsr::DsrRreqTable> rreqTable = CreateObject<dsr::DsrRreqTable> ();
437
  // Set the initial hop limit
437
  // Set the initial hop limit
438
  rreqTable->SetInitHopLimit (m_discoveryHopLimit);
438
  rreqTable->SetInitHopLimit (m_discoveryHopLimit);
439
  // Configure the request table parameters
439
  // Configure the request table parameters
 Lines 442-448    Link Here 
442
  rreqTable->SetUniqueRreqIdSize (m_maxRreqId);
442
  rreqTable->SetUniqueRreqIdSize (m_maxRreqId);
443
  SetRequestTable (rreqTable);
443
  SetRequestTable (rreqTable);
444
  // Set the passive buffer parameters using just the send buffer parameters
444
  // Set the passive buffer parameters using just the send buffer parameters
445
  Ptr<dsr::PassiveBuffer> passiveBuffer = CreateObject<dsr::PassiveBuffer> ();
445
  Ptr<dsr::DsrPassiveBuffer> passiveBuffer = CreateObject<dsr::DsrPassiveBuffer> ();
446
  passiveBuffer->SetMaxQueueLen (m_maxSendBuffLen);
446
  passiveBuffer->SetMaxQueueLen (m_maxSendBuffLen);
447
  passiveBuffer->SetPassiveBufferTimeout (m_sendBufferTimeout);
447
  passiveBuffer->SetPassiveBufferTimeout (m_sendBufferTimeout);
448
  SetPassiveBuffer (passiveBuffer);
448
  SetPassiveBuffer (passiveBuffer);
 Lines 472-478    Link Here 
472
              /*
472
              /*
473
               * Set dsr route cache
473
               * Set dsr route cache
474
               */
474
               */
475
              Ptr<dsr::RouteCache> routeCache = CreateObject<dsr::RouteCache> ();
475
              Ptr<dsr::DsrRouteCache> routeCache = CreateObject<dsr::DsrRouteCache> ();
476
              // Configure the path cache parameters
476
              // Configure the path cache parameters
477
              routeCache->SetCacheType (m_cacheType);
477
              routeCache->SetCacheType (m_cacheType);
478
              routeCache->SetSubRoute (m_subRoute);
478
              routeCache->SetSubRoute (m_subRoute);
 Lines 593-599    Link Here 
593
593
594
      Ptr<Packet> p = Create<Packet> ();
594
      Ptr<Packet> p = Create<Packet> ();
595
      // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
595
      // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
596
      MaintainBuffEntry newEntry;
596
      DsrMaintainBuffEntry newEntry;
597
      newEntry.SetPacket (p);
597
      newEntry.SetPacket (p);
598
      newEntry.SetSrc (sourceIp);
598
      newEntry.SetSrc (sourceIp);
599
      newEntry.SetDst (destinationIp);
599
      newEntry.SetDst (destinationIp);
 Lines 674-712    Link Here 
674
  return m_node;
674
  return m_node;
675
}
675
}
676
676
677
void DsrRouting::SetRouteCache (Ptr<dsr::RouteCache> r)
677
void DsrRouting::SetRouteCache (Ptr<dsr::DsrRouteCache> r)
678
{
678
{
679
  // / Set the route cache to use
679
  // / Set the route cache to use
680
  m_routeCache = r;
680
  m_routeCache = r;
681
}
681
}
682
682
683
Ptr<dsr::RouteCache>
683
Ptr<dsr::DsrRouteCache>
684
DsrRouting::GetRouteCache () const
684
DsrRouting::GetRouteCache () const
685
{
685
{
686
  // / Get the route cache to use
686
  // / Get the route cache to use
687
  return m_routeCache;
687
  return m_routeCache;
688
}
688
}
689
689
690
void DsrRouting::SetRequestTable (Ptr<dsr::RreqTable> q)
690
void DsrRouting::SetRequestTable (Ptr<dsr::DsrRreqTable> q)
691
{
691
{
692
  // / Set the request table to use
692
  // / Set the request table to use
693
  m_rreqTable = q;
693
  m_rreqTable = q;
694
}
694
}
695
695
696
Ptr<dsr::RreqTable>
696
Ptr<dsr::DsrRreqTable>
697
DsrRouting::GetRequestTable () const
697
DsrRouting::GetRequestTable () const
698
{
698
{
699
  // / Get the request table to use
699
  // / Get the request table to use
700
  return m_rreqTable;
700
  return m_rreqTable;
701
}
701
}
702
702
703
void DsrRouting::SetPassiveBuffer (Ptr<dsr::PassiveBuffer> p)
703
void DsrRouting::SetPassiveBuffer (Ptr<dsr::DsrPassiveBuffer> p)
704
{
704
{
705
  // / Set the request table to use
705
  // / Set the request table to use
706
  m_passiveBuffer = p;
706
  m_passiveBuffer = p;
707
}
707
}
708
708
709
Ptr<dsr::PassiveBuffer>
709
Ptr<dsr::DsrPassiveBuffer>
710
DsrRouting::GetPassiveBuffer () const
710
DsrRouting::GetPassiveBuffer () const
711
{
711
{
712
  // / Get the request table to use
712
  // / Get the request table to use
 Lines 736-759    Link Here 
736
  return m_routeCache->IsLinkCache ();
736
  return m_routeCache->IsLinkCache ();
737
}
737
}
738
738
739
void DsrRouting::UseExtends (RouteCacheEntry::IP_VECTOR rt)
739
void DsrRouting::UseExtends (DsrRouteCacheEntry::IP_VECTOR rt)
740
{
740
{
741
  m_routeCache->UseExtends (rt);
741
  m_routeCache->UseExtends (rt);
742
}
742
}
743
743
744
bool DsrRouting::LookupRoute (Ipv4Address id, RouteCacheEntry & rt)
744
bool DsrRouting::LookupRoute (Ipv4Address id, DsrRouteCacheEntry & rt)
745
{
745
{
746
  return m_routeCache->LookupRoute (id, rt);
746
  return m_routeCache->LookupRoute (id, rt);
747
}
747
}
748
748
749
bool DsrRouting::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
749
bool DsrRouting::AddRoute_Link (DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
750
{
750
{
751
  Ipv4Address nextHop = SearchNextHop (source, nodelist);
751
  Ipv4Address nextHop = SearchNextHop (source, nodelist);
752
  m_errorBuffer.DropPacketForErrLink (source, nextHop);
752
  m_errorBuffer.DropPacketForErrLink (source, nextHop);
753
  return m_routeCache->AddRoute_Link (nodelist, source);
753
  return m_routeCache->AddRoute_Link (nodelist, source);
754
}
754
}
755
755
756
bool DsrRouting::AddRoute (RouteCacheEntry & rt)
756
bool DsrRouting::AddRoute (DsrRouteCacheEntry & rt)
757
{
757
{
758
  std::vector<Ipv4Address> nodelist = rt.GetVector ();
758
  std::vector<Ipv4Address> nodelist = rt.GetVector ();
759
  Ipv4Address nextHop = SearchNextHop (m_mainAddress, nodelist);
759
  Ipv4Address nextHop = SearchNextHop (m_mainAddress, nodelist);
 Lines 925-935    Link Here 
925
  NS_LOG_INFO (Simulator::Now ().GetSeconds ()
925
  NS_LOG_INFO (Simulator::Now ().GetSeconds ()
926
               << " Checking send buffer at " << m_mainAddress << " with size " << m_sendBuffer.GetSize ());
926
               << " Checking send buffer at " << m_mainAddress << " with size " << m_sendBuffer.GetSize ());
927
927
928
  for (std::vector<SendBuffEntry>::iterator i = m_sendBuffer.GetBuffer ().begin (); i != m_sendBuffer.GetBuffer ().end (); )
928
  for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.GetBuffer ().begin (); i != m_sendBuffer.GetBuffer ().end (); )
929
    {
929
    {
930
      NS_LOG_DEBUG ("Here we try to find the data packet in the send buffer");
930
      NS_LOG_DEBUG ("Here we try to find the data packet in the send buffer");
931
      Ipv4Address destination = i->GetDestination ();
931
      Ipv4Address destination = i->GetDestination ();
932
      RouteCacheEntry toDst;
932
      DsrRouteCacheEntry toDst;
933
      bool findRoute = m_routeCache->LookupRoute (destination, toDst);
933
      bool findRoute = m_routeCache->LookupRoute (destination, toDst);
934
      if (findRoute)
934
      if (findRoute)
935
        {
935
        {
 Lines 1061-1067    Link Here 
1061
              cleanP->AddHeader (dsrRoutingHeader);
1061
              cleanP->AddHeader (dsrRoutingHeader);
1062
              Ptr<const Packet> mtP = cleanP->Copy ();
1062
              Ptr<const Packet> mtP = cleanP->Copy ();
1063
              // Put the data packet in the maintenance queue for data packet retransmission
1063
              // Put the data packet in the maintenance queue for data packet retransmission
1064
              MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
1064
              DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
1065
                                                      /*source=*/ m_mainAddress, /*destination=*/ destination, /*ackId=*/ 0,
1065
                                                      /*source=*/ m_mainAddress, /*destination=*/ destination, /*ackId=*/ 0,
1066
                                                      /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1066
                                                      /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1067
              bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
1067
              bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
 Lines 1200-1206    Link Here 
1200
{
1200
{
1201
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol);
1201
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol);
1202
  // Look up routes for the specific destination
1202
  // Look up routes for the specific destination
1203
  RouteCacheEntry toDst;
1203
  DsrRouteCacheEntry toDst;
1204
  bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1204
  bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1205
  // Queue the packet if there is no route pre-existing
1205
  // Queue the packet if there is no route pre-existing
1206
  if (!findRoute)
1206
  if (!findRoute)
 Lines 1209-1215    Link Here 
1209
                   << "s " << m_mainAddress << " there is no route for this packet, queue the packet");
1209
                   << "s " << m_mainAddress << " there is no route for this packet, queue the packet");
1210
1210
1211
      Ptr<Packet> p = packet->Copy ();
1211
      Ptr<Packet> p = packet->Copy ();
1212
      SendBuffEntry newEntry (p, destination, m_sendBufferTimeout, protocol);     // Create a new entry for send buffer
1212
      DsrSendBuffEntry newEntry (p, destination, m_sendBufferTimeout, protocol);     // Create a new entry for send buffer
1213
      bool result = m_sendBuffer.Enqueue (newEntry);     // Enqueue the packet in send buffer
1213
      bool result = m_sendBuffer.Enqueue (newEntry);     // Enqueue the packet in send buffer
1214
      if (result)
1214
      if (result)
1215
        {
1215
        {
 Lines 1260-1266    Link Here 
1260
      Ptr<const Packet> mtP = cleanP->Copy ();
1260
      Ptr<const Packet> mtP = cleanP->Copy ();
1261
      SetRoute (nextHop, m_mainAddress);
1261
      SetRoute (nextHop, m_mainAddress);
1262
      // Put the data packet in the maintenance queue for data packet retransmission
1262
      // Put the data packet in the maintenance queue for data packet retransmission
1263
      MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
1263
      DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
1264
                                              /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1264
                                              /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1265
                                              /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1265
                                              /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1266
      bool result = m_maintainBuffer.Enqueue (newEntry);     // Enqueue the packet the the maintenance buffer
1266
      bool result = m_maintainBuffer.Enqueue (newEntry);     // Enqueue the packet the the maintenance buffer
 Lines 1331-1337    Link Here 
1331
  uint8_t rerrLength = rerrUnreachHeader.GetLength ();
1331
  uint8_t rerrLength = rerrUnreachHeader.GetLength ();
1332
1332
1333
1333
1334
  RouteCacheEntry toDst;
1334
  DsrRouteCacheEntry toDst;
1335
  bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1335
  bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1336
  // Queue the packet if there is no route pre-existing
1336
  // Queue the packet if there is no route pre-existing
1337
  Ptr<Packet> newPacket = Create<Packet> ();
1337
  Ptr<Packet> newPacket = Create<Packet> ();
 Lines 1353-1359    Link Here 
1353
        newPacket->AddHeader (dsrRoutingHeader);
1353
        newPacket->AddHeader (dsrRoutingHeader);
1354
        Ptr<Packet> p = newPacket->Copy ();
1354
        Ptr<Packet> p = newPacket->Copy ();
1355
        // Save the error packet in the error buffer
1355
        // Save the error packet in the error buffer
1356
        ErrorBuffEntry newEntry (p, destination, m_mainAddress, unreachNode, m_sendBufferTimeout, protocol);
1356
        DsrErrorBuffEntry newEntry (p, destination, m_mainAddress, unreachNode, m_sendBufferTimeout, protocol);
1357
        bool result = m_errorBuffer.Enqueue (newEntry);                    // Enqueue the packet in send buffer
1357
        bool result = m_errorBuffer.Enqueue (newEntry);                    // Enqueue the packet in send buffer
1358
        if (result)
1358
        if (result)
1359
          {
1359
          {
 Lines 1484-1490    Link Here 
1484
  else
1484
  else
1485
    {
1485
    {
1486
      // Look up routes for the specific destination
1486
      // Look up routes for the specific destination
1487
      RouteCacheEntry toDst;
1487
      DsrRouteCacheEntry toDst;
1488
      bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1488
      bool findRoute = m_routeCache->LookupRoute (destination, toDst);
1489
      // Queue the packet if there is no route pre-existing
1489
      // Queue the packet if there is no route pre-existing
1490
      if (!findRoute)
1490
      if (!findRoute)
 Lines 1493-1499    Link Here 
1493
                       << "s " << m_mainAddress << " there is no route for this packet, queue the packet");
1493
                       << "s " << m_mainAddress << " there is no route for this packet, queue the packet");
1494
1494
1495
          Ptr<Packet> p = packet->Copy ();
1495
          Ptr<Packet> p = packet->Copy ();
1496
          SendBuffEntry newEntry (p, destination, m_sendBufferTimeout, protocol);     // Create a new entry for send buffer
1496
          DsrSendBuffEntry newEntry (p, destination, m_sendBufferTimeout, protocol);     // Create a new entry for send buffer
1497
          bool result = m_sendBuffer.Enqueue (newEntry);     // Enqueue the packet in send buffer
1497
          bool result = m_sendBuffer.Enqueue (newEntry);     // Enqueue the packet in send buffer
1498
          if (result)
1498
          if (result)
1499
            {
1499
            {
 Lines 1550-1556    Link Here 
1550
          Ptr<const Packet> mtP = cleanP->Copy ();
1550
          Ptr<const Packet> mtP = cleanP->Copy ();
1551
          NS_LOG_DEBUG ("maintain packet size " << cleanP->GetSize ());
1551
          NS_LOG_DEBUG ("maintain packet size " << cleanP->GetSize ());
1552
          // Put the data packet in the maintenance queue for data packet retransmission
1552
          // Put the data packet in the maintenance queue for data packet retransmission
1553
          MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
1553
          DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
1554
                                                  /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1554
                                                  /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1555
                                                  /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1555
                                                  /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1556
          bool result = m_maintainBuffer.Enqueue (newEntry);       // Enqueue the packet the the maintenance buffer
1556
          bool result = m_maintainBuffer.Enqueue (newEntry);       // Enqueue the packet the the maintenance buffer
 Lines 1818-1824    Link Here 
1818
        {
1818
        {
1819
          m_routeCache->UseExtends (nodeList);
1819
          m_routeCache->UseExtends (nodeList);
1820
        }
1820
        }
1821
      SendBuffEntry entry;
1821
      DsrSendBuffEntry entry;
1822
      if (m_sendBuffer.Dequeue (destination, entry))
1822
      if (m_sendBuffer.Dequeue (destination, entry))
1823
        {
1823
        {
1824
          Ptr<Packet> packet = entry.GetPacket ()->Copy ();
1824
          Ptr<Packet> packet = entry.GetPacket ()->Copy ();
 Lines 1838-1844    Link Here 
1838
1838
1839
          Ptr<const Packet> mtP = p->Copy ();
1839
          Ptr<const Packet> mtP = p->Copy ();
1840
          // Put the data packet in the maintenance queue for data packet retransmission
1840
          // Put the data packet in the maintenance queue for data packet retransmission
1841
          MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
1841
          DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
1842
                                      /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1842
                                      /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
1843
                                      /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1843
                                      /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
1844
          bool result = m_maintainBuffer.Enqueue (newEntry);       // Enqueue the packet the the maintenance buffer
1844
          bool result = m_maintainBuffer.Enqueue (newEntry);       // Enqueue the packet the the maintenance buffer
 Lines 1905-1911    Link Here 
1905
   */
1905
   */
1906
  else if (m_errorBuffer.Find (destination))
1906
  else if (m_errorBuffer.Find (destination))
1907
    {
1907
    {
1908
      ErrorBuffEntry entry;
1908
      DsrErrorBuffEntry entry;
1909
      if (m_errorBuffer.Dequeue (destination, entry))
1909
      if (m_errorBuffer.Dequeue (destination, entry))
1910
        {
1910
        {
1911
          Ptr<Packet> packet = entry.GetPacket ()->Copy ();
1911
          Ptr<Packet> packet = entry.GetPacket ()->Copy ();
 Lines 2014-2020    Link Here 
2014
2014
2015
  Ptr<Packet> p = packet->Copy ();
2015
  Ptr<Packet> p = packet->Copy ();
2016
  // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
2016
  // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
2017
  PassiveBuffEntry newEntry;
2017
  DsrPassiveBuffEntry newEntry;
2018
  newEntry.SetPacket (p);
2018
  newEntry.SetPacket (p);
2019
  newEntry.SetSource (source);
2019
  newEntry.SetSource (source);
2020
  newEntry.SetDestination (destination);
2020
  newEntry.SetDestination (destination);
 Lines 2031-2037    Link Here 
2031
      // It only compares the source and destination address, ackId, and the segments left value
2031
      // It only compares the source and destination address, ackId, and the segments left value
2032
      NS_LOG_DEBUG ("We get the all equal for passive buffer here");
2032
      NS_LOG_DEBUG ("We get the all equal for passive buffer here");
2033
2033
2034
      MaintainBuffEntry mbEntry;
2034
      DsrMaintainBuffEntry mbEntry;
2035
      mbEntry.SetPacket (p);
2035
      mbEntry.SetPacket (p);
2036
      mbEntry.SetSrc (source);
2036
      mbEntry.SetSrc (source);
2037
      mbEntry.SetDst (destination);
2037
      mbEntry.SetDst (destination);
 Lines 2059-2065    Link Here 
2059
2059
2060
  Ptr<Packet> p = packet->Copy ();
2060
  Ptr<Packet> p = packet->Copy ();
2061
  // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
2061
  // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
2062
  MaintainBuffEntry newEntry;
2062
  DsrMaintainBuffEntry newEntry;
2063
  newEntry.SetPacket (p);
2063
  newEntry.SetPacket (p);
2064
  newEntry.SetSrc (source);
2064
  newEntry.SetSrc (source);
2065
  newEntry.SetDst (destination);
2065
  newEntry.SetDst (destination);
 Lines 2087-2100    Link Here 
2087
   * The reason is ack header doesn't have the original packet copy
2087
   * The reason is ack header doesn't have the original packet copy
2088
   */
2088
   */
2089
  Ptr<Packet> mainP = Create<Packet> ();
2089
  Ptr<Packet> mainP = Create<Packet> ();
2090
  MaintainBuffEntry newEntry (/*Packet=*/ mainP, /*ourAddress=*/ sender, /*nextHop=*/ receiver,
2090
  DsrMaintainBuffEntry newEntry (/*Packet=*/ mainP, /*ourAddress=*/ sender, /*nextHop=*/ receiver,
2091
                                          /*source=*/ realSrc, /*destination=*/ realDst, /*ackId=*/ ackId,
2091
                                          /*source=*/ realSrc, /*destination=*/ realDst, /*ackId=*/ ackId,
2092
                                          /*SegsLeft=*/ 0, /*expire time=*/ Simulator::Now ());
2092
                                          /*SegsLeft=*/ 0, /*expire time=*/ Simulator::Now ());
2093
  CancelNetworkPacketTimer (newEntry);  // Only need to cancel network packet timer
2093
  CancelNetworkPacketTimer (newEntry);  // Only need to cancel network packet timer
2094
}
2094
}
2095
2095
2096
void 
2096
void 
2097
DsrRouting::CancelPacketAllTimer (MaintainBuffEntry & mb)
2097
DsrRouting::CancelPacketAllTimer (DsrMaintainBuffEntry & mb)
2098
{
2098
{
2099
  NS_LOG_FUNCTION (this);
2099
  NS_LOG_FUNCTION (this);
2100
  CancelLinkPacketTimer (mb);
2100
  CancelLinkPacketTimer (mb);
 Lines 2103-2109    Link Here 
2103
}
2103
}
2104
2104
2105
void
2105
void
2106
DsrRouting::CancelLinkPacketTimer (MaintainBuffEntry & mb)
2106
DsrRouting::CancelLinkPacketTimer (DsrMaintainBuffEntry & mb)
2107
{
2107
{
2108
  NS_LOG_FUNCTION (this);
2108
  NS_LOG_FUNCTION (this);
2109
  LinkKey linkKey;
2109
  LinkKey linkKey;
 Lines 2153-2159    Link Here 
2153
}
2153
}
2154
2154
2155
void
2155
void
2156
DsrRouting::CancelNetworkPacketTimer (MaintainBuffEntry & mb)
2156
DsrRouting::CancelNetworkPacketTimer (DsrMaintainBuffEntry & mb)
2157
{
2157
{
2158
  NS_LOG_FUNCTION (this);
2158
  NS_LOG_FUNCTION (this);
2159
  NetworkKey networkKey;
2159
  NetworkKey networkKey;
 Lines 2203-2209    Link Here 
2203
}
2203
}
2204
2204
2205
void
2205
void
2206
DsrRouting::CancelPassivePacketTimer (MaintainBuffEntry & mb)
2206
DsrRouting::CancelPassivePacketTimer (DsrMaintainBuffEntry & mb)
2207
{
2207
{
2208
  NS_LOG_FUNCTION (this);
2208
  NS_LOG_FUNCTION (this);
2209
  PassiveKey passiveKey;
2209
  PassiveKey passiveKey;
 Lines 2243-2249    Link Here 
2243
{
2243
{
2244
  NS_LOG_FUNCTION (this << nextHop << (uint32_t)protocol);
2244
  NS_LOG_FUNCTION (this << nextHop << (uint32_t)protocol);
2245
2245
2246
  MaintainBuffEntry entry;
2246
  DsrMaintainBuffEntry entry;
2247
  std::vector<Ipv4Address> previousErrorDst;
2247
  std::vector<Ipv4Address> previousErrorDst;
2248
  if (m_maintainBuffer.Dequeue (nextHop, entry))
2248
  if (m_maintainBuffer.Dequeue (nextHop, entry))
2249
    {
2249
    {
 Lines 2339-2345    Link Here 
2339
  /*
2339
  /*
2340
   * Look in the route cache for other routes for this destination
2340
   * Look in the route cache for other routes for this destination
2341
   */
2341
   */
2342
  RouteCacheEntry toDst;
2342
  DsrRouteCacheEntry toDst;
2343
  bool findRoute = m_routeCache->LookupRoute (dst, toDst);
2343
  bool findRoute = m_routeCache->LookupRoute (dst, toDst);
2344
  if (findRoute && (salvage < m_maxSalvageCount))
2344
  if (findRoute && (salvage < m_maxSalvageCount))
2345
    {
2345
    {
 Lines 2411-2417    Link Here 
2411
}
2411
}
2412
2412
2413
void
2413
void
2414
DsrRouting::ScheduleLinkPacketRetry (MaintainBuffEntry & mb,
2414
DsrRouting::ScheduleLinkPacketRetry (DsrMaintainBuffEntry & mb,
2415
                                     uint8_t protocol)
2415
                                     uint8_t protocol)
2416
{
2416
{
2417
  NS_LOG_FUNCTION (this << (uint32_t) protocol);
2417
  NS_LOG_FUNCTION (this << (uint32_t) protocol);
 Lines 2441-2447    Link Here 
2441
}
2441
}
2442
2442
2443
void
2443
void
2444
DsrRouting::SchedulePassivePacketRetry (MaintainBuffEntry & mb,
2444
DsrRouting::SchedulePassivePacketRetry (DsrMaintainBuffEntry & mb,
2445
                                        uint8_t protocol)
2445
                                        uint8_t protocol)
2446
{
2446
{
2447
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
2447
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
 Lines 2472-2478    Link Here 
2472
}
2472
}
2473
2473
2474
void
2474
void
2475
DsrRouting::ScheduleNetworkPacketRetry (MaintainBuffEntry & mb,
2475
DsrRouting::ScheduleNetworkPacketRetry (DsrMaintainBuffEntry & mb,
2476
                                        bool isFirst,
2476
                                        bool isFirst,
2477
                                        uint8_t protocol)
2477
                                        uint8_t protocol)
2478
{
2478
{
 Lines 2495-2501    Link Here 
2495
      SendPacket (p, source, nextHop, protocol);
2495
      SendPacket (p, source, nextHop, protocol);
2496
2496
2497
      dsrP = p->Copy ();
2497
      dsrP = p->Copy ();
2498
      MaintainBuffEntry newEntry = mb;
2498
      DsrMaintainBuffEntry newEntry = mb;
2499
      // The function AllEqual will find the exact entry and delete it if found
2499
      // The function AllEqual will find the exact entry and delete it if found
2500
      m_maintainBuffer.AllEqual (mb);
2500
      m_maintainBuffer.AllEqual (mb);
2501
      newEntry.SetPacket (dsrP);
2501
      newEntry.SetPacket (dsrP);
 Lines 2580-2586    Link Here 
2580
}
2580
}
2581
2581
2582
void
2582
void
2583
DsrRouting::LinkScheduleTimerExpire  (MaintainBuffEntry & mb,
2583
DsrRouting::LinkScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
2584
                                      uint8_t protocol)
2584
                                      uint8_t protocol)
2585
{
2585
{
2586
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
2586
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
 Lines 2627-2633    Link Here 
2627
}
2627
}
2628
2628
2629
void
2629
void
2630
DsrRouting::PassiveScheduleTimerExpire  (MaintainBuffEntry & mb,
2630
DsrRouting::PassiveScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
2631
                                         uint8_t protocol)
2631
                                         uint8_t protocol)
2632
{
2632
{
2633
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
2633
  NS_LOG_FUNCTION (this << (uint32_t)protocol);
 Lines 2676-2682    Link Here 
2676
}
2676
}
2677
2677
2678
void
2678
void
2679
DsrRouting::NetworkScheduleTimerExpire  (MaintainBuffEntry & mb,
2679
DsrRouting::NetworkScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
2680
                                         uint8_t protocol)
2680
                                         uint8_t protocol)
2681
{
2681
{
2682
  Ptr<Packet> p = mb.GetPacket ()->Copy ();
2682
  Ptr<Packet> p = mb.GetPacket ()->Copy ();
 Lines 2739-2745    Link Here 
2739
2739
2740
  Ptr<const Packet> mtP = p->Copy ();
2740
  Ptr<const Packet> mtP = p->Copy ();
2741
2741
2742
  MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
2742
  DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
2743
                              /*source=*/ source, /*destination=*/ targetAddress, /*ackId=*/ m_ackId,
2743
                              /*source=*/ source, /*destination=*/ targetAddress, /*ackId=*/ m_ackId,
2744
                              /*SegsLeft=*/ sourceRoute.GetSegmentsLeft (), /*expire time=*/ m_maxMaintainTime);
2744
                              /*SegsLeft=*/ sourceRoute.GetSegmentsLeft (), /*expire time=*/ m_maxMaintainTime);
2745
  bool result = m_maintainBuffer.Enqueue (newEntry);
2745
  bool result = m_maintainBuffer.Enqueue (newEntry);
 Lines 2848-2854    Link Here 
2848
  NS_LOG_DEBUG ("our own address here " << m_mainAddress << " error source " << rerr.GetErrorSrc () << " error destination " << rerr.GetErrorDst ()
2848
  NS_LOG_DEBUG ("our own address here " << m_mainAddress << " error source " << rerr.GetErrorSrc () << " error destination " << rerr.GetErrorDst ()
2849
                                        << " error next hop " << rerr.GetUnreachNode () << " original dst " << rerr.GetOriginalDst ()
2849
                                        << " error next hop " << rerr.GetUnreachNode () << " original dst " << rerr.GetOriginalDst ()
2850
                );
2850
                );
2851
  RouteCacheEntry toDst;
2851
  DsrRouteCacheEntry toDst;
2852
  if (m_routeCache->LookupRoute (dst, toDst))
2852
  if (m_routeCache->LookupRoute (dst, toDst))
2853
    {
2853
    {
2854
      /*
2854
      /*
 Lines 3075-3081    Link Here 
3075
3075
3076
  Ipv4Address source = address[0];
3076
  Ipv4Address source = address[0];
3077
  Ipv4Address dst = address[1];
3077
  Ipv4Address dst = address[1];
3078
  RouteCacheEntry toDst;
3078
  DsrRouteCacheEntry toDst;
3079
  if (m_routeCache->LookupRoute (dst, toDst))
3079
  if (m_routeCache->LookupRoute (dst, toDst))
3080
    {
3080
    {
3081
      /*
3081
      /*
(-)a/src/dsr/model/dsr-routing.h (-27 / +27 lines)
 Lines 126-165    Link Here 
126
   * \brief Set the route cache.
126
   * \brief Set the route cache.
127
   * \param r the route cache to set
127
   * \param r the route cache to set
128
   */
128
   */
129
  void SetRouteCache (Ptr<dsr::RouteCache> r);
129
  void SetRouteCache (Ptr<dsr::DsrRouteCache> r);
130
  /**
130
  /**
131
   * \brief Get the route cache.
131
   * \brief Get the route cache.
132
   * \return the route cache
132
   * \return the route cache
133
   */
133
   */
134
  Ptr<dsr::RouteCache> GetRouteCache () const;
134
  Ptr<dsr::DsrRouteCache> GetRouteCache () const;
135
  /**
135
  /**
136
   * \brief Set the node.
136
   * \brief Set the node.
137
   * \param r the request table to set
137
   * \param r the request table to set
138
   */
138
   */
139
  void SetRequestTable (Ptr<dsr::RreqTable> r);
139
  void SetRequestTable (Ptr<dsr::DsrRreqTable> r);
140
  /**
140
  /**
141
    * \brief Get the request table.
141
    * \brief Get the request table.
142
    * \return the request table
142
    * \return the request table
143
    */
143
    */
144
  Ptr<dsr::RreqTable> GetRequestTable () const;
144
  Ptr<dsr::DsrRreqTable> GetRequestTable () const;
145
  /**
145
  /**
146
   * \brief Set the node.
146
   * \brief Set the node.
147
   * \param r the passive buffer to set
147
   * \param r the passive buffer to set
148
   */
148
   */
149
  void SetPassiveBuffer (Ptr<dsr::PassiveBuffer> r);
149
  void SetPassiveBuffer (Ptr<dsr::DsrPassiveBuffer> r);
150
  /**
150
  /**
151
    * \brief Get the passive buffer
151
    * \brief Get the passive buffer
152
    * \return the passive buffer
152
    * \return the passive buffer
153
    */
153
    */
154
  Ptr<dsr::PassiveBuffer> GetPassiveBuffer () const;
154
  Ptr<dsr::DsrPassiveBuffer> GetPassiveBuffer () const;
155
155
156
  /// functions used to direct to route cache
156
  /// functions used to direct to route cache
157
  //\{
157
  //\{
158
  bool IsLinkCache ();
158
  bool IsLinkCache ();
159
  void UseExtends (RouteCacheEntry::IP_VECTOR rt);
159
  void UseExtends (DsrRouteCacheEntry::IP_VECTOR rt);
160
  bool LookupRoute (Ipv4Address id, RouteCacheEntry & rt);
160
  bool LookupRoute (Ipv4Address id, DsrRouteCacheEntry & rt);
161
  bool AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source);
161
  bool AddRoute_Link (DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source);
162
  bool AddRoute (RouteCacheEntry & rt);
162
  bool AddRoute (DsrRouteCacheEntry & rt);
163
  void DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node);
163
  void DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node);
164
  bool UpdateRouteEntry (Ipv4Address dst);
164
  bool UpdateRouteEntry (Ipv4Address dst);
165
  bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
165
  bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
 Lines 307-313    Link Here 
307
  /**
307
  /**
308
  * \brief Cancel all the packet timers
308
  * \brief Cancel all the packet timers
309
  */
309
  */
310
  void CancelPacketAllTimer (MaintainBuffEntry & mb);
310
  void CancelPacketAllTimer (DsrMaintainBuffEntry & mb);
311
  /**
311
  /**
312
   * \brief Cancel the passive timer
312
   * \brief Cancel the passive timer
313
   */
313
   */
 Lines 319-333    Link Here 
319
  /**
319
  /**
320
   * \brief Cancel the network packet retransmission timer for a specific maintenance entry
320
   * \brief Cancel the network packet retransmission timer for a specific maintenance entry
321
   */
321
   */
322
  void CancelNetworkPacketTimer (MaintainBuffEntry & mb);
322
  void CancelNetworkPacketTimer (DsrMaintainBuffEntry & mb);
323
  /**
323
  /**
324
   * \brief Cancel the passive packet retransmission timer for a specific maintenance entry
324
   * \brief Cancel the passive packet retransmission timer for a specific maintenance entry
325
   */
325
   */
326
  void CancelPassivePacketTimer (MaintainBuffEntry & mb);
326
  void CancelPassivePacketTimer (DsrMaintainBuffEntry & mb);
327
  /**
327
  /**
328
   * \brief Cancel the link packet retransmission timer for a specific maintenance entry
328
   * \brief Cancel the link packet retransmission timer for a specific maintenance entry
329
   */
329
   */
330
  void CancelLinkPacketTimer (MaintainBuffEntry & mb);
330
  void CancelLinkPacketTimer (DsrMaintainBuffEntry & mb);
331
  /**
331
  /**
332
   * \brief Cancel the packet retransmission timer for a all maintenance entries with nextHop address
332
   * \brief Cancel the packet retransmission timer for a all maintenance entries with nextHop address
333
   */
333
   */
 Lines 341-354    Link Here 
341
   * \param mb maintainenace buffer entry
341
   * \param mb maintainenace buffer entry
342
   * \param protocol the protocol number
342
   * \param protocol the protocol number
343
   */
343
   */
344
  void ScheduleLinkPacketRetry   (MaintainBuffEntry & mb,
344
  void ScheduleLinkPacketRetry   (DsrMaintainBuffEntry & mb,
345
                                  uint8_t protocol);
345
                                  uint8_t protocol);
346
  /**
346
  /**
347
   * \brief Schedule the packet retransmission based on passive acknowledgment
347
   * \brief Schedule the packet retransmission based on passive acknowledgment
348
   * \param mb maintainenace buffer entry
348
   * \param mb maintainenace buffer entry
349
   * \param protocol the protocol number
349
   * \param protocol the protocol number
350
   */
350
   */
351
  void SchedulePassivePacketRetry   (MaintainBuffEntry & mb,
351
  void SchedulePassivePacketRetry   (DsrMaintainBuffEntry & mb,
352
                                     uint8_t protocol);
352
                                     uint8_t protocol);
353
  /**
353
  /**
354
   * \brief Schedule the packet retransmission based on network layer acknowledgment
354
   * \brief Schedule the packet retransmission based on network layer acknowledgment
 Lines 356-378    Link Here 
356
   * \param isFirst see if this is the first packet retry or not
356
   * \param isFirst see if this is the first packet retry or not
357
   * \param protocol the protocol number
357
   * \param protocol the protocol number
358
   */
358
   */
359
  void ScheduleNetworkPacketRetry   (MaintainBuffEntry & mb,
359
  void ScheduleNetworkPacketRetry   (DsrMaintainBuffEntry & mb,
360
                                     bool isFirst,
360
                                     bool isFirst,
361
                                     uint8_t protocol);
361
                                     uint8_t protocol);
362
  /**
362
  /**
363
   * \brief This function deals with packet retransmission timer expire using link acknowledgment
363
   * \brief This function deals with packet retransmission timer expire using link acknowledgment
364
   */
364
   */
365
  void LinkScheduleTimerExpire  (MaintainBuffEntry & mb,
365
  void LinkScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
366
                                 uint8_t protocol);
366
                                 uint8_t protocol);
367
  /**
367
  /**
368
   * \brief This function deals with packet retransmission timer expire using network acknowledgment
368
   * \brief This function deals with packet retransmission timer expire using network acknowledgment
369
   */
369
   */
370
  void NetworkScheduleTimerExpire  (MaintainBuffEntry & mb,
370
  void NetworkScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
371
                                    uint8_t protocol);
371
                                    uint8_t protocol);
372
  /**
372
  /**
373
   * \brief This function deals with packet retransmission timer expire using passive acknowledgment
373
   * \brief This function deals with packet retransmission timer expire using passive acknowledgment
374
   */
374
   */
375
  void PassiveScheduleTimerExpire  (MaintainBuffEntry & mb,
375
  void PassiveScheduleTimerExpire  (DsrMaintainBuffEntry & mb,
376
                                    uint8_t protocol);
376
                                    uint8_t protocol);
377
  /**
377
  /**
378
   * \brief Forward the packet using the route saved in the source route option header
378
   * \brief Forward the packet using the route saved in the source route option header
 Lines 654-662    Link Here 
654
654
655
  Time  m_sendBufferTimeout;                            ///< The maximum period of time that a routing protocol is allowed to buffer a packet for.
655
  Time  m_sendBufferTimeout;                            ///< The maximum period of time that a routing protocol is allowed to buffer a packet for.
656
656
657
  SendBuffer m_sendBuffer;                              ///< The send buffer
657
  DsrSendBuffer m_sendBuffer;                           ///< The send buffer
658
658
659
  ErrorBuffer m_errorBuffer;                            ///< The error buffer to save the error messages
659
  DsrErrorBuffer m_errorBuffer;                         ///< The error buffer to save the error messages
660
660
661
  uint32_t  m_maxMaintainLen;                           ///< Max # of entries for maintainance buffer
661
  uint32_t  m_maxMaintainLen;                           ///< Max # of entries for maintainance buffer
662
662
 Lines 670-676    Link Here 
670
670
671
  uint32_t  m_maxEntriesEachDst;                        ///< Max number of route entries to save for each destination
671
  uint32_t  m_maxEntriesEachDst;                        ///< Max number of route entries to save for each destination
672
672
673
  MaintainBuffer m_maintainBuffer;                      ///< The declaration of maintain buffer
673
  DsrMaintainBuffer m_maintainBuffer;                   ///< The declaration of maintain buffer
674
674
675
  uint32_t m_requestId;                                 ///< The id assigned to each route request
675
  uint32_t m_requestId;                                 ///< The id assigned to each route request
676
676
 Lines 742-752    Link Here 
742
742
743
  std::map<LinkKey, Timer> m_linkAckTimer;              ///< The timer for link acknowledgment
743
  std::map<LinkKey, Timer> m_linkAckTimer;              ///< The timer for link acknowledgment
744
744
745
  Ptr<dsr::RouteCache> m_routeCache;                    ///< A "drop-front" queue used by the routing layer to cache routes found.
745
  Ptr<dsr::DsrRouteCache> m_routeCache;                 ///< A "drop-front" queue used by the routing layer to cache routes found.
746
746
747
  Ptr<dsr::RreqTable> m_rreqTable;                      ///< A "drop-front" queue used by the routing layer to cache route request sent.
747
  Ptr<dsr::DsrRreqTable> m_rreqTable;                   ///< A "drop-front" queue used by the routing layer to cache route request sent.
748
748
749
  Ptr<dsr::PassiveBuffer> m_passiveBuffer;              ///< A "drop-front" queue used by the routing layer to cache route request sent.
749
  Ptr<dsr::DsrPassiveBuffer> m_passiveBuffer;           ///< A "drop-front" queue used by the routing layer to cache route request sent.
750
750
751
  uint32_t m_numPriorityQueues;                         ///< The number of priority queues used
751
  uint32_t m_numPriorityQueues;                         ///< The number of priority queues used
752
752
 Lines 754-760    Link Here 
754
754
755
  std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue;   ///< priority queues
755
  std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue;   ///< priority queues
756
756
757
  GraReply m_graReply;                                  ///< The gratuitous route reply.
757
  DsrGraReply m_graReply;                               ///< The gratuitous route reply.
758
758
759
  DsrNetworkQueue m_networkQueue;                       ///< The network queue.
759
  DsrNetworkQueue m_networkQueue;                       ///< The network queue.
760
760
(-)a/src/dsr/model/dsr-rreq-table.cc (-22 / +22 lines)
 Lines 36-69    Link Here 
36
36
37
namespace ns3 {
37
namespace ns3 {
38
38
39
NS_LOG_COMPONENT_DEFINE ("RreqTable");
39
NS_LOG_COMPONENT_DEFINE ("DsrRreqTable");
40
  
40
  
41
namespace dsr {
41
namespace dsr {
42
42
43
NS_OBJECT_ENSURE_REGISTERED (RreqTable);
43
NS_OBJECT_ENSURE_REGISTERED (DsrRreqTable);
44
44
45
TypeId RreqTable::GetTypeId ()
45
TypeId DsrRreqTable::GetTypeId ()
46
{
46
{
47
  static TypeId tid = TypeId ("ns3::dsr::RreqTable")
47
  static TypeId tid = TypeId ("ns3::dsr::DsrRreqTable")
48
    .SetParent<Object> ()
48
    .SetParent<Object> ()
49
    .SetGroupName ("Dsr")
49
    .SetGroupName ("Dsr")
50
    .AddConstructor<RreqTable> ()
50
    .AddConstructor<DsrRreqTable> ()
51
  ;
51
  ;
52
  return tid;
52
  return tid;
53
}
53
}
54
54
55
RreqTable::RreqTable ()
55
DsrRreqTable::DsrRreqTable ()
56
  : m_linkStates (PROBABLE)
56
  : m_linkStates (PROBABLE)
57
{
57
{
58
}
58
}
59
59
60
RreqTable::~RreqTable ()
60
DsrRreqTable::~DsrRreqTable ()
61
{
61
{
62
  NS_LOG_FUNCTION_NOARGS ();
62
  NS_LOG_FUNCTION_NOARGS ();
63
}
63
}
64
64
65
void
65
void
66
RreqTable::RemoveLeastExpire (std::map<Ipv4Address, RreqTableEntry > & rreqDstMap)
66
DsrRreqTable::RemoveLeastExpire (std::map<Ipv4Address, RreqTableEntry > & rreqDstMap)
67
{
67
{
68
  NS_LOG_FUNCTION (this);
68
  NS_LOG_FUNCTION (this);
69
  Ipv4Address firstExpire;
69
  Ipv4Address firstExpire;
 Lines 83-89    Link Here 
83
}
83
}
84
84
85
void
85
void
86
RreqTable::FindAndUpdate (Ipv4Address dst)
86
DsrRreqTable::FindAndUpdate (Ipv4Address dst)
87
{
87
{
88
  NS_LOG_FUNCTION (this << dst);
88
  NS_LOG_FUNCTION (this << dst);
89
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
89
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
 Lines 116-122    Link Here 
116
}
116
}
117
117
118
void
118
void
119
RreqTable::RemoveRreqEntry (Ipv4Address dst)
119
DsrRreqTable::RemoveRreqEntry (Ipv4Address dst)
120
{
120
{
121
  NS_LOG_FUNCTION (this << dst);
121
  NS_LOG_FUNCTION (this << dst);
122
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
122
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
 Lines 133-139    Link Here 
133
}
133
}
134
134
135
uint32_t
135
uint32_t
136
RreqTable::GetRreqCnt (Ipv4Address dst)
136
DsrRreqTable::GetRreqCnt (Ipv4Address dst)
137
{
137
{
138
  NS_LOG_FUNCTION (this << dst);
138
  NS_LOG_FUNCTION (this << dst);
139
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
139
  std::map<Ipv4Address, RreqTableEntry >::const_iterator i =
 Lines 156-162    Link Here 
156
 * Essentially a counter
156
 * Essentially a counter
157
 */
157
 */
158
uint32_t
158
uint32_t
159
RreqTable::CheckUniqueRreqId (Ipv4Address dst)
159
DsrRreqTable::CheckUniqueRreqId (Ipv4Address dst)
160
{
160
{
161
  NS_LOG_LOGIC ("The size of id cache " << m_rreqIdCache.size ());
161
  NS_LOG_LOGIC ("The size of id cache " << m_rreqIdCache.size ());
162
  std::map<Ipv4Address, uint32_t>::const_iterator i =
162
  std::map<Ipv4Address, uint32_t>::const_iterator i =
 Lines 188-194    Link Here 
188
}
188
}
189
189
190
uint32_t
190
uint32_t
191
RreqTable::GetRreqSize ()
191
DsrRreqTable::GetRreqSize ()
192
{
192
{
193
  return m_rreqIdCache.size ();
193
  return m_rreqIdCache.size ();
194
}
194
}
 Lines 199-205    Link Here 
199
 */
199
 */
200
200
201
void
201
void
202
RreqTable::Invalidate ()
202
DsrRreqTable::Invalidate ()
203
{
203
{
204
  if (m_linkStates == QUESTIONABLE)
204
  if (m_linkStates == QUESTIONABLE)
205
    {
205
    {
 Lines 209-215    Link Here 
209
}
209
}
210
210
211
BlackList*
211
BlackList*
212
RreqTable::FindUnidirectional (Ipv4Address neighbor)
212
DsrRreqTable::FindUnidirectional (Ipv4Address neighbor)
213
{
213
{
214
  PurgeNeighbor ();  // purge the neighbor cache
214
  PurgeNeighbor ();  // purge the neighbor cache
215
  for (std::vector<BlackList>::iterator i = m_blackList.begin ();
215
  for (std::vector<BlackList>::iterator i = m_blackList.begin ();
 Lines 224-230    Link Here 
224
}
224
}
225
225
226
bool
226
bool
227
RreqTable::MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout)
227
DsrRreqTable::MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout)
228
{
228
{
229
  NS_LOG_LOGIC ("Add neighbor address in blacklist " << m_blackList.size ());
229
  NS_LOG_LOGIC ("Add neighbor address in blacklist " << m_blackList.size ());
230
  for (std::vector<BlackList>::iterator i = m_blackList.begin (); i != m_blackList.end (); i++)
230
  for (std::vector<BlackList>::iterator i = m_blackList.begin (); i != m_blackList.end (); i++)
 Lines 243-249    Link Here 
243
}
243
}
244
244
245
void
245
void
246
RreqTable::PurgeNeighbor ()
246
DsrRreqTable::PurgeNeighbor ()
247
{
247
{
248
  /*
248
  /*
249
   * Purge the expired blacklist entries
249
   * Purge the expired blacklist entries
 Lines 253-269    Link Here 
253
}
253
}
254
254
255
bool
255
bool
256
RreqTable::FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id)
256
DsrRreqTable::FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id)
257
{
257
{
258
  NS_LOG_FUNCTION (this << src << dst << id);
258
  NS_LOG_FUNCTION (this << src << dst << id);
259
  ReceivedRreqEntry rreqEntry;
259
  DsrReceivedRreqEntry rreqEntry;
260
  rreqEntry.SetDestination (dst);
260
  rreqEntry.SetDestination (dst);
261
  rreqEntry.SetIdentification (id);
261
  rreqEntry.SetIdentification (id);
262
  std::list<ReceivedRreqEntry> receivedRreqEntryList;
262
  std::list<DsrReceivedRreqEntry> receivedRreqEntryList;
263
  /*
263
  /*
264
   * this function will return false if the entry is not found, true if duplicate entry find
264
   * this function will return false if the entry is not found, true if duplicate entry find
265
   */
265
   */
266
  std::map<Ipv4Address, std::list<ReceivedRreqEntry> >::const_iterator i = m_sourceRreqMap.find (src);
266
  std::map<Ipv4Address, std::list<DsrReceivedRreqEntry> >::const_iterator i = m_sourceRreqMap.find (src);
267
  if (i == m_sourceRreqMap.end ())
267
  if (i == m_sourceRreqMap.end ())
268
    {
268
    {
269
      NS_LOG_LOGIC ("The source request table entry for " << src << " not found");
269
      NS_LOG_LOGIC ("The source request table entry for " << src << " not found");
 Lines 287-293    Link Here 
287
        }
287
        }
288
      Ipv4Address src = i->first;
288
      Ipv4Address src = i->first;
289
      // We loop the receive rreq entry to find duplicate
289
      // We loop the receive rreq entry to find duplicate
290
      for (std::list<ReceivedRreqEntry>::const_iterator j = receivedRreqEntryList.begin (); j != receivedRreqEntryList.end (); ++j)
290
      for (std::list<DsrReceivedRreqEntry>::const_iterator j = receivedRreqEntryList.begin (); j != receivedRreqEntryList.end (); ++j)
291
        {
291
        {
292
          if (*j == rreqEntry)          /// Check if we have found one duplication entry or not
292
          if (*j == rreqEntry)          /// Check if we have found one duplication entry or not
293
            {
293
            {
(-)a/src/dsr/model/dsr-rreq-table.h (-11 / +11 lines)
 Lines 83-108    Link Here 
83
 * The request entry for intermediate nodes to check if they have received this request or not
83
 * The request entry for intermediate nodes to check if they have received this request or not
84
 * This is used to control the duplication request from being processed
84
 * This is used to control the duplication request from being processed
85
 */
85
 */
86
class ReceivedRreqEntry
86
class DsrReceivedRreqEntry
87
{
87
{
88
public:
88
public:
89
  /**
89
  /**
90
   * Construct a ReceivedRreqEntry with the given parameters
90
   * Construct a DsrReceivedRreqEntry with the given parameters
91
   *
91
   *
92
   * \param d IPv4 address of the destination
92
   * \param d IPv4 address of the destination
93
   * \param i identification
93
   * \param i identification
94
   */
94
   */
95
  ReceivedRreqEntry (Ipv4Address d = Ipv4Address (), uint16_t i = 0)
95
  DsrReceivedRreqEntry (Ipv4Address d = Ipv4Address (), uint16_t i = 0)
96
    : m_destination (d),
96
    : m_destination (d),
97
      m_identification (i)
97
      m_identification (i)
98
  {
98
  {
99
  }
99
  }
100
  /**
100
  /**
101
   * \brief Compare send buffer entries (destination address and identification)
101
   * \brief Compare send buffer entries (destination address and identification)
102
   * \param o another ReceivedRreqEntry
102
   * \param o another DsrReceivedRreqEntry
103
   * \return true if equal
103
   * \return true if equal
104
   */
104
   */
105
  bool operator== (ReceivedRreqEntry const & o) const
105
  bool operator== (DsrReceivedRreqEntry const & o) const
106
  {
106
  {
107
    return ((m_destination == o.m_destination) && (m_identification == o.m_identification)
107
    return ((m_destination == o.m_destination) && (m_identification == o.m_identification)
108
           );
108
           );
 Lines 194-209    Link Here 
194
194
195
/**
195
/**
196
 * \ingroup dsr
196
 * \ingroup dsr
197
 * \brief maintain list of RreqTable entry
197
 * \brief maintain list of DsrRreqTable entry
198
 */
198
 */
199
class RreqTable  : public Object
199
class DsrRreqTable  : public Object
200
{
200
{
201
public:
201
public:
202
202
203
  static TypeId GetTypeId ();
203
  static TypeId GetTypeId ();
204
204
205
  RreqTable ();
205
  DsrRreqTable ();
206
  virtual ~RreqTable ();
206
  virtual ~DsrRreqTable ();
207
207
208
  /**
208
  /**
209
   * Set the initial discovert hop limit
209
   * Set the initial discovert hop limit
 Lines 359-371    Link Here 
359
  /// The state of the unidirectional link
359
  /// The state of the unidirectional link
360
  LinkStates m_linkStates;
360
  LinkStates m_linkStates;
361
  /// Map of entries
361
  /// Map of entries
362
  std::list<ReceivedRreqEntry> m_sourceRequests;
362
  std::list<DsrReceivedRreqEntry> m_sourceRequests;
363
  /// The id cache to ensure all the ids are unique, it is used when sending out route request
363
  /// The id cache to ensure all the ids are unique, it is used when sending out route request
364
  std::map<Ipv4Address, uint32_t> m_rreqIdCache;
364
  std::map<Ipv4Address, uint32_t> m_rreqIdCache;
365
  /// The cache to save route request table entries indexed with destination address
365
  /// The cache to save route request table entries indexed with destination address
366
  std::map<Ipv4Address, RreqTableEntry > m_rreqDstMap;
366
  std::map<Ipv4Address, RreqTableEntry > m_rreqDstMap;
367
  /// The cache to ensure all the route request from unique source
367
  /// The cache to ensure all the route request from unique source
368
  std::map<Ipv4Address, std::list<ReceivedRreqEntry> > m_sourceRreqMap;
368
  std::map<Ipv4Address, std::list<DsrReceivedRreqEntry> > m_sourceRreqMap;
369
369
370
  /// The Black list
370
  /// The Black list
371
  std::vector<BlackList> m_blackList;
371
  std::vector<BlackList> m_blackList;
(-)a/src/dsr/model/dsr-rsendbuff.cc (-14 / +14 lines)
 Lines 43-59    Link Here 
43
namespace dsr {
43
namespace dsr {
44
44
45
uint32_t
45
uint32_t
46
SendBuffer::GetSize ()
46
DsrSendBuffer::GetSize ()
47
{
47
{
48
  Purge ();
48
  Purge ();
49
  return m_sendBuffer.size ();
49
  return m_sendBuffer.size ();
50
}
50
}
51
51
52
bool
52
bool
53
SendBuffer::Enqueue (SendBuffEntry & entry)
53
DsrSendBuffer::Enqueue (DsrSendBuffEntry & entry)
54
{
54
{
55
  Purge ();
55
  Purge ();
56
  for (std::vector<SendBuffEntry>::const_iterator i = m_sendBuffer.begin (); i
56
  for (std::vector<DsrSendBuffEntry>::const_iterator i = m_sendBuffer.begin (); i
57
       != m_sendBuffer.end (); ++i)
57
       != m_sendBuffer.end (); ++i)
58
    {
58
    {
59
//      NS_LOG_DEBUG ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid ()
59
//      NS_LOG_DEBUG ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid ()
 Lines 81-94    Link Here 
81
}
81
}
82
82
83
void
83
void
84
SendBuffer::DropPacketWithDst (Ipv4Address dst)
84
DsrSendBuffer::DropPacketWithDst (Ipv4Address dst)
85
{
85
{
86
  NS_LOG_FUNCTION (this << dst);
86
  NS_LOG_FUNCTION (this << dst);
87
  Purge ();
87
  Purge ();
88
  /*
88
  /*
89
   * Drop the packet with destination address dst
89
   * Drop the packet with destination address dst
90
   */
90
   */
91
  for (std::vector<SendBuffEntry>::iterator i = m_sendBuffer.begin (); i
91
  for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.begin (); i
92
       != m_sendBuffer.end (); ++i)
92
       != m_sendBuffer.end (); ++i)
93
    {
93
    {
94
      if (IsEqual (*i, dst))
94
      if (IsEqual (*i, dst))
 Lines 97-113    Link Here 
97
        }
97
        }
98
    }
98
    }
99
  m_sendBuffer.erase (std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (),
99
  m_sendBuffer.erase (std::remove_if (m_sendBuffer.begin (), m_sendBuffer.end (),
100
                                      std::bind2nd (std::ptr_fun (SendBuffer::IsEqual), dst)), m_sendBuffer.end ());
100
                                      std::bind2nd (std::ptr_fun (DsrSendBuffer::IsEqual), dst)), m_sendBuffer.end ());
101
}
101
}
102
102
103
bool
103
bool
104
SendBuffer::Dequeue (Ipv4Address dst, SendBuffEntry & entry)
104
DsrSendBuffer::Dequeue (Ipv4Address dst, DsrSendBuffEntry & entry)
105
{
105
{
106
  Purge ();
106
  Purge ();
107
  /*
107
  /*
108
   * Dequeue the entry with destination address dst
108
   * Dequeue the entry with destination address dst
109
   */
109
   */
110
  for (std::vector<SendBuffEntry>::iterator i = m_sendBuffer.begin (); i != m_sendBuffer.end (); ++i)
110
  for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.begin (); i != m_sendBuffer.end (); ++i)
111
    {
111
    {
112
      if (i->GetDestination () == dst)
112
      if (i->GetDestination () == dst)
113
        {
113
        {
 Lines 121-132    Link Here 
121
}
121
}
122
122
123
bool
123
bool
124
SendBuffer::Find (Ipv4Address dst)
124
DsrSendBuffer::Find (Ipv4Address dst)
125
{
125
{
126
  /*
126
  /*
127
   * Make sure if the send buffer contains entry with certain dst
127
   * Make sure if the send buffer contains entry with certain dst
128
   */
128
   */
129
  for (std::vector<SendBuffEntry>::const_iterator i = m_sendBuffer.begin (); i
129
  for (std::vector<DsrSendBuffEntry>::const_iterator i = m_sendBuffer.begin (); i
130
       != m_sendBuffer.end (); ++i)
130
       != m_sendBuffer.end (); ++i)
131
    {
131
    {
132
      if (i->GetDestination () == dst)
132
      if (i->GetDestination () == dst)
 Lines 141-147    Link Here 
141
struct IsExpired
141
struct IsExpired
142
{
142
{
143
  bool
143
  bool
144
  operator() (SendBuffEntry const & e) const
144
  operator() (DsrSendBuffEntry const & e) const
145
  {
145
  {
146
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
146
    // NS_LOG_DEBUG("Expire time for packet in req queue: "<<e.GetExpireTime ());
147
    return (e.GetExpireTime () < Seconds (0));
147
    return (e.GetExpireTime () < Seconds (0));
 Lines 149-162    Link Here 
149
};
149
};
150
150
151
void
151
void
152
SendBuffer::Purge ()
152
DsrSendBuffer::Purge ()
153
{
153
{
154
  /*
154
  /*
155
   * Purge the buffer to eliminate expired entries
155
   * Purge the buffer to eliminate expired entries
156
   */
156
   */
157
  NS_LOG_INFO ("The send buffer size " << m_sendBuffer.size ());
157
  NS_LOG_INFO ("The send buffer size " << m_sendBuffer.size ());
158
  IsExpired pred;
158
  IsExpired pred;
159
  for (std::vector<SendBuffEntry>::iterator i = m_sendBuffer.begin (); i
159
  for (std::vector<DsrSendBuffEntry>::iterator i = m_sendBuffer.begin (); i
160
       != m_sendBuffer.end (); ++i)
160
       != m_sendBuffer.end (); ++i)
161
    {
161
    {
162
      if (pred (*i))
162
      if (pred (*i))
 Lines 170-176    Link Here 
170
}
170
}
171
171
172
void
172
void
173
SendBuffer::Drop (SendBuffEntry en, std::string reason)
173
DsrSendBuffer::Drop (DsrSendBuffEntry en, std::string reason)
174
{
174
{
175
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
175
  NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << " " << en.GetDestination ());
176
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
176
//  en.GetErrorCallback () (en.GetPacket (), en.GetDestination (),
(-)a/src/dsr/model/dsr-rsendbuff.h (-14 / +14 lines)
 Lines 42-59    Link Here 
42
 * \ingroup dsr
42
 * \ingroup dsr
43
 * \brief DSR Send Buffer Entry
43
 * \brief DSR Send Buffer Entry
44
 */
44
 */
45
class SendBuffEntry
45
class DsrSendBuffEntry
46
{
46
{
47
public:
47
public:
48
  /**
48
  /**
49
   * Construct SendBuffEntry with the given parameters.
49
   * Construct DsrSendBuffEntry with the given parameters.
50
   *
50
   *
51
   * \param pa packet
51
   * \param pa packet
52
   * \param d destination address
52
   * \param d destination address
53
   * \param exp expiration time
53
   * \param exp expiration time
54
   * \param p protocol number
54
   * \param p protocol number
55
   */
55
   */
56
  SendBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (),
56
  DsrSendBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (),
57
                 Time exp = Simulator::Now (), uint8_t p = 0)
57
                 Time exp = Simulator::Now (), uint8_t p = 0)
58
    : m_packet (pa),
58
    : m_packet (pa),
59
      m_dst (d),
59
      m_dst (d),
 Lines 63-72    Link Here 
63
  }
63
  }
64
  /**
64
  /**
65
   * Compare send buffer entries
65
   * Compare send buffer entries
66
   * \param o another SendBuffEntry
66
   * \param o another DsrSendBuffEntry
67
   * \return true if equal
67
   * \return true if equal
68
   */
68
   */
69
  bool operator== (SendBuffEntry const & o) const
69
  bool operator== (DsrSendBuffEntry const & o) const
70
  {
70
  {
71
    return ((m_packet == o.m_packet) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
71
    return ((m_packet == o.m_packet) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
72
  }
72
  }
 Lines 121-144    Link Here 
121
 * \brief DSR send buffer
121
 * \brief DSR send buffer
122
 */
122
 */
123
/************************************************************************************************************************/
123
/************************************************************************************************************************/
124
class SendBuffer
124
class DsrSendBuffer
125
{
125
{
126
public:
126
public:
127
  /**
127
  /**
128
   * Default constructor
128
   * Default constructor
129
   */
129
   */
130
  SendBuffer ()
130
  DsrSendBuffer ()
131
  {
131
  {
132
  }
132
  }
133
  /**
133
  /**
134
   * Push entry in queue, if there is no entry with
134
   * Push entry in queue, if there is no entry with
135
   * the same packet and destination address in queue.
135
   * the same packet and destination address in queue.
136
   *
136
   *
137
   * \param entry SendBuffEntry to put in the queue
137
   * \param entry DsrSendBuffEntry to put in the queue
138
   * \return true if successfully enqueued,
138
   * \return true if successfully enqueued,
139
   *         false otherwise
139
   *         false otherwise
140
   */
140
   */
141
  bool Enqueue (SendBuffEntry & entry);
141
  bool Enqueue (DsrSendBuffEntry & entry);
142
  /**
142
  /**
143
   * Return first found (the earliest) entry for
143
   * Return first found (the earliest) entry for
144
   * the given destination.
144
   * the given destination.
 Lines 148-154    Link Here 
148
   * \return true if successfully dequeued,
148
   * \return true if successfully dequeued,
149
   *         false otherwise
149
   *         false otherwise
150
   */
150
   */
151
  bool Dequeue (Ipv4Address dst, SendBuffEntry & entry);
151
  bool Dequeue (Ipv4Address dst, DsrSendBuffEntry & entry);
152
  /**
152
  /**
153
   * Remove all packets with destination IP address dst
153
   * Remove all packets with destination IP address dst
154
   *
154
   *
 Lines 211-226    Link Here 
211
   *
211
   *
212
   * \return a pointer to the internal queue
212
   * \return a pointer to the internal queue
213
   */
213
   */
214
  std::vector<SendBuffEntry> & GetBuffer ()
214
  std::vector<DsrSendBuffEntry> & GetBuffer ()
215
  {
215
  {
216
    return m_sendBuffer;
216
    return m_sendBuffer;
217
  }
217
  }
218
218
219
private:
219
private:
220
220
221
  std::vector<SendBuffEntry> m_sendBuffer;                      ///< The send buffer to cache unsent packet
221
  std::vector<DsrSendBuffEntry> m_sendBuffer;                   ///< The send buffer to cache unsent packet
222
  void Purge ();                                                ///< Remove all expired entries
222
  void Purge ();                                                ///< Remove all expired entries
223
  void Drop (SendBuffEntry en, std::string reason);             ///< Notify that packet is dropped from queue by timeout
223
  void Drop (DsrSendBuffEntry en, std::string reason);          ///< Notify that packet is dropped from queue by timeout
224
  uint32_t m_maxLen;                                            ///< The maximum number of packets that we allow a routing protocol to buffer.
224
  uint32_t m_maxLen;                                            ///< The maximum number of packets that we allow a routing protocol to buffer.
225
  Time m_sendBufferTimeout;                                     ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
225
  Time m_sendBufferTimeout;                                     ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
226
  /**
226
  /**
 Lines 231-237    Link Here 
231
   * \return true if the SendBufferEntry destination is the same,
231
   * \return true if the SendBufferEntry destination is the same,
232
   *         false otherwise
232
   *         false otherwise
233
   */
233
   */
234
  static bool IsEqual (SendBuffEntry en, const Ipv4Address dst)
234
  static bool IsEqual (DsrSendBuffEntry en, const Ipv4Address dst)
235
  {
235
  {
236
    return (en.GetDestination () == dst);
236
    return (en.GetDestination () == dst);
237
  }
237
  }
(-)a/src/dsr/test/dsr-test-suite.cc (-10 / +10 lines)
 Lines 350-361    Link Here 
350
void
350
void
351
DsrCacheEntryTest::DoRun ()
351
DsrCacheEntryTest::DoRun ()
352
{
352
{
353
  Ptr<dsr::RouteCache> rcache = CreateObject<dsr::RouteCache> ();
353
  Ptr<dsr::DsrRouteCache> rcache = CreateObject<dsr::DsrRouteCache> ();
354
  std::vector<Ipv4Address> ip;
354
  std::vector<Ipv4Address> ip;
355
  ip.push_back (Ipv4Address ("0.0.0.0"));
355
  ip.push_back (Ipv4Address ("0.0.0.0"));
356
  ip.push_back (Ipv4Address ("0.0.0.1"));
356
  ip.push_back (Ipv4Address ("0.0.0.1"));
357
  Ipv4Address dst = Ipv4Address ("0.0.0.1");
357
  Ipv4Address dst = Ipv4Address ("0.0.0.1");
358
  dsr::RouteCacheEntry entry (ip, dst, Seconds (1));
358
  dsr::DsrRouteCacheEntry entry (ip, dst, Seconds (1));
359
  NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 2, "trivial");
359
  NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 2, "trivial");
360
  NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("0.0.0.1"), "trivial");
360
  NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("0.0.0.1"), "trivial");
361
  NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial");
361
  NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial");
 Lines 374-381    Link Here 
374
  ip2.push_back (Ipv4Address ("1.1.1.0"));
374
  ip2.push_back (Ipv4Address ("1.1.1.0"));
375
  ip2.push_back (Ipv4Address ("1.1.1.1"));
375
  ip2.push_back (Ipv4Address ("1.1.1.1"));
376
  Ipv4Address dst2 = Ipv4Address ("1.1.1.1");
376
  Ipv4Address dst2 = Ipv4Address ("1.1.1.1");
377
  dsr::RouteCacheEntry entry2 (ip2, dst2, Seconds (2));
377
  dsr::DsrRouteCacheEntry entry2 (ip2, dst2, Seconds (2));
378
  dsr::RouteCacheEntry newEntry;
378
  dsr::DsrRouteCacheEntry newEntry;
379
  NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry2), true, "trivial");
379
  NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry2), true, "trivial");
380
  NS_TEST_EXPECT_MSG_EQ (rcache->LookupRoute (dst2, newEntry), true, "trivial");
380
  NS_TEST_EXPECT_MSG_EQ (rcache->LookupRoute (dst2, newEntry), true, "trivial");
381
  NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("2.2.2.2")), false, "trivial");
381
  NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("2.2.2.2")), false, "trivial");
 Lines 395-401    Link Here 
395
  void CheckSizeLimit ();
395
  void CheckSizeLimit ();
396
  void CheckTimeout ();
396
  void CheckTimeout ();
397
397
398
  dsr::SendBuffer q;
398
  dsr::DsrSendBuffer q;
399
};
399
};
400
DsrSendBuffTest::DsrSendBuffTest ()
400
DsrSendBuffTest::DsrSendBuffTest ()
401
  : TestCase ("DSR SendBuff"),
401
  : TestCase ("DSR SendBuff"),
 Lines 415-421    Link Here 
415
415
416
  Ptr<const Packet> packet = Create<Packet> ();
416
  Ptr<const Packet> packet = Create<Packet> ();
417
  Ipv4Address dst1 = Ipv4Address ("0.0.0.1");
417
  Ipv4Address dst1 = Ipv4Address ("0.0.0.1");
418
  dsr::SendBuffEntry e1 (packet, dst1, Seconds (1));
418
  dsr::DsrSendBuffEntry e1 (packet, dst1, Seconds (1));
419
  q.Enqueue (e1);
419
  q.Enqueue (e1);
420
  q.Enqueue (e1);
420
  q.Enqueue (e1);
421
  q.Enqueue (e1);
421
  q.Enqueue (e1);
 Lines 427-437    Link Here 
427
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "trivial");
427
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 0, "trivial");
428
428
429
  Ipv4Address dst2 = Ipv4Address ("0.0.0.2");
429
  Ipv4Address dst2 = Ipv4Address ("0.0.0.2");
430
  dsr::SendBuffEntry e2 (packet, dst2, Seconds (1));
430
  dsr::DsrSendBuffEntry e2 (packet, dst2, Seconds (1));
431
  q.Enqueue (e1);
431
  q.Enqueue (e1);
432
  q.Enqueue (e2);
432
  q.Enqueue (e2);
433
  Ptr<Packet> packet2 = Create<Packet> ();
433
  Ptr<Packet> packet2 = Create<Packet> ();
434
  dsr::SendBuffEntry e3 (packet2, dst2, Seconds (1));
434
  dsr::DsrSendBuffEntry e3 (packet2, dst2, Seconds (1));
435
  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("0.0.0.3"), e3), false, "trivial");
435
  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("0.0.0.3"), e3), false, "trivial");
436
  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("0.0.0.2"), e3), true, "trivial");
436
  NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("0.0.0.2"), e3), true, "trivial");
437
  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("0.0.0.2")), false, "trivial");
437
  NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("0.0.0.2")), false, "trivial");
 Lines 440-446    Link Here 
440
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial");
440
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 2, "trivial");
441
  Ptr<Packet> packet4 = Create<Packet> ();
441
  Ptr<Packet> packet4 = Create<Packet> ();
442
  Ipv4Address dst4 = Ipv4Address ("0.0.0.4");
442
  Ipv4Address dst4 = Ipv4Address ("0.0.0.4");
443
  dsr::SendBuffEntry e4 (packet4, dst4, Seconds (20));
443
  dsr::DsrSendBuffEntry e4 (packet4, dst4, Seconds (20));
444
  q.Enqueue (e4);
444
  q.Enqueue (e4);
445
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 3, "trivial");
445
  NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 3, "trivial");
446
  q.DropPacketWithDst (Ipv4Address ("0.0.0.4"));
446
  q.DropPacketWithDst (Ipv4Address ("0.0.0.4"));
 Lines 458-464    Link Here 
458
{
458
{
459
  Ptr<Packet> packet = Create<Packet> ();
459
  Ptr<Packet> packet = Create<Packet> ();
460
  Ipv4Address dst;
460
  Ipv4Address dst;
461
  dsr::SendBuffEntry e1 (packet, dst, Seconds (1));
461
  dsr::DsrSendBuffEntry e1 (packet, dst, Seconds (1));
462
462
463
  for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i)
463
  for (uint32_t i = 0; i < q.GetMaxQueueLen (); ++i)
464
    {
464
    {

Return to bug 2246