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

(-)a/examples/routing/manet-routing-compare.cc (-12 / +10 lines)
 Lines 120-143   RoutingExperiment::RoutingExperiment () Link Here 
120
std::string
120
std::string
121
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet)
121
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet)
122
{
122
{
123
  SocketAddressTag tag;
123
  Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
124
  bool found;
125
  found = packet->PeekPacketTag (tag);
126
  std::ostringstream oss;
124
  std::ostringstream oss;
127
125
128
  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
126
  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
129
127
130
  if (found)
128
  if (tag != 0)
131
    {
129
        {
132
      InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
130
      InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag->GetAddress ());
133
      oss << " received one packet from " << addr.GetIpv4 ();
131
      oss << " received one packet from " << addr.GetIpv4 ();
134
    }
132
        }
135
  else
133
      else
136
    {
134
        {
137
      oss << " received one packet!";
135
      oss << " received one packet!";
138
    }
136
        }
139
  return oss.str ();
137
  return oss.str ();
140
}
138
    }
141
139
142
void
140
void
143
RoutingExperiment::ReceivePacket (Ptr<Socket> socket)
141
RoutingExperiment::ReceivePacket (Ptr<Socket> socket)
 Lines 148-154   RoutingExperiment::ReceivePacket (Ptr<Socket> socket) Link Here 
148
      bytesTotal += packet->GetSize ();
146
      bytesTotal += packet->GetSize ();
149
      packetsReceived += 1;
147
      packetsReceived += 1;
150
      NS_LOG_UNCOND (PrintReceivedPacket (socket, packet));
148
      NS_LOG_UNCOND (PrintReceivedPacket (socket, packet));
151
    }
149
}
152
}
150
}
153
151
154
void
152
void
(-)a/src/aodv/model/aodv-routing-protocol.cc (-8 / +7 lines)
 Lines 352-360   RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Link Here 
352
  // Actual route request will be deferred until packet will be fully formed, 
352
  // Actual route request will be deferred until packet will be fully formed, 
353
  // routed to loopback, received from loopback and passed to RouteInput (see below)
353
  // routed to loopback, received from loopback and passed to RouteInput (see below)
354
  uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
354
  uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
355
  DeferredRouteOutputTag tag (iif);
355
  if (p->PeekPacketTag<DeferredRouteOutputTag> () == 0)
356
  if (!p->PeekPacketTag (tag))
357
    {
356
    {
357
      Ptr<DeferredRouteOutputTag> tag = CreateObject<DeferredRouteOutputTag> (iif);
358
      p->AddPacketTag (tag);
358
      p->AddPacketTag (tag);
359
    }
359
    }
360
  return LoopbackRoute (header, oif);
360
  return LoopbackRoute (header, oif);
 Lines 405-412   RoutingProtocol::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Link Here 
405
  // Deferred route request
405
  // Deferred route request
406
  if (idev == m_lo)
406
  if (idev == m_lo)
407
    {
407
    {
408
      DeferredRouteOutputTag tag;
408
      if (p->PeekPacketTag<DeferredRouteOutputTag> () != 0)
409
      if (p->PeekPacketTag (tag))
410
        {
409
        {
411
          DeferredRouteOutput (p, header, ucb, ecb);
410
          DeferredRouteOutput (p, header, ucb, ecb);
412
          return true;
411
          return true;
 Lines 1594-1604   RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route) Link Here 
1594
  QueueEntry queueEntry;
1593
  QueueEntry queueEntry;
1595
  while (m_queue.Dequeue (dst, queueEntry))
1594
  while (m_queue.Dequeue (dst, queueEntry))
1596
    {
1595
    {
1597
      DeferredRouteOutputTag tag;
1598
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1596
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1599
      if (p->RemovePacketTag (tag) && 
1597
      Ptr<const DeferredRouteOutputTag> tag = p->RemovePacketTag<DeferredRouteOutputTag> ();
1600
          tag.GetInterface() != -1 &&
1598
      if (tag != 0 && 
1601
          tag.GetInterface() != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1599
          tag->GetInterface() != -1 && 
1600
          tag->GetInterface() != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1602
        {
1601
        {
1603
          NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1602
          NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1604
          return;
1603
          return;
(-)a/src/applications/model/radvd.cc (-2 / +2 lines)
 Lines 211-218   void Radvd::Send (Ptr<RadvdInterface> config, Ipv6Address dst, bool reschedule) Link Here 
211
  /* Router advertisements MUST always have a ttl of 255
211
  /* Router advertisements MUST always have a ttl of 255
212
   * The ttl value should be set as a socket option, but this is not yet implemented
212
   * The ttl value should be set as a socket option, but this is not yet implemented
213
   */
213
   */
214
  SocketIpTtlTag ttl;
214
  Ptr<SocketIpTtlTag> ttl = CreateObject<SocketIpTtlTag> ();
215
  ttl.SetTtl (255);
215
  ttl->SetTtl (255);
216
  p->AddPacketTag (ttl);
216
  p->AddPacketTag (ttl);
217
217
218
  /* send RA */
218
  /* send RA */
(-)a/src/dsdv/model/dsdv-routing-protocol.cc (-8 / +6 lines)
 Lines 317-326   RoutingProtocol::RouteOutput (Ptr<Packet> p, Link Here 
317
  if (EnableBuffering)
317
  if (EnableBuffering)
318
    {
318
    {
319
      uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
319
      uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
320
      DeferredRouteOutputTag tag (iif);
320
      if (p->PeekPacketTag<DeferredRouteOutputTag> () == 0)
321
      if (!p->PeekPacketTag (tag))
322
        {
321
        {
323
          p->AddPacketTag (tag);
322
          p->AddPacketTag (CreateObject<DeferredRouteOutputTag> (iif));
324
        }
323
        }
325
    }
324
    }
326
  return LoopbackRoute (header,oif);
325
  return LoopbackRoute (header,oif);
 Lines 377-384   RoutingProtocol::RouteInput (Ptr<const Packet> p, Link Here 
377
  // Deferred route request
376
  // Deferred route request
378
  if (EnableBuffering == true && idev == m_lo)
377
  if (EnableBuffering == true && idev == m_lo)
379
    {
378
    {
380
      DeferredRouteOutputTag tag;
379
      if (p->PeekPacketTag<DeferredRouteOutputTag> () != 0)
381
      if (p->PeekPacketTag (tag))
382
        {
380
        {
383
          DeferredRouteOutput (p,header,ucb,ecb);
381
          DeferredRouteOutput (p,header,ucb,ecb);
384
          return true;
382
          return true;
 Lines 1121-1131   RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Link Here 
1121
  QueueEntry queueEntry;
1119
  QueueEntry queueEntry;
1122
  if (m_queue.Dequeue (dst,queueEntry))
1120
  if (m_queue.Dequeue (dst,queueEntry))
1123
    {
1121
    {
1124
      DeferredRouteOutputTag tag;
1125
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1122
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1126
      if (p->RemovePacketTag (tag))
1123
      Ptr<const DeferredRouteOutputTag> tag = p->RemovePacketTag<DeferredRouteOutputTag> ();
1124
      if (tag != 0)
1127
        {
1125
        {
1128
          if (tag.oif != -1 && tag.oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1126
          if (tag->oif != -1 && tag->oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1129
            {
1127
            {
1130
              NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1128
              NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1131
              return;
1129
              return;
(-)a/src/flow-monitor/model/ipv4-flow-probe.cc (-12 / +8 lines)
 Lines 204-211   Ipv4FlowProbe::SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr<const Packet> Link Here 
204
204
205
      // tag the packet with the flow id and packet id, so that the packet can be identified even
205
      // tag the packet with the flow id and packet id, so that the packet can be identified even
206
      // when Ipv4Header is not accessible at some non-IPv4 protocol layer
206
      // when Ipv4Header is not accessible at some non-IPv4 protocol layer
207
      Ipv4FlowProbeTag fTag (flowId, packetId, size);
207
      Ptr<Ipv4FlowProbeTag> fTag = CreateObject<Ipv4FlowProbeTag> (flowId, packetId, size);
208
      ipPayload->AddPacketTag (fTag);
208
      ConstCast<Packet> (ipPayload)->AddPacketTag (fTag);
209
    }
209
    }
210
}
210
}
211
211
 Lines 233-242   Ipv4FlowProbe::ForwardUpLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ip Link Here 
233
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
233
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
234
    {
234
    {
235
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
235
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
236
      Ipv4FlowProbeTag fTag;
237
236
238
      // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
237
      // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
239
      ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
238
      ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
240
239
241
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
240
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
242
      NS_LOG_DEBUG ("ReportLastRx ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<");");
241
      NS_LOG_DEBUG ("ReportLastRx ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<");");
 Lines 272-281   Ipv4FlowProbe::DropLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPaylo Link Here 
272
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
271
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
273
    {
272
    {
274
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
273
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
275
      Ipv4FlowProbeTag fTag;
276
274
277
      // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
275
      // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
278
      ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
276
      ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
279
277
280
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
278
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
281
      NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << reason 
279
      NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << reason 
 Lines 325-343   void Link Here 
325
Ipv4FlowProbe::QueueDropLogger (Ptr<const Packet> ipPayload)
323
Ipv4FlowProbe::QueueDropLogger (Ptr<const Packet> ipPayload)
326
{
324
{
327
  // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
325
  // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
328
  Ipv4FlowProbeTag fTag;
329
326
330
  // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
327
  // ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
331
  bool tagFound;
328
  Ptr<const Ipv4FlowProbeTag> fTag = ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
332
  tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
333
  if (!tagFound)
329
  if (!tagFound)
334
    {
330
    {
335
      return;
331
      return;
336
    }
332
    }
337
333
338
  FlowId flowId = fTag.GetFlowId ();
334
  FlowId flowId = fTag->GetFlowId ();
339
  FlowPacketId packetId = fTag.GetPacketId ();
335
  FlowPacketId packetId = fTag->GetPacketId ();
340
  uint32_t size = fTag.GetPacketSize ();
336
  uint32_t size = fTag->GetPacketSize ();
341
337
342
  NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << DROP_QUEUE 
338
  NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << DROP_QUEUE 
343
                        << "); ");
339
                        << "); ");
(-)a/src/internet/model/icmpv6-l4-protocol.cc (-4 / +4 lines)
 Lines 846-855   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address src, Ipv6Add Link Here 
846
{
846
{
847
  NS_LOG_FUNCTION (this << packet << src << dst << (uint32_t)ttl);
847
  NS_LOG_FUNCTION (this << packet << src << dst << (uint32_t)ttl);
848
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
848
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
849
  SocketIpTtlTag tag;
850
  NS_ASSERT (ipv6 != 0);
849
  NS_ASSERT (ipv6 != 0);
851
850
852
  tag.SetTtl (ttl);
851
  Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
852
  tag->SetTtl (ttl);
853
  packet->AddPacketTag (tag);
853
  packet->AddPacketTag (tag);
854
  m_downTarget (packet, src, dst, PROT_NUMBER, 0);
854
  m_downTarget (packet, src, dst, PROT_NUMBER, 0);
855
}
855
}
 Lines 860-866   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H Link Here 
860
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
860
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
861
  NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
861
  NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
862
  Ipv6Header header;
862
  Ipv6Header header;
863
  SocketIpTtlTag tag;
864
  Socket::SocketErrno err;
863
  Socket::SocketErrno err;
865
  Ptr<Ipv6Route> route;
864
  Ptr<Ipv6Route> route;
866
  Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
865
  Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
 Lines 871-877   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H Link Here 
871
  if (route != 0)
870
  if (route != 0)
872
    {
871
    {
873
      NS_LOG_LOGIC ("Route exists");
872
      NS_LOG_LOGIC ("Route exists");
874
      tag.SetTtl (ttl);
873
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
874
      tag->SetTtl (ttl);
875
      packet->AddPacketTag (tag);
875
      packet->AddPacketTag (tag);
876
      Ipv6Address src = route->GetSource ();
876
      Ipv6Address src = route->GetSource ();
877
877
(-)a/src/internet/model/ipv4-l3-protocol.cc (-4 / +3 lines)
 Lines 547-557   Ipv4L3Protocol::Send (Ptr<Packet> packet, Link Here 
547
  Ipv4Header ipHeader;
547
  Ipv4Header ipHeader;
548
  bool mayFragment = true;
548
  bool mayFragment = true;
549
  uint8_t ttl = m_defaultTtl;
549
  uint8_t ttl = m_defaultTtl;
550
  SocketIpTtlTag tag;
550
  Ptr<const SocketIpTtlTag> tag = packet->RemovePacketTag<SocketIpTtlTag> ();
551
  bool found = packet->RemovePacketTag (tag);
551
  if (tag != 0)
552
  if (found)
553
    {
552
    {
554
      ttl = tag.GetTtl ();
553
      ttl = tag->GetTtl ();
555
    }
554
    }
556
555
557
  // Handle a few cases:
556
  // Handle a few cases:
(-)a/src/internet/model/ipv4-raw-socket-impl.cc (-3 / +4 lines)
 Lines 320-328   Ipv4RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4 Link Here 
320
      // Should check via getsockopt ()..
320
      // Should check via getsockopt ()..
321
      if (IsRecvPktInfo ())
321
      if (IsRecvPktInfo ())
322
        {
322
        {
323
          Ipv4PacketInfoTag tag;
323
          Ptr<const Ipv4PacketInfoTag> origTag = copy->RemovePacketTag<Ipv4PacketInfoTag> ();
324
          copy->RemovePacketTag (tag);
324
          NS_ASSERT (origTag != 0);
325
          tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
325
          Ptr<Ipv4PacketInfoTag> tag = CreateObject<Ipv4PacketInfoTag> (*origTag);
326
          tag->SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
326
          copy->AddPacketTag (tag);
327
          copy->AddPacketTag (tag);
327
        }
328
        }
328
      if (m_protocol == 1)
329
      if (m_protocol == 1)
(-)a/src/internet/model/ipv6-l3-protocol.cc (-4 / +3 lines)
 Lines 610-621   void Ipv6L3Protocol::Send (Ptr<Packet> packet, Ipv6Address source, Ipv6Address d Link Here 
610
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol << route);
610
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol << route);
611
  Ipv6Header hdr;
611
  Ipv6Header hdr;
612
  uint8_t ttl = m_defaultTtl;
612
  uint8_t ttl = m_defaultTtl;
613
  SocketIpTtlTag tag;
613
  Ptr<const SocketIpTtlTag> tag = packet->RemovePacketTag<SocketIpTtlTag> ();
614
  bool found = packet->RemovePacketTag (tag);
615
614
616
  if (found)
615
  if (tag != 0)
617
    {
616
    {
618
      ttl = tag.GetTtl ();
617
      ttl = tag->GetTtl ();
619
    }
618
    }
620
619
621
  /* Handle 3 cases:
620
  /* Handle 3 cases:
(-)a/src/internet/model/ipv6-raw-socket-impl.cc (-3 / +3 lines)
 Lines 340-348   bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetD Link Here 
340
      // Should check via getsockopt ()..
340
      // Should check via getsockopt ()..
341
      if (IsRecvPktInfo ())
341
      if (IsRecvPktInfo ())
342
        {
342
        {
343
          Ipv6PacketInfoTag tag;
343
          Ptr<const Ipv6PacketInfoTag> origTag = copy->RemovePacketTag<Ipv6PacketInfoTag> ();
344
          copy->RemovePacketTag (tag);
344
          Ptr<Ipv6PacketInfoTag> tag = CreateObject<Ipv6PacketInfoTag> (*origTag);
345
          tag.SetRecvIf (device->GetIfIndex ());
345
          tag->SetRecvIf (device->GetIfIndex ());
346
          copy->AddPacketTag (tag);
346
          copy->AddPacketTag (tag);
347
        }
347
        }
348
348
(-)a/src/internet/model/tcp-socket-base.cc (-80 / +81 lines)
 Lines 269-275   TcpSocketBase::Bind6 (void) Link Here 
269
    {
269
    {
270
      m_errno = ERROR_ADDRNOTAVAIL;
270
      m_errno = ERROR_ADDRNOTAVAIL;
271
      return -1;
271
      return -1;
272
    }
272
}
273
  m_tcp->m_sockets.push_back (this);
273
  m_tcp->m_sockets.push_back (this);
274
  return SetupCallback ();
274
  return SetupCallback ();
275
}
275
}
 Lines 281-310   TcpSocketBase::Bind (const Address &address) Link Here 
281
  NS_LOG_FUNCTION (this << address);
281
  NS_LOG_FUNCTION (this << address);
282
  if (InetSocketAddress::IsMatchingType (address))
282
  if (InetSocketAddress::IsMatchingType (address))
283
    {
283
    {
284
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
284
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
285
      Ipv4Address ipv4 = transport.GetIpv4 ();
285
  Ipv4Address ipv4 = transport.GetIpv4 ();
286
      uint16_t port = transport.GetPort ();
286
  uint16_t port = transport.GetPort ();
287
      if (ipv4 == Ipv4Address::GetAny () && port == 0)
287
  if (ipv4 == Ipv4Address::GetAny () && port == 0)
288
        {
288
    {
289
          m_endPoint = m_tcp->Allocate ();
289
      m_endPoint = m_tcp->Allocate ();
290
        }
290
    }
291
      else if (ipv4 == Ipv4Address::GetAny () && port != 0)
291
  else if (ipv4 == Ipv4Address::GetAny () && port != 0)
292
        {
292
    {
293
          m_endPoint = m_tcp->Allocate (port);
293
      m_endPoint = m_tcp->Allocate (port);
294
        }
294
    }
295
      else if (ipv4 != Ipv4Address::GetAny () && port == 0)
295
  else if (ipv4 != Ipv4Address::GetAny () && port == 0)
296
        {
296
    {
297
          m_endPoint = m_tcp->Allocate (ipv4);
297
      m_endPoint = m_tcp->Allocate (ipv4);
298
        }
298
    }
299
      else if (ipv4 != Ipv4Address::GetAny () && port != 0)
299
  else if (ipv4 != Ipv4Address::GetAny () && port != 0)
300
        {
300
    {
301
          m_endPoint = m_tcp->Allocate (ipv4, port);
301
      m_endPoint = m_tcp->Allocate (ipv4, port);
302
        }
302
    }
303
      if (0 == m_endPoint)
303
  if (0 == m_endPoint)
304
        {
304
    {
305
          m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
305
      m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
306
          return -1;
306
      return -1;
307
        }
307
    }
308
    }
308
    }
309
  else if (Inet6SocketAddress::IsMatchingType (address))
309
  else if (Inet6SocketAddress::IsMatchingType (address))
310
    {
310
    {
 Lines 353-376   TcpSocketBase::Connect (const Address & address) Link Here 
353
  // If haven't do so, Bind() this socket first
353
  // If haven't do so, Bind() this socket first
354
  if (InetSocketAddress::IsMatchingType (address) && m_endPoint6 == 0)
354
  if (InetSocketAddress::IsMatchingType (address) && m_endPoint6 == 0)
355
    {
355
    {
356
      if (m_endPoint == 0)
356
  if (m_endPoint == 0)
357
    {
358
      if (Bind () == -1)
357
        {
359
        {
358
          if (Bind () == -1)
360
          NS_ASSERT (m_endPoint == 0);
359
            {
361
          return -1; // Bind() failed
360
              NS_ASSERT (m_endPoint == 0);
361
              return -1; // Bind() failed
362
            }
363
          NS_ASSERT (m_endPoint != 0);
364
        }
362
        }
365
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
363
      NS_ASSERT (m_endPoint != 0);
366
      m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
364
    }
365
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
366
  m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
367
      m_endPoint6 = 0;
367
      m_endPoint6 = 0;
368
368
369
      // Get the appropriate local address and port number from the routing protocol and set up endpoint
369
  // Get the appropriate local address and port number from the routing protocol and set up endpoint
370
      if (SetupEndpoint () != 0)
370
  if (SetupEndpoint () != 0)
371
        { // Route to destination does not exist
371
    { // Route to destination does not exist
372
          return -1;
372
      return -1;
373
        }
373
    }
374
    }
374
    }
375
  else if (Inet6SocketAddress::IsMatchingType (address)  && m_endPoint == 0)
375
  else if (Inet6SocketAddress::IsMatchingType (address)  && m_endPoint == 0)
376
    {
376
    {
 Lines 381-387   TcpSocketBase::Connect (const Address & address) Link Here 
381
      if (v6Addr.IsIpv4MappedAddress () == true)
381
      if (v6Addr.IsIpv4MappedAddress () == true)
382
        {
382
        {
383
          Ipv4Address v4Addr = v6Addr.GetIpv4MappedAddress ();
383
          Ipv4Address v4Addr = v6Addr.GetIpv4MappedAddress ();
384
          return Connect (InetSocketAddress (v4Addr, transport.GetPort ()));
384
          return Connect(InetSocketAddress(v4Addr, transport.GetPort ()));
385
        }
385
        }
386
386
387
      if (m_endPoint6 == 0)
387
      if (m_endPoint6 == 0)
 Lines 526-540   TcpSocketBase::Recv (uint32_t maxSize, uint32_t flags) Link Here 
526
  Ptr<Packet> outPacket = m_rxBuffer.Extract (maxSize);
526
  Ptr<Packet> outPacket = m_rxBuffer.Extract (maxSize);
527
  if (outPacket != 0 && outPacket->GetSize () != 0)
527
  if (outPacket != 0 && outPacket->GetSize () != 0)
528
    {
528
    {
529
      SocketAddressTag tag;
529
      Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
530
      if (m_endPoint != 0)
530
      if (m_endPoint != 0)
531
        {
531
        {
532
          tag.SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
532
          tag->SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
533
        }
533
        }
534
      else if (m_endPoint6 != 0)
534
      else if (m_endPoint6 != 0)
535
        {
535
        {
536
          tag.SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
536
          tag->SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
537
        }
537
        }
538
      
538
      outPacket->AddPacketTag (tag);
539
      outPacket->AddPacketTag (tag);
539
    }
540
    }
540
  return outPacket;
541
  return outPacket;
 Lines 621-627   TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice) Link Here 
621
622
622
  if (m_endPoint != 0)
623
  if (m_endPoint != 0)
623
    {
624
    {
624
      m_endPoint->BindToNetDevice (netdevice);
625
  m_endPoint->BindToNetDevice (netdevice);
625
    }
626
    }
626
  // No BindToNetDevice() for Ipv6EndPoint
627
  // No BindToNetDevice() for Ipv6EndPoint
627
  return;
628
  return;
 Lines 639-646   TcpSocketBase::SetupCallback (void) Link Here 
639
    }
640
    }
640
  if (m_endPoint != 0)
641
  if (m_endPoint != 0)
641
    {
642
    {
642
      m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this)));
643
  m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this)));
643
      m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
644
  m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
644
    }
645
    }
645
  if (m_endPoint6 != 0)
646
  if (m_endPoint6 != 0)
646
    {
647
    {
 Lines 791-797   TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port Link Here 
791
  TcpHeader tcpHeader;
792
  TcpHeader tcpHeader;
792
  packet->RemoveHeader (tcpHeader);
793
  packet->RemoveHeader (tcpHeader);
793
  if (tcpHeader.GetFlags () & TcpHeader::ACK)
794
  if (tcpHeader.GetFlags () & TcpHeader::ACK)
794
    {
795
    { 
795
      EstimateRtt (tcpHeader);
796
      EstimateRtt (tcpHeader);
796
    }
797
    }
797
  ReadOptions (tcpHeader);
798
  ReadOptions (tcpHeader);
 Lines 810-816   TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port Link Here 
810
    {
811
    {
811
      NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
812
      NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
812
                    " received packet of seq [" << tcpHeader.GetSequenceNumber () <<
813
                    " received packet of seq [" << tcpHeader.GetSequenceNumber () <<
813
                    ":" << tcpHeader.GetSequenceNumber () + packet->GetSize () <<
814
                    ":" << tcpHeader.GetSequenceNumber () + packet->GetSize() <<
814
                    ") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
815
                    ") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
815
                    m_rxBuffer.MaxRxSequence () << ")");
816
                    m_rxBuffer.MaxRxSequence () << ")");
816
      // Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
817
      // Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
 Lines 905-911   TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address d Link Here 
905
    {
906
    {
906
      NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
907
      NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
907
                    " received packet of seq [" << tcpHeader.GetSequenceNumber () <<
908
                    " received packet of seq [" << tcpHeader.GetSequenceNumber () <<
908
                    ":" << tcpHeader.GetSequenceNumber () + packet->GetSize () <<
909
                    ":" << tcpHeader.GetSequenceNumber () + packet->GetSize() <<
909
                    ") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
910
                    ") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
910
                    m_rxBuffer.MaxRxSequence () << ")");
911
                    m_rxBuffer.MaxRxSequence () << ")");
911
      // Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
912
      // Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
 Lines 1130-1136   TcpSocketBase::ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader) Link Here 
1130
    { // Other in-sequence input
1131
    { // Other in-sequence input
1131
      if (tcpflags != TcpHeader::RST)
1132
      if (tcpflags != TcpHeader::RST)
1132
        { // When (1) rx of FIN+ACK; (2) rx of FIN; (3) rx of bad flags
1133
        { // When (1) rx of FIN+ACK; (2) rx of FIN; (3) rx of bad flags
1133
          NS_LOG_LOGIC ("Illegal flag " << std::hex << static_cast<uint32_t> (tcpflags) << std::dec << " received. Reset packet is sent.");
1134
          NS_LOG_LOGIC ("Illegal flag " << std::hex << static_cast<uint32_t>(tcpflags) << std::dec << " received. Reset packet is sent.");
1134
          SendRST ();
1135
          SendRST ();
1135
        }
1136
        }
1136
      CloseAndNotify ();
1137
      CloseAndNotify ();
 Lines 1149-1155   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1149
1150
1150
  if (tcpflags == 0
1151
  if (tcpflags == 0
1151
      || (tcpflags == TcpHeader::ACK
1152
      || (tcpflags == TcpHeader::ACK
1152
          && m_nextTxSequence + SequenceNumber32 (1) == tcpHeader.GetAckNumber ()))
1153
       && m_nextTxSequence + SequenceNumber32 (1) == tcpHeader.GetAckNumber ()))
1153
    { // If it is bare data, accept it and move to ESTABLISHED state. This is
1154
    { // If it is bare data, accept it and move to ESTABLISHED state. This is
1154
      // possibly due to ACK lost in 3WHS. If in-sequence ACK is received, the
1155
      // possibly due to ACK lost in 3WHS. If in-sequence ACK is received, the
1155
      // handshake is completed nicely.
1156
      // handshake is completed nicely.
 Lines 1161-1168   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1161
      m_txBuffer.SetHeadSequence (m_nextTxSequence);
1162
      m_txBuffer.SetHeadSequence (m_nextTxSequence);
1162
      if (m_endPoint)
1163
      if (m_endPoint)
1163
        {
1164
        {
1164
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1165
      m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1165
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1166
                           InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1166
        }
1167
        }
1167
      else if (m_endPoint6)
1168
      else if (m_endPoint6)
1168
        {
1169
        {
 Lines 1195-1202   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1195
          m_txBuffer.SetHeadSequence (m_nextTxSequence);
1196
          m_txBuffer.SetHeadSequence (m_nextTxSequence);
1196
          if (m_endPoint)
1197
          if (m_endPoint)
1197
            {
1198
            {
1198
              m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1199
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1199
                                   InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1200
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1200
            }
1201
            }
1201
          else if (m_endPoint6)
1202
          else if (m_endPoint6)
1202
            {
1203
            {
 Lines 1213-1220   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1213
          NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
1214
          NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
1214
          if (m_endPoint)
1215
          if (m_endPoint)
1215
            {
1216
            {
1216
              m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1217
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1217
                                   InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1218
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1218
            }
1219
            }
1219
          else if (m_endPoint6)
1220
          else if (m_endPoint6)
1220
            {
1221
            {
 Lines 1294-1302   TcpSocketBase::ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader) Link Here 
1294
      if (!m_shutdownRecv)
1295
      if (!m_shutdownRecv)
1295
        {
1296
        {
1296
          NotifyDataRecv ();
1297
          NotifyDataRecv ();
1297
        }
1298
    }
1298
    }
1299
}
1299
}
1300
}
1300
1301
1301
/** Received a packet upon CLOSING */
1302
/** Received a packet upon CLOSING */
1302
void
1303
void
 Lines 1450-1461   TcpSocketBase::Destroy (void) Link Here 
1450
  m_endPoint = 0;
1451
  m_endPoint = 0;
1451
  if (m_tcp != 0)
1452
  if (m_tcp != 0)
1452
    {
1453
    {
1453
      std::vector<Ptr<TcpSocketBase> >::iterator it
1454
  std::vector<Ptr<TcpSocketBase> >::iterator it
1454
        = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
1455
    = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
1455
      if (it != m_tcp->m_sockets.end ())
1456
  if (it != m_tcp->m_sockets.end ())
1456
        {
1457
    {
1457
          m_tcp->m_sockets.erase (it);
1458
      m_tcp->m_sockets.erase (it);
1458
        }
1459
    }
1459
    }
1460
    }
1460
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1461
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1461
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
1462
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
 Lines 1511-1518   TcpSocketBase::SendEmptyPacket (uint8_t flags) Link Here 
1511
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1512
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1512
  if (m_endPoint != 0)
1513
  if (m_endPoint != 0)
1513
    {
1514
    {
1514
      header.SetSourcePort (m_endPoint->GetLocalPort ());
1515
  header.SetSourcePort (m_endPoint->GetLocalPort ());
1515
      header.SetDestinationPort (m_endPoint->GetPeerPort ());
1516
  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1516
    }
1517
    }
1517
  else
1518
  else
1518
    {
1519
    {
 Lines 1601-1607   TcpSocketBase::DeallocateEndPoint (void) Link Here 
1601
      if (it != m_tcp->m_sockets.end ())
1602
      if (it != m_tcp->m_sockets.end ())
1602
        {
1603
        {
1603
          m_tcp->m_sockets.erase (it);
1604
          m_tcp->m_sockets.erase (it);
1604
        }
1605
}
1605
      CancelAllTimers ();
1606
      CancelAllTimers ();
1606
    }
1607
    }
1607
}
1608
}
 Lines 1677-1686   TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h, Link Here 
1677
  // Get port and address from peer (connecting host)
1678
  // Get port and address from peer (connecting host)
1678
  if (InetSocketAddress::IsMatchingType (toAddress))
1679
  if (InetSocketAddress::IsMatchingType (toAddress))
1679
    {
1680
    {
1680
      m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
1681
  m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
1681
                                    InetSocketAddress::ConvertFrom (toAddress).GetPort (),
1682
                                InetSocketAddress::ConvertFrom (toAddress).GetPort (),
1682
                                    InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1683
                                InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1683
                                    InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1684
                                InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1684
      m_endPoint6 = 0;
1685
      m_endPoint6 = 0;
1685
    }
1686
    }
1686
  else if (Inet6SocketAddress::IsMatchingType (toAddress))
1687
  else if (Inet6SocketAddress::IsMatchingType (toAddress))
 Lines 1748-1755   TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with Link Here 
1748
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1749
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1749
  if (m_endPoint)
1750
  if (m_endPoint)
1750
    {
1751
    {
1751
      header.SetSourcePort (m_endPoint->GetLocalPort ());
1752
  header.SetSourcePort (m_endPoint->GetLocalPort ());
1752
      header.SetDestinationPort (m_endPoint->GetPeerPort ());
1753
  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1753
    }
1754
    }
1754
  else
1755
  else
1755
    {
1756
    {
 Lines 1769-1776   TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with Link Here 
1769
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
1770
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
1770
  if (m_endPoint)
1771
  if (m_endPoint)
1771
    {
1772
    {
1772
      m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1773
  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1773
                         m_endPoint->GetPeerAddress (), m_boundnetdevice);
1774
                     m_endPoint->GetPeerAddress (), m_boundnetdevice);
1774
    }
1775
    }
1775
  else
1776
  else
1776
    {
1777
    {
 Lines 2061-2068   TcpSocketBase::PersistTimeout () Link Here 
2061
  tcpHeader.SetWindowSize (AdvertisedWindowSize ());
2062
  tcpHeader.SetWindowSize (AdvertisedWindowSize ());
2062
  if (m_endPoint != 0)
2063
  if (m_endPoint != 0)
2063
    {
2064
    {
2064
      tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
2065
  tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
2065
      tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
2066
  tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
2066
    }
2067
    }
2067
  else
2068
  else
2068
    {
2069
    {
 Lines 2073-2080   TcpSocketBase::PersistTimeout () Link Here 
2073
2074
2074
  if (m_endPoint != 0)
2075
  if (m_endPoint != 0)
2075
    {
2076
    {
2076
      m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
2077
  m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
2077
                         m_endPoint->GetPeerAddress (), m_boundnetdevice);
2078
                     m_endPoint->GetPeerAddress (), m_boundnetdevice);
2078
    }
2079
    }
2079
  else
2080
  else
2080
    {
2081
    {
 Lines 2149-2155   TcpSocketBase::TimeWait () Link Here 
2149
  CancelAllTimers ();
2150
  CancelAllTimers ();
2150
  // Move from TIME_WAIT to CLOSED after 2*MSL. Max segment lifetime is 2 min
2151
  // Move from TIME_WAIT to CLOSED after 2*MSL. Max segment lifetime is 2 min
2151
  // according to RFC793, p.28
2152
  // according to RFC793, p.28
2152
  m_timewaitEvent = Simulator::Schedule (Seconds (2 * m_msl),
2153
  m_timewaitEvent = Simulator::Schedule (Seconds (2*m_msl),
2153
                                         &TcpSocketBase::CloseAndNotify, this);
2154
                                         &TcpSocketBase::CloseAndNotify, this);
2154
}
2155
}
2155
2156
(-)a/src/internet/model/udp-socket-impl.cc (-69 / +68 lines)
 Lines 180-188   UdpSocketImpl::FinishBind (void) Link Here 
180
  bool done = false;
180
  bool done = false;
181
  if (m_endPoint != 0)
181
  if (m_endPoint != 0)
182
    {
182
    {
183
      m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
183
  m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
184
      m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
184
  m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
185
      m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
185
  m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
186
      done = true;
186
      done = true;
187
    }
187
    }
188
  if (m_endPoint6 != 0)
188
  if (m_endPoint6 != 0)
 Lines 194-201   UdpSocketImpl::FinishBind (void) Link Here 
194
    }
194
    }
195
  if (done)
195
  if (done)
196
    {
196
    {
197
      return 0;
197
  return 0;
198
    }
198
}
199
  return -1;
199
  return -1;
200
}
200
}
201
201
 Lines 207-213   UdpSocketImpl::Bind (void) Link Here 
207
  return FinishBind ();
207
  return FinishBind ();
208
}
208
}
209
209
210
int
210
int 
211
UdpSocketImpl::Bind6 (void)
211
UdpSocketImpl::Bind6 (void)
212
{
212
{
213
  NS_LOG_FUNCTION_NOARGS ();
213
  NS_LOG_FUNCTION_NOARGS ();
 Lines 222-246   UdpSocketImpl::Bind (const Address &address) Link Here 
222
222
223
  if (InetSocketAddress::IsMatchingType (address))
223
  if (InetSocketAddress::IsMatchingType (address))
224
    {
224
    {
225
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
225
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
226
      Ipv4Address ipv4 = transport.GetIpv4 ();
226
  Ipv4Address ipv4 = transport.GetIpv4 ();
227
      uint16_t port = transport.GetPort ();
227
  uint16_t port = transport.GetPort ();
228
      if (ipv4 == Ipv4Address::GetAny () && port == 0)
228
  if (ipv4 == Ipv4Address::GetAny () && port == 0)
229
        {
229
    {
230
          m_endPoint = m_udp->Allocate ();
230
      m_endPoint = m_udp->Allocate ();
231
        }
231
    }
232
      else if (ipv4 == Ipv4Address::GetAny () && port != 0)
232
  else if (ipv4 == Ipv4Address::GetAny () && port != 0)
233
        {
233
    {
234
          m_endPoint = m_udp->Allocate (port);
234
      m_endPoint = m_udp->Allocate (port);
235
        }
235
    }
236
      else if (ipv4 != Ipv4Address::GetAny () && port == 0)
236
  else if (ipv4 != Ipv4Address::GetAny () && port == 0)
237
        {
237
    {
238
          m_endPoint = m_udp->Allocate (ipv4);
238
      m_endPoint = m_udp->Allocate (ipv4);
239
        }
239
    }
240
      else if (ipv4 != Ipv4Address::GetAny () && port != 0)
240
  else if (ipv4 != Ipv4Address::GetAny () && port != 0)
241
        {
241
    {
242
          m_endPoint = m_udp->Allocate (ipv4, port);
242
      m_endPoint = m_udp->Allocate (ipv4, port);
243
        }
243
    }
244
    }
244
    }
245
  else if (Inet6SocketAddress::IsMatchingType (address))
245
  else if (Inet6SocketAddress::IsMatchingType (address))
246
    {
246
    {
 Lines 310-320   UdpSocketImpl::Connect (const Address & address) Link Here 
310
  NS_LOG_FUNCTION (this << address);
310
  NS_LOG_FUNCTION (this << address);
311
  if (InetSocketAddress::IsMatchingType(address) == true)
311
  if (InetSocketAddress::IsMatchingType(address) == true)
312
    {
312
    {
313
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
313
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
314
      m_defaultAddress = Address(transport.GetIpv4 ());
314
      m_defaultAddress = Address(transport.GetIpv4 ());
315
      m_defaultPort = transport.GetPort ();
315
  m_defaultPort = transport.GetPort ();
316
      m_connected = true;
316
  m_connected = true;
317
      NotifyConnectionSucceeded ();
317
  NotifyConnectionSucceeded ();
318
    }
318
    }
319
  else if (Inet6SocketAddress::IsMatchingType(address) == true)
319
  else if (Inet6SocketAddress::IsMatchingType(address) == true)
320
    {
320
    {
 Lines 393-403   UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address) Link Here 
393
      NS_LOG_LOGIC ("Not connected");
393
      NS_LOG_LOGIC ("Not connected");
394
      if (InetSocketAddress::IsMatchingType(address) == true)
394
      if (InetSocketAddress::IsMatchingType(address) == true)
395
        {
395
        {
396
          InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
396
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
397
          Ipv4Address ipv4 = transport.GetIpv4 ();
397
      Ipv4Address ipv4 = transport.GetIpv4 ();
398
          uint16_t port = transport.GetPort ();
398
      uint16_t port = transport.GetPort ();
399
          return DoSendTo (p, ipv4, port);
399
      return DoSendTo (p, ipv4, port);
400
        }
400
    }
401
      else if (Inet6SocketAddress::IsMatchingType(address) == true)
401
      else if (Inet6SocketAddress::IsMatchingType(address) == true)
402
        {
402
        {
403
          Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
403
          Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
 Lines 405-412   UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address) Link Here 
405
          uint16_t port = transport.GetPort ();
405
          uint16_t port = transport.GetPort ();
406
          return DoSendTo (p, ipv6, port);
406
          return DoSendTo (p, ipv6, port);
407
        }
407
        }
408
      else
408
  else
409
        {
409
    {
410
          return -1;
410
          return -1;
411
        }
411
        }
412
    }
412
    }
 Lines 417-427   UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address) Link Here 
417
      if (Ipv4Address::IsMatchingType(m_defaultAddress))
417
      if (Ipv4Address::IsMatchingType(m_defaultAddress))
418
        {
418
        {
419
          return DoSendTo (p, Ipv4Address::ConvertFrom(m_defaultAddress), m_defaultPort);
419
          return DoSendTo (p, Ipv4Address::ConvertFrom(m_defaultAddress), m_defaultPort);
420
        }
420
    }
421
      else if (Ipv6Address::IsMatchingType(m_defaultAddress))
421
      else if (Ipv6Address::IsMatchingType(m_defaultAddress))
422
        {
422
        {
423
          return DoSendTo (p, Ipv6Address::ConvertFrom(m_defaultAddress), m_defaultPort);
423
          return DoSendTo (p, Ipv6Address::ConvertFrom(m_defaultAddress), m_defaultPort);
424
        }
424
}
425
    }
425
    }
426
  m_errno = ERROR_AFNOSUPPORT;
426
  m_errno = ERROR_AFNOSUPPORT;
427
  return(-1);
427
  return(-1);
 Lines 468-495   UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port) Link Here 
468
  // the same as a unicast, but it will be fixed further down the stack
468
  // the same as a unicast, but it will be fixed further down the stack
469
  if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
469
  if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
470
    {
470
    {
471
      SocketIpTtlTag tag;
471
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
472
      tag.SetTtl (m_ipMulticastTtl);
472
      tag->SetTtl (m_ipMulticastTtl);
473
      p->AddPacketTag (tag);
473
      p->AddPacketTag (tag);
474
    }
474
    }
475
  else if (m_ipTtl != 0 && !dest.IsMulticast () && !dest.IsBroadcast ())
475
  else if (m_ipTtl != 0 && !dest.IsMulticast () && !dest.IsBroadcast ())
476
    {
476
    {
477
      SocketIpTtlTag tag;
477
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
478
      tag.SetTtl (m_ipTtl);
478
      tag->SetTtl (m_ipTtl);
479
      p->AddPacketTag (tag);
479
      p->AddPacketTag (tag);
480
    }
480
    }
481
  {
481
  {
482
    SocketSetDontFragmentTag tag;
482
483
    bool found = p->RemovePacketTag (tag);
483
    // !!! Previously, header was removed, checked, but never added back.  Guess, this was wrong
484
    if (!found)
484
    if (p->PeekPacketTag<SocketSetDontFragmentTag> () == 0)
485
      {
485
      {
486
        Ptr<SocketSetDontFragmentTag> tag = CreateObject<SocketSetDontFragmentTag> ();
486
        if (m_mtuDiscover)
487
        if (m_mtuDiscover)
487
          {
488
          {
488
            tag.Enable ();
489
            tag->Enable ();
489
          }
490
          }
490
        else
491
        else
491
          {
492
          {
492
            tag.Disable ();
493
            tag->Disable ();
493
          }
494
          }
494
        p->AddPacketTag (tag);
495
        p->AddPacketTag (tag);
495
      }
496
      }
 Lines 656-669   UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv6Address dest, uint16_t port) Link Here 
656
  // the same as a unicast, but it will be fixed further down the stack
657
  // the same as a unicast, but it will be fixed further down the stack
657
  if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
658
  if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
658
    {
659
    {
659
      SocketIpTtlTag tag;
660
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
660
      tag.SetTtl (m_ipMulticastTtl);
661
      tag->SetTtl (m_ipMulticastTtl);
661
      p->AddPacketTag (tag);
662
      p->AddPacketTag (tag);
662
    }
663
    }
663
  else if (m_ipTtl != 0 && !dest.IsMulticast ())
664
  else if (m_ipTtl != 0 && !dest.IsMulticast ())
664
    {
665
    {
665
      SocketIpTtlTag tag;
666
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
666
      tag.SetTtl (m_ipTtl);
667
      tag->SetTtl (m_ipTtl);
667
      p->AddPacketTag (tag);
668
      p->AddPacketTag (tag);
668
    }
669
    }
669
  // There is no analgous to an IPv4 broadcast address in IPv6.
670
  // There is no analgous to an IPv4 broadcast address in IPv6.
 Lines 734-744   UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address) Link Here 
734
  NS_LOG_FUNCTION (this << p << flags << address);
735
  NS_LOG_FUNCTION (this << p << flags << address);
735
  if (InetSocketAddress::IsMatchingType (address))
736
  if (InetSocketAddress::IsMatchingType (address))
736
    {
737
    {
737
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
738
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
738
      Ipv4Address ipv4 = transport.GetIpv4 ();
739
  Ipv4Address ipv4 = transport.GetIpv4 ();
739
      uint16_t port = transport.GetPort ();
740
  uint16_t port = transport.GetPort ();
740
      return DoSendTo (p, ipv4, port);
741
  return DoSendTo (p, ipv4, port);
741
    }
742
}
742
  else if (Inet6SocketAddress::IsMatchingType (address))
743
  else if (Inet6SocketAddress::IsMatchingType (address))
743
    {
744
    {
744
      Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
745
      Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
 Lines 788-798   UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Link Here 
788
  Ptr<Packet> packet = Recv (maxSize, flags);
789
  Ptr<Packet> packet = Recv (maxSize, flags);
789
  if (packet != 0)
790
  if (packet != 0)
790
    {
791
    {
791
      SocketAddressTag tag;
792
      Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
792
      bool found;
793
      NS_ASSERT (tag != 0);
793
      found = packet->PeekPacketTag (tag);
794
      fromAddress = tag->GetAddress ();
794
      NS_ASSERT (found);
795
      fromAddress = tag.GetAddress ();
796
    }
795
    }
797
  return packet;
796
  return packet;
798
}
797
}
 Lines 874-890   UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Link Here 
874
  // Should check via getsockopt ()..
873
  // Should check via getsockopt ()..
875
  if (IsRecvPktInfo ())
874
  if (IsRecvPktInfo ())
876
    {
875
    {
877
      Ipv4PacketInfoTag tag;
876
      Ptr<const Ipv4PacketInfoTag> origTag = packet->RemovePacketTag<Ipv4PacketInfoTag> ();
878
      packet->RemovePacketTag (tag);
877
      Ptr<Ipv4PacketInfoTag> tag = CreateObject<Ipv4PacketInfoTag> (*origTag);      
879
      tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
878
      tag->SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
880
      packet->AddPacketTag (tag);
879
      packet->AddPacketTag (tag);
881
    }
880
    }
882
881
883
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
882
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
884
    {
883
    {
885
      Address address = InetSocketAddress (header.GetSource (), port);
884
      Address address = InetSocketAddress (header.GetSource (), port);
886
      SocketAddressTag tag;
885
      Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
887
      tag.SetAddress (address);
886
      tag->SetAddress (address);
888
      packet->AddPacketTag (tag);
887
      packet->AddPacketTag (tag);
889
      m_deliveryQueue.push (packet);
888
      m_deliveryQueue.push (packet);
890
      m_rxAvailable += packet->GetSize ();
889
      m_rxAvailable += packet->GetSize ();
 Lines 902-908   UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Link Here 
902
    }
901
    }
903
}
902
}
904
903
905
void 
904
void
906
UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address daddr, uint16_t port)
905
UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address daddr, uint16_t port)
907
{
906
{
908
  NS_LOG_FUNCTION (this << packet << saddr << port);
907
  NS_LOG_FUNCTION (this << packet << saddr << port);
 Lines 915-922   UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address da Link Here 
915
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
914
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
916
    {
915
    {
917
      Address address = Inet6SocketAddress (saddr, port);
916
      Address address = Inet6SocketAddress (saddr, port);
918
      SocketAddressTag tag;
917
      Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
919
      tag.SetAddress (address);
918
      tag->SetAddress (address);
920
      packet->AddPacketTag (tag);
919
      packet->AddPacketTag (tag);
921
      m_deliveryQueue.push (packet);
920
      m_deliveryQueue.push (packet);
922
      m_rxAvailable += packet->GetSize ();
921
      m_rxAvailable += packet->GetSize ();
(-)a/src/mesh/model/dot11s/hwmp-protocol-mac.cc (-10 / +9 lines)
 Lines 55-62   HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header) Link Here 
55
  NS_ASSERT (header.IsData ());
55
  NS_ASSERT (header.IsData ());
56
56
57
  MeshHeader meshHdr;
57
  MeshHeader meshHdr;
58
  HwmpTag tag;
58
  if (packet->PeekPacketTag<HwmpTag> () != 0)
59
  if (packet->PeekPacketTag (tag))
60
    {
59
    {
61
      NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
60
      NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
62
    }
61
    }
 Lines 78-85   HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header) Link Here 
78
      NS_FATAL_ERROR (
77
      NS_FATAL_ERROR (
79
        "6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
78
        "6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
80
    }
79
    }
81
  tag.SetSeqno (meshHdr.GetMeshSeqno ());
80
  Ptr<HwmpTag> tag = CreateObject<HwmpTag> ();
82
  tag.SetTtl (meshHdr.GetMeshTtl ());
81
  tag->SetSeqno (meshHdr.GetMeshSeqno ());
82
  tag->SetTtl (meshHdr.GetMeshTtl ());
83
  packet->AddPacketTag (tag);
83
  packet->AddPacketTag (tag);
84
84
85
  if ((destination == Mac48Address::GetBroadcast ()) && (m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (),
85
  if ((destination == Mac48Address::GetBroadcast ()) && (m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (),
 Lines 188-206   HwmpProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & heade Link Here 
188
    {
188
    {
189
      return true;
189
      return true;
190
    }
190
    }
191
  HwmpTag tag;
191
  Ptr<const HwmpTag> tag = packet->RemovePacketTag<HwmpTag> ();
192
  bool tagExists = packet->RemovePacketTag (tag);
192
  if (tag == 0)
193
  if (!tagExists)
194
    {
193
    {
195
      NS_FATAL_ERROR ("HWMP tag must exist at this point");
194
      NS_FATAL_ERROR ("HWMP tag must exist at this point");
196
    }
195
    }
197
  m_stats.txData++;
196
  m_stats.txData++;
198
  m_stats.txDataBytes += packet->GetSize ();
197
  m_stats.txDataBytes += packet->GetSize ();
199
  MeshHeader meshHdr;
198
  MeshHeader meshHdr;
200
  meshHdr.SetMeshSeqno (tag.GetSeqno ());
199
  meshHdr.SetMeshSeqno (tag->GetSeqno ());
201
  meshHdr.SetMeshTtl (tag.GetTtl ());
200
  meshHdr.SetMeshTtl (tag->GetTtl ());
202
  packet->AddHeader (meshHdr);
201
  packet->AddHeader (meshHdr);
203
  header.SetAddr1 (tag.GetAddress ());
202
  header.SetAddr1 (tag->GetAddress ());
204
  return true;
203
  return true;
205
}
204
}
206
WifiActionHeader
205
WifiActionHeader
(-)a/src/mesh/model/dot11s/hwmp-protocol.cc (-21 / +29 lines)
 Lines 233-261   HwmpProtocol::RequestRoute ( Link Here 
233
  )
233
  )
234
{
234
{
235
  Ptr <Packet> packet = constPacket->Copy ();
235
  Ptr <Packet> packet = constPacket->Copy ();
236
  HwmpTag tag;
236
  Ptr<HwmpTag> tag = 0;
237
  if (sourceIface == GetMeshPoint ()->GetIfIndex ())
237
  if (sourceIface == GetMeshPoint ()->GetIfIndex ())
238
    {
238
    {
239
      // packet from level 3
239
      // packet from level 3
240
      if (packet->PeekPacketTag (tag))
240
      if (packet->PeekPacketTag<HwmpTag> () != 0)
241
        {
241
        {
242
          NS_FATAL_ERROR ("HWMP tag has come with a packet from upper layer. This must not occur...");
242
          NS_FATAL_ERROR ("HWMP tag has come with a packet from upper layer. This must not occur...");
243
        }
243
        }
244
      tag = CreateObject<HwmpTag> ();
244
      //Filling TAG:
245
      //Filling TAG:
245
      if (destination == Mac48Address::GetBroadcast ())
246
      if (destination == Mac48Address::GetBroadcast ())
246
        {
247
        {
247
          tag.SetSeqno (m_dataSeqno++);
248
          tag->SetSeqno (m_dataSeqno++);
248
        }
249
        }
249
      tag.SetTtl (m_maxTtl);
250
      tag->SetTtl (m_maxTtl);
250
    }
251
    }
251
  else
252
  else
252
    {
253
    {
253
      if (!packet->RemovePacketTag (tag))
254
      Ptr<const HwmpTag> origTag = packet->RemovePacketTag<HwmpTag> ();
255
      if (!packet->RemovePacketTag<HwmpTag> ())
254
        {
256
        {
255
          NS_FATAL_ERROR ("HWMP tag is supposed to be here at this point.");
257
          NS_FATAL_ERROR ("HWMP tag is supposed to be here at this point.");
256
        }
258
        }
257
      tag.DecrementTtl ();
259
      tag = CreateObject<HwmpTag> (*origTag);
258
      if (tag.GetTtl () == 0)
260
      tag->DecrementTtl ();
261
      if (tag->GetTtl () == 0)
259
        {
262
        {
260
          m_stats.droppedTtl++;
263
          m_stats.droppedTtl++;
261
          return false;
264
          return false;
 Lines 287-297   HwmpProtocol::RequestRoute ( Link Here 
287
            {
290
            {
288
              Ptr<Packet> packetCopy = packet->Copy ();
291
              Ptr<Packet> packetCopy = packet->Copy ();
289
              //
292
              //
290
              // 64-bit Intel valgrind complains about tag.SetAddress (*i).  It
293
              // 64-bit Intel valgrind complains about tag->SetAddress (*i).  It
291
              // likes this just fine.
294
              // likes this just fine.
292
              //
295
              //
293
              Mac48Address address = *i;
296
              Mac48Address address = *i;
294
              tag.SetAddress (address);
297
              tag->SetAddress (address);
295
              packetCopy->AddPacketTag (tag);
298
              packetCopy->AddPacketTag (tag);
296
              routeReply (true, packetCopy, source, destination, protocolType, plugin->first);
299
              routeReply (true, packetCopy, source, destination, protocolType, plugin->first);
297
            }
300
            }
 Lines 299-305   HwmpProtocol::RequestRoute ( Link Here 
299
    }
302
    }
300
  else
303
  else
301
    {
304
    {
302
      return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag.GetTtl ());
305
      return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag->GetTtl ());
303
    }
306
    }
304
  return true;
307
  return true;
305
}
308
}
 Lines 307-314   bool Link Here 
307
HwmpProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
310
HwmpProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
308
                                  const Mac48Address destination, Ptr<Packet>  packet, uint16_t&  protocolType)
311
                                  const Mac48Address destination, Ptr<Packet>  packet, uint16_t&  protocolType)
309
{
312
{
310
  HwmpTag tag;
313
  Ptr<const HwmpTag> tag = packet->RemovePacketTag<HwmpTag> ();
311
  if (!packet->RemovePacketTag (tag))
314
  if (tag == 0)
312
    {
315
    {
313
      NS_FATAL_ERROR ("HWMP tag must exist when packet received from the network");
316
      NS_FATAL_ERROR ("HWMP tag must exist when packet received from the network");
314
    }
317
    }
 Lines 325-333   HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source, Link Here 
325
    {
328
    {
326
      result = m_rtable->LookupProactive ();
329
      result = m_rtable->LookupProactive ();
327
    }
330
    }
328
  HwmpTag tag;
331
  Ptr<HwmpTag> tag = CreateObject<HwmpTag> ();
329
  tag.SetAddress (result.retransmitter);
332
  tag->SetAddress (result.retransmitter);
330
  tag.SetTtl (ttl);
333
  tag->SetTtl (ttl);
331
  //seqno and metric is not used;
334
  //seqno and metric is not used;
332
  packet->AddPacketTag (tag);
335
  packet->AddPacketTag (tag);
333
  if (result.retransmitter != Mac48Address::GetBroadcast ())
336
  if (result.retransmitter != Mac48Address::GetBroadcast ())
 Lines 921-929   HwmpProtocol::ReactivePathResolved (Mac48Address dst) Link Here 
921
  while (packet.pkt != 0)
924
  while (packet.pkt != 0)
922
    {
925
    {
923
      //set RA tag for retransmitter:
926
      //set RA tag for retransmitter:
924
      HwmpTag tag;
927
      Ptr<const HwmpTag> origTag = packet.pkt->RemovePacketTag<HwmpTag> ();
925
      packet.pkt->RemovePacketTag (tag);
928
      if (origTag == 0)
926
      tag.SetAddress (result.retransmitter);
929
        {
930
          NS_FATAL_ERROR ("HWMP tag must be present at this point");
931
        }
932
      Ptr<HwmpTag> tag = CreateObject<HwmpTag> (*origTag);
933
      tag->SetAddress (result.retransmitter);
927
      packet.pkt->AddPacketTag (tag);
934
      packet.pkt->AddPacketTag (tag);
928
      m_stats.txUnicast++;
935
      m_stats.txUnicast++;
929
      m_stats.txBytes += packet.pkt->GetSize ();
936
      m_stats.txBytes += packet.pkt->GetSize ();
 Lines 942-953   HwmpProtocol::ProactivePathResolved () Link Here 
942
  while (packet.pkt != 0)
949
  while (packet.pkt != 0)
943
    {
950
    {
944
      //set RA tag for retransmitter:
951
      //set RA tag for retransmitter:
945
      HwmpTag tag;
952
      Ptr<const HwmpTag> origTag = packet.pkt->RemovePacketTag<HwmpTag> ();
946
      if (!packet.pkt->RemovePacketTag (tag))
953
      if (origTag == 0)
947
        {
954
        {
948
          NS_FATAL_ERROR ("HWMP tag must be present at this point");
955
          NS_FATAL_ERROR ("HWMP tag must be present at this point");
949
        }
956
        }
950
      tag.SetAddress (result.retransmitter);
957
      Ptr<HwmpTag> tag = CreateObject<HwmpTag> (*origTag);
958
      tag->SetAddress (result.retransmitter);
951
      packet.pkt->AddPacketTag (tag);
959
      packet.pkt->AddPacketTag (tag);
952
      m_stats.txUnicast++;
960
      m_stats.txUnicast++;
953
      m_stats.txBytes += packet.pkt->GetSize ();
961
      m_stats.txBytes += packet.pkt->GetSize ();
(-)a/src/mesh/model/dot11s/hwmp-tag.cc (-4 / +4 lines)
 Lines 41-47   HwmpTag::SetAddress (Mac48Address retransmitter) Link Here 
41
}
41
}
42
42
43
Mac48Address
43
Mac48Address
44
HwmpTag::GetAddress ()
44
HwmpTag::GetAddress () const
45
{
45
{
46
  return m_address;
46
  return m_address;
47
}
47
}
 Lines 53-59   HwmpTag::SetTtl (uint8_t ttl) Link Here 
53
}
53
}
54
54
55
uint8_t
55
uint8_t
56
HwmpTag::GetTtl ()
56
HwmpTag::GetTtl () const
57
{
57
{
58
  return m_ttl;
58
  return m_ttl;
59
}
59
}
 Lines 65-71   HwmpTag::SetMetric (uint32_t metric) Link Here 
65
}
65
}
66
66
67
uint32_t
67
uint32_t
68
HwmpTag::GetMetric ()
68
HwmpTag::GetMetric () const
69
{
69
{
70
  return m_metric;
70
  return m_metric;
71
}
71
}
 Lines 77-83   HwmpTag::SetSeqno (uint32_t seqno) Link Here 
77
}
77
}
78
78
79
uint32_t
79
uint32_t
80
HwmpTag::GetSeqno ()
80
HwmpTag::GetSeqno () const
81
{
81
{
82
  return m_seqno;
82
  return m_seqno;
83
}
83
}
(-)a/src/mesh/model/dot11s/hwmp-tag.h (-4 / +4 lines)
 Lines 51-63   public: Link Here 
51
  HwmpTag ();
51
  HwmpTag ();
52
  ~HwmpTag ();
52
  ~HwmpTag ();
53
  void  SetAddress (Mac48Address retransmitter);
53
  void  SetAddress (Mac48Address retransmitter);
54
  Mac48Address GetAddress ();
54
  Mac48Address GetAddress () const;
55
  void  SetTtl (uint8_t ttl);
55
  void  SetTtl (uint8_t ttl);
56
  uint8_t GetTtl ();
56
  uint8_t GetTtl () const;
57
  void  SetMetric (uint32_t metric);
57
  void  SetMetric (uint32_t metric);
58
  uint32_t GetMetric ();
58
  uint32_t GetMetric () const;
59
  void  SetSeqno (uint32_t seqno);
59
  void  SetSeqno (uint32_t seqno);
60
  uint32_t GetSeqno ();
60
  uint32_t GetSeqno () const;
61
  void  DecrementTtl ();
61
  void  DecrementTtl ();
62
62
63
  static  TypeId  GetTypeId ();
63
  static  TypeId  GetTypeId ();
(-)a/src/mesh/model/flame/flame-protocol-mac.cc (-9 / +9 lines)
 Lines 47-60   FlameProtocolMac::Receive (Ptr<Packet> packet, const WifiMacHeader & header) Link Here 
47
    {
47
    {
48
      return true;
48
      return true;
49
    }
49
    }
50
  FlameTag tag;
50
  if (packet->PeekPacketTag<FlameTag> () != 0)
51
  if (packet->PeekPacketTag (tag))
52
    {
51
    {
53
      NS_FATAL_ERROR ("FLAME tag is not supposed to be received by network");
52
      NS_FATAL_ERROR ("FLAME tag is not supposed to be received by network");
54
    }
53
    }
55
  tag.receiver = header.GetAddr1 ();
54
  Ptr<FlameTag> tag = CreateObject<FlameTag> ();
56
  tag.transmitter = header.GetAddr2 ();
55
  tag->receiver = header.GetAddr1 ();
57
  if (tag.receiver == Mac48Address::GetBroadcast ())
56
  tag->transmitter = header.GetAddr2 ();
57
  if (tag->receiver == Mac48Address::GetBroadcast ())
58
    {
58
    {
59
      m_stats.rxBroadcast++;
59
      m_stats.rxBroadcast++;
60
    }
60
    }
 Lines 74-86   FlameProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & head Link Here 
74
    {
74
    {
75
      return true;
75
      return true;
76
    }
76
    }
77
  FlameTag tag;
77
  Ptr<const FlameTag> tag = packet->RemovePacketTag<FlameTag> ();
78
  if (!packet->RemovePacketTag (tag))
78
  if (tag == 0)
79
    {
79
    {
80
      NS_FATAL_ERROR ("FLAME tag must exist here");
80
      NS_FATAL_ERROR ("FLAME tag must exist here");
81
    }
81
    }
82
  header.SetAddr1 (tag.receiver);
82
  header.SetAddr1 (tag->receiver);
83
  if (tag.receiver == Mac48Address::GetBroadcast ())
83
  if (tag->receiver == Mac48Address::GetBroadcast ())
84
    {
84
    {
85
      m_stats.txBroadcast++;
85
      m_stats.txBroadcast++;
86
    }
86
    }
(-)a/src/mesh/model/flame/flame-protocol.cc (-16 / +18 lines)
 Lines 150-157   FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co Link Here 
150
  if (sourceIface == m_mp->GetIfIndex ())
150
  if (sourceIface == m_mp->GetIfIndex ())
151
    {
151
    {
152
      //Packet from upper layer!
152
      //Packet from upper layer!
153
      FlameTag tag;
153
      if (packet->PeekPacketTag<FlameTag> () != 0)
154
      if (packet->PeekPacketTag (tag))
155
        {
154
        {
156
          NS_FATAL_ERROR ("FLAME tag is not supposed to be received from upper layers");
155
          NS_FATAL_ERROR ("FLAME tag is not supposed to be received from upper layers");
157
        }
156
        }
 Lines 174-180   FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co Link Here 
174
      flameHdr.SetOrigSrc (source);
173
      flameHdr.SetOrigSrc (source);
175
      m_stats.txBytes += packet->GetSize ();
174
      m_stats.txBytes += packet->GetSize ();
176
      packet->AddHeader (flameHdr);
175
      packet->AddHeader (flameHdr);
177
      tag.receiver = result.retransmitter;
176
      Ptr<FlameTag> tag = CreateObject<FlameTag> ();
177
      tag->receiver = result.retransmitter;
178
      if (result.retransmitter == Mac48Address::GetBroadcast ())
178
      if (result.retransmitter == Mac48Address::GetBroadcast ())
179
        {
179
        {
180
          m_stats.txBroadcast++;
180
          m_stats.txBroadcast++;
 Lines 183-189   FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co Link Here 
183
        {
183
        {
184
          m_stats.txUnicast++;
184
          m_stats.txUnicast++;
185
        }
185
        }
186
      NS_LOG_DEBUG ("Source: send packet with RA = " << tag.receiver);
186
      NS_LOG_DEBUG ("Source: send packet with RA = " << tag->receiver);
187
      packet->AddPacketTag (tag);
187
      packet->AddPacketTag (tag);
188
      routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex);
188
      routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex);
189
    }
189
    }
 Lines 191-207   FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co Link Here 
191
    {
191
    {
192
      FlameHeader flameHdr;
192
      FlameHeader flameHdr;
193
      packet->RemoveHeader (flameHdr);
193
      packet->RemoveHeader (flameHdr);
194
      FlameTag tag;
195
194
196
      if (!packet->RemovePacketTag (tag))
195
      Ptr<const FlameTag> origTag = packet->RemovePacketTag<FlameTag> ();
196
      if (origTag == 0)
197
        {
197
        {
198
          NS_FATAL_ERROR ("FLAME tag must exist here");
198
          NS_FATAL_ERROR ("FLAME tag must exist here");
199
        }
199
        }
200
      
200
      if (destination == Mac48Address::GetBroadcast ())
201
      if (destination == Mac48Address::GetBroadcast ())
201
        {
202
        {
202
          //Broadcast always is forwarded as broadcast!
203
          //Broadcast always is forwarded as broadcast!
203
          NS_ASSERT (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface));
204
          NS_ASSERT (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, origTag->transmitter, sourceIface));
204
          FlameTag tag (Mac48Address::GetBroadcast ());
205
          Ptr<FlameTag> tag = CreateObject<FlameTag> (Mac48Address::GetBroadcast ());
205
          flameHdr.AddCost (1);
206
          flameHdr.AddCost (1);
206
          m_stats.txBytes += packet->GetSize ();
207
          m_stats.txBytes += packet->GetSize ();
207
          packet->AddHeader (flameHdr);
208
          packet->AddHeader (flameHdr);
 Lines 212-238   FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co Link Here 
212
        }
213
        }
213
      else
214
      else
214
        {
215
        {
216
          Ptr<FlameTag> tag = CreateObject<FlameTag> (*origTag);
215
          // We check sequence only when forward unicast, because broadcast-checks were done
217
          // We check sequence only when forward unicast, because broadcast-checks were done
216
          // inside remove routing stuff.
218
          // inside remove routing stuff.
217
          if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface))
219
          if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag->transmitter, sourceIface))
218
            {
220
            {
219
              return false;
221
              return false;
220
            }
222
            }
221
          FlameRtable::LookupResult result = m_rtable->Lookup (destination);
223
          FlameRtable::LookupResult result = m_rtable->Lookup (destination);
222
          if (tag.receiver != Mac48Address::GetBroadcast ())
224
          if (origTag->receiver != Mac48Address::GetBroadcast ())
223
            {
225
            {
224
              if (result.retransmitter == Mac48Address::GetBroadcast ())
226
              if (result.retransmitter == Mac48Address::GetBroadcast ())
225
                {
227
                {
226
                  NS_LOG_DEBUG ("unicast packet dropped, because no route! I am " << GetAddress ()
228
                  NS_LOG_DEBUG ("unicast packet dropped, because no route! I am " << GetAddress ()
227
                                                                                  << ", RA = " << tag.receiver << ", TA = " << tag.transmitter);
229
                                                                                  << ", RA = " << origTag->receiver << ", TA = " << origTag->transmitter);
228
                  m_stats.totalDropped++;
230
                  m_stats.totalDropped++;
229
                  return false;
231
                  return false;
230
                }
232
                }
231
              tag.receiver = result.retransmitter;
233
              tag->receiver = result.retransmitter;
232
            }
234
            }
233
          else
235
          else
234
            {
236
            {
235
              tag.receiver = Mac48Address::GetBroadcast ();
237
              tag->receiver = Mac48Address::GetBroadcast ();
236
            }
238
            }
237
          if (result.retransmitter == Mac48Address::GetBroadcast ())
239
          if (result.retransmitter == Mac48Address::GetBroadcast ())
238
            {
240
            {
 Lines 263-276   FlameProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source Link Here 
263
      NS_LOG_DEBUG ("Dropped my own frame!");
265
      NS_LOG_DEBUG ("Dropped my own frame!");
264
      return false;
266
      return false;
265
    }
267
    }
266
  FlameTag tag;
268
  Ptr<const FlameTag> tag = packet->RemovePacketTag <FlameTag> ();
267
  if (!packet->RemovePacketTag (tag))
269
  if (tag == 0)
268
    {
270
    {
269
      NS_FATAL_ERROR ("FLAME tag must exist when packet is coming to protocol");
271
      NS_FATAL_ERROR ("FLAME tag must exist when packet is coming to protocol");
270
    }
272
    }
271
  FlameHeader flameHdr;
273
  FlameHeader flameHdr;
272
  packet->RemoveHeader (flameHdr);
274
  packet->RemoveHeader (flameHdr);
273
  if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface))
275
  if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag->transmitter, fromIface))
274
    {
276
    {
275
      return false;
277
      return false;
276
    }
278
    }
(-)a/src/mesh/model/mesh-wifi-interface-mac.cc (-5 / +5 lines)
 Lines 222-236   MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address Link Here 
222
  //Classify: application sets a tag, which is removed here
222
  //Classify: application sets a tag, which is removed here
223
  // Get Qos tag:
223
  // Get Qos tag:
224
  AcIndex ac = AC_BE;
224
  AcIndex ac = AC_BE;
225
  QosTag tag;
225
  Ptr<const QosTag> tag = packet->RemovePacketTag<QosTag> ();
226
  if (packet->RemovePacketTag (tag))
226
  if (tag != 0)
227
    {
227
    {
228
      hdr.SetType (WIFI_MAC_QOSDATA);
228
      hdr.SetType (WIFI_MAC_QOSDATA);
229
      hdr.SetQosTid (tag.GetTid ());
229
      hdr.SetQosTid (tag->GetTid ());
230
      //Aftre setting type DsFrom and DsTo fields are reset.
230
      //Aftre setting type DsFrom and DsTo fields are reset.
231
      hdr.SetDsFrom ();
231
      hdr.SetDsFrom ();
232
      hdr.SetDsTo ();
232
      hdr.SetDsTo ();
233
      ac = QosUtilsMapTidToAc (tag.GetTid ());
233
      ac = QosUtilsMapTidToAc (tag->GetTid ());
234
    }
234
    }
235
  m_stats.sentFrames++;
235
  m_stats.sentFrames++;
236
  m_stats.sentBytes += packet->GetSize ();
236
  m_stats.sentBytes += packet->GetSize ();
 Lines 446-452   MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr) Link Here 
446
  // Check if QoS tag exists and add it:
446
  // Check if QoS tag exists and add it:
447
  if (hdr->IsQosData ())
447
  if (hdr->IsQosData ())
448
    {
448
    {
449
      packet->AddPacketTag (QosTag (hdr->GetQosTid ()));
449
      packet->AddPacketTag (CreateObject<QosTag> (hdr->GetQosTid ()));
450
    }
450
    }
451
  // Forward data up
451
  // Forward data up
452
  if (hdr->IsData ())
452
  if (hdr->IsData ())
(-)a/src/network/examples/main-packet-tag.cc (-5 / +4 lines)
 Lines 96-103   MyTag::GetSimpleValue (void) const Link Here 
96
int main (int argc, char *argv[])
96
int main (int argc, char *argv[])
97
{
97
{
98
  // create a tag.
98
  // create a tag.
99
  MyTag tag;
99
  Ptr<MyTag> tag = CreateObject<MyTag> ();
100
  tag.SetSimpleValue (0x56);
100
  tag->SetSimpleValue (0x56);
101
101
102
  // store the tag in a packet.
102
  // store the tag in a packet.
103
  Ptr<Packet> p = Create<Packet> (100);
103
  Ptr<Packet> p = Create<Packet> (100);
 Lines 107-117   int main (int argc, char *argv[]) Link Here 
107
  Ptr<Packet> aCopy = p->Copy ();
107
  Ptr<Packet> aCopy = p->Copy ();
108
108
109
  // read the tag from the packet copy
109
  // read the tag from the packet copy
110
  MyTag tagCopy;
110
  Ptr<const MyTag> tagCopy = p->PeekPacketTag<MyTag> ();
111
  p->PeekPacketTag (tagCopy);
112
111
113
  // the copy and the original are the same !
112
  // the copy and the original are the same !
114
  NS_ASSERT (tagCopy.GetSimpleValue () == tag.GetSimpleValue ());
113
  NS_ASSERT (tagCopy->GetSimpleValue () == tag->GetSimpleValue ());
115
114
116
  aCopy->PrintPacketTags (std::cout);
115
  aCopy->PrintPacketTags (std::cout);
117
  std::cout << std::endl;
116
  std::cout << std::endl;
(-)a/src/network/utils/packet-socket.cc (-15 / +11 lines)
 Lines 385-397   PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet, Link Here 
385
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
385
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
386
    {
386
    {
387
      Ptr<Packet> copy = packet->Copy ();
387
      Ptr<Packet> copy = packet->Copy ();
388
      DeviceNameTag dnt;
388
      Ptr<DeviceNameTag> dnt = CreateObject<DeviceNameTag> ();
389
      dnt.SetDeviceName (device->GetTypeId ().GetName ());
389
      dnt->SetDeviceName (device->GetTypeId ().GetName ());
390
      PacketSocketTag pst;
390
      Ptr<PacketSocketTag> pst = CreateObject<PacketSocketTag> ();
391
      pst.SetPacketType (packetType);
391
      pst->SetPacketType (packetType);
392
      pst.SetDestAddress (to);
392
      pst->SetDestAddress (to);
393
      SocketAddressTag tag;
393
      Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
394
      tag.SetAddress (address);
394
      tag->SetAddress (address);
395
      copy->AddPacketTag (tag); // Attach From Physical Address
395
      copy->AddPacketTag (tag); // Attach From Physical Address
396
      copy->AddPacketTag (pst); // Attach Packet Type and Dest Address
396
      copy->AddPacketTag (pst); // Attach Packet Type and Dest Address
397
      copy->AddPacketTag (dnt); // Attach device source name
397
      copy->AddPacketTag (dnt); // Attach device source name
 Lines 449-459   PacketSocket::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress) Link Here 
449
  Ptr<Packet> packet = Recv (maxSize, flags);
449
  Ptr<Packet> packet = Recv (maxSize, flags);
450
  if (packet != 0)
450
  if (packet != 0)
451
    {
451
    {
452
      SocketAddressTag tag;
452
      Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
453
      bool found;
453
      NS_ASSERT (tag != 0);
454
      found = packet->PeekPacketTag (tag);
454
      fromAddress = tag->GetAddress ();
455
      NS_ASSERT (found);
456
      fromAddress = tag.GetAddress ();
457
    }
455
    }
458
  return packet;
456
  return packet;
459
}
457
}
 Lines 611-617   uint32_t Link Here 
611
DeviceNameTag::GetSerializedSize (void) const
609
DeviceNameTag::GetSerializedSize (void) const
612
{
610
{
613
  uint32_t s = 1 + m_deviceName.size();
611
  uint32_t s = 1 + m_deviceName.size();
614
  return ( s >= PACKET_TAG_MAX_SIZE)?PACKET_TAG_MAX_SIZE:s;
612
  return s;
615
}
613
}
616
void
614
void
617
DeviceNameTag::Serialize (TagBuffer i) const
615
DeviceNameTag::Serialize (TagBuffer i) const
 Lines 619-626   DeviceNameTag::Serialize (TagBuffer i) const Link Here 
619
  const char *n = m_deviceName.c_str();
617
  const char *n = m_deviceName.c_str();
620
  uint8_t l = (uint8_t) strlen (n);
618
  uint8_t l = (uint8_t) strlen (n);
621
619
622
  if ( ( 1 + l ) > PACKET_TAG_MAX_SIZE ) l = PACKET_TAG_MAX_SIZE - 1;
623
624
  i.WriteU8 (l);
620
  i.WriteU8 (l);
625
  i.Write ( (uint8_t*) n , (uint32_t) l );
621
  i.Write ( (uint8_t*) n , (uint32_t) l );
626
}
622
}
(-)a/src/virtual-net-device/examples/virtual-net-device.cc (-6 / +3 lines)
 Lines 113-120   class Tunnel Link Here 
113
  {
113
  {
114
    Ptr<Packet> packet = socket->Recv (65535, 0);
114
    Ptr<Packet> packet = socket->Recv (65535, 0);
115
    NS_LOG_DEBUG ("N3SocketRecv: " << *packet);
115
    NS_LOG_DEBUG ("N3SocketRecv: " << *packet);
116
    SocketAddressTag socketAddressTag;
116
    packet->RemovePacketTag<SocketAddressTag> ();
117
    packet->RemovePacketTag (socketAddressTag);
118
    m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST);
117
    m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST);
119
  }
118
  }
120
119
 Lines 122-129   class Tunnel Link Here 
122
  {
121
  {
123
    Ptr<Packet> packet = socket->Recv (65535, 0);
122
    Ptr<Packet> packet = socket->Recv (65535, 0);
124
    NS_LOG_DEBUG ("N0SocketRecv: " << *packet);
123
    NS_LOG_DEBUG ("N0SocketRecv: " << *packet);
125
    SocketAddressTag socketAddressTag;
124
    packet->RemovePacketTag<SocketAddressTag> ();
126
    packet->RemovePacketTag (socketAddressTag);
127
    m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST);
125
    m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST);
128
  }
126
  }
129
127
 Lines 131-138   class Tunnel Link Here 
131
  {
129
  {
132
    Ptr<Packet> packet = socket->Recv (65535, 0);
130
    Ptr<Packet> packet = socket->Recv (65535, 0);
133
    NS_LOG_DEBUG ("N1SocketRecv: " << *packet);
131
    NS_LOG_DEBUG ("N1SocketRecv: " << *packet);
134
    SocketAddressTag socketAddressTag;
132
    packet->RemovePacketTag<SocketAddressTag> ();
135
    packet->RemovePacketTag (socketAddressTag);
136
    m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST);
133
    m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST);
137
  }
134
  }
138
135
(-)a/src/wifi/model/mac-low.cc (-10 / +8 lines)
 Lines 709-720   MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb Link Here 
709
           && m_currentPacket != 0)
709
           && m_currentPacket != 0)
710
    {
710
    {
711
      NS_LOG_DEBUG ("receive cts from=" << m_currentHdr.GetAddr1 ());
711
      NS_LOG_DEBUG ("receive cts from=" << m_currentHdr.GetAddr1 ());
712
      SnrTag tag;
712
      Ptr<const SnrTag> tag = packet->RemovePacketTag<SnrTag> ();
713
      packet->RemovePacketTag (tag);
714
      m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
713
      m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
715
                                    rxSnr, txMode);
714
                                    rxSnr, txMode);
716
      m_stationManager->ReportRtsOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
715
      m_stationManager->ReportRtsOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
717
                                     rxSnr, txMode, tag.Get ());
716
                                     rxSnr, txMode, tag->Get ());
718
717
719
      m_ctsTimeoutEvent.Cancel ();
718
      m_ctsTimeoutEvent.Cancel ();
720
      NotifyCtsTimeoutResetNow ();
719
      NotifyCtsTimeoutResetNow ();
 Lines 734-745   MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb Link Here 
734
           && m_txParams.MustWaitAck ())
733
           && m_txParams.MustWaitAck ())
735
    {
734
    {
736
      NS_LOG_DEBUG ("receive ack from=" << m_currentHdr.GetAddr1 ());
735
      NS_LOG_DEBUG ("receive ack from=" << m_currentHdr.GetAddr1 ());
737
      SnrTag tag;
736
      Ptr<const SnrTag> tag = packet->RemovePacketTag<SnrTag> ();
738
      packet->RemovePacketTag (tag);
739
      m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
737
      m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
740
                                    rxSnr, txMode);
738
                                    rxSnr, txMode);
741
      m_stationManager->ReportDataOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
739
      m_stationManager->ReportDataOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
742
                                      rxSnr, txMode, tag.Get ());
740
                                      rxSnr, txMode, tag->Get ());
743
      bool gotAck = false;
741
      bool gotAck = false;
744
      if (m_txParams.MustWaitNormalAck ()
742
      if (m_txParams.MustWaitNormalAck ()
745
          && m_normalAckTimeoutEvent.IsRunning ())
743
          && m_normalAckTimeoutEvent.IsRunning ())
 Lines 1446-1453   MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiMode rtsTxMode, Link Here 
1446
  WifiMacTrailer fcs;
1444
  WifiMacTrailer fcs;
1447
  packet->AddTrailer (fcs);
1445
  packet->AddTrailer (fcs);
1448
1446
1449
  SnrTag tag;
1447
  Ptr<SnrTag> tag = CreateObject<SnrTag> ();
1450
  tag.Set (rtsSnr);
1448
  tag->Set (rtsSnr);
1451
  packet->AddPacketTag (tag);
1449
  packet->AddPacketTag (tag);
1452
1450
1453
  ForwardDown (packet, &cts, ctsTxMode);
1451
  ForwardDown (packet, &cts, ctsTxMode);
 Lines 1525-1532   MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMod Link Here 
1525
  WifiMacTrailer fcs;
1523
  WifiMacTrailer fcs;
1526
  packet->AddTrailer (fcs);
1524
  packet->AddTrailer (fcs);
1527
1525
1528
  SnrTag tag;
1526
  Ptr<SnrTag> tag = CreateObject<SnrTag> ();
1529
  tag.Set (dataSnr);
1527
  tag->Set (dataSnr);
1530
  packet->AddPacketTag (tag);
1528
  packet->AddPacketTag (tag);
1531
1529
1532
  ForwardDown (packet, &ack, ackTxMode);
1530
  ForwardDown (packet, &ack, ackTxMode);
(-)a/src/wifi/model/qos-utils.cc (-4 / +4 lines)
 Lines 59-71   QosUtilsMapTidToAc (uint8_t tid) Link Here 
59
uint8_t
59
uint8_t
60
QosUtilsGetTidForPacket (Ptr<const Packet> packet)
60
QosUtilsGetTidForPacket (Ptr<const Packet> packet)
61
{
61
{
62
  QosTag qos;
62
  Ptr<const QosTag> qos = packet->PeekPacketTag<QosTag> ();
63
  uint8_t tid = 8;
63
  uint8_t tid = 8;
64
  if (packet->PeekPacketTag (qos))
64
  if (qos != 0)
65
    {
65
    {
66
      if (qos.GetTid () < 8)
66
      if (qos->GetTid () < 8)
67
        {
67
        {
68
          tid = qos.GetTid ();
68
          tid = qos->GetTid ();
69
        }
69
        }
70
    }
70
    }
71
  return tid;
71
  return tid;
(-)a/src/wifi/model/wifi-remote-station-manager.cc (-14 / +10 lines)
 Lines 347-358   WifiRemoteStationManager::PrepareForQueue (Mac48Address address, const WifiMacHe Link Here 
347
  WifiRemoteStation *station = Lookup (address, header);
347
  WifiRemoteStation *station = Lookup (address, header);
348
  WifiMode rts = DoGetRtsMode (station);
348
  WifiMode rts = DoGetRtsMode (station);
349
  WifiMode data = DoGetDataMode (station, fullPacketSize);
349
  WifiMode data = DoGetDataMode (station, fullPacketSize);
350
  TxModeTag tag;
350
  
351
  // first, make sure that the tag is not here anymore.
351
  // first, make sure that the tag is not here anymore.
352
  ConstCast<Packet> (packet)->RemovePacketTag (tag);
352
  ConstCast<Packet> (packet)->RemovePacketTag<TxModeTag> ();
353
  tag = TxModeTag (rts, data);
353
  Ptr<TxModeTag> tag = CreateObject<TxModeTag> (rts, data);
354
  // and then, add it back
354
  // and then, add it back
355
  packet->AddPacketTag (tag);
355
  ConstCast<Packet> (packet)->AddPacketTag (tag);
356
}
356
}
357
WifiMode
357
WifiMode
358
WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader *header,
358
WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader *header,
 Lines 364-374   WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader Link Here 
364
    }
364
    }
365
  if (!IsLowLatency ())
365
  if (!IsLowLatency ())
366
    {
366
    {
367
      TxModeTag tag;
367
      Ptr<const TxModeTag> tag = packet->PeekPacketTag<TxModeTag> ();
368
      bool found;
368
      NS_ASSERT (tag != 0);
369
      found = ConstCast<Packet> (packet)->PeekPacketTag (tag);
369
      return tag->GetDataMode ();
370
      NS_ASSERT (found);
371
      return tag.GetDataMode ();
372
    }
370
    }
373
  return DoGetDataMode (Lookup (address, header), fullPacketSize);
371
  return DoGetDataMode (Lookup (address, header), fullPacketSize);
374
}
372
}
 Lines 379-389   WifiRemoteStationManager::GetRtsMode (Mac48Address address, const WifiMacHeader Link Here 
379
  NS_ASSERT (!address.IsGroup ());
377
  NS_ASSERT (!address.IsGroup ());
380
  if (!IsLowLatency ())
378
  if (!IsLowLatency ())
381
    {
379
    {
382
      TxModeTag tag;
380
      Ptr<const TxModeTag> tag = packet->PeekPacketTag<TxModeTag> ();
383
      bool found;
381
      NS_ASSERT (tag != 0);
384
      found = ConstCast<Packet> (packet)->PeekPacketTag (tag);
382
      return tag->GetRtsMode ();
385
      NS_ASSERT (found);
386
      return tag.GetRtsMode ();
387
    }
383
    }
388
  return DoGetRtsMode (Lookup (address, header));
384
  return DoGetRtsMode (Lookup (address, header));
389
}
385
}
(-)a/utils/bench-packets.cc (-7 / +6 lines)
 Lines 163-181   benchD (uint32_t n) Link Here 
163
{
163
{
164
  BenchHeader<25> ipv4;
164
  BenchHeader<25> ipv4;
165
  BenchHeader<8> udp;
165
  BenchHeader<8> udp;
166
  BenchTag<16> tag1;
167
  BenchTag<17> tag2;
168
166
169
  for (uint32_t i = 0; i < n; i++) {
167
  for (uint32_t i = 0; i < n; i++) {
170
    Ptr<Packet> p = Create<Packet> (2000);
168
    Ptr<Packet> p = Create<Packet> (2000);
171
    p->AddPacketTag (tag1);
169
    p->AddPacketTag (CreateObject<BenchTag<16> > ());
172
    p->AddHeader (udp);
170
    p->AddHeader (udp);
173
    p->RemovePacketTag (tag1);
171
    p->RemovePacketTag (BenchTag<16>::GetTypeId ());
174
    p->AddPacketTag (tag2);
172
    
173
    p->AddPacketTag (CreateObject<BenchTag<17> > ());
175
    p->AddHeader (ipv4);
174
    p->AddHeader (ipv4);
175
    
176
    Ptr<Packet> o = p->Copy ();
176
    Ptr<Packet> o = p->Copy ();
177
    o->RemoveHeader (ipv4);
177
    o->RemoveHeader (ipv4);
178
    p->RemovePacketTag (tag2);
178
    p->RemovePacketTag (BenchTag<17>::GetTypeId ());
179
    o->RemoveHeader (udp);
179
    o->RemoveHeader (udp);
180
  }
180
  }
181
}
181
}
182
- 

Return to bug 1383