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 332-340   RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Link Here 
332
  // Actual route request will be deferred until packet will be fully formed, 
332
  // Actual route request will be deferred until packet will be fully formed, 
333
  // routed to loopback, received from loopback and passed to RouteInput (see below)
333
  // routed to loopback, received from loopback and passed to RouteInput (see below)
334
  uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
334
  uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
335
  DeferredRouteOutputTag tag (iif);
335
  if (p->PeekPacketTag<DeferredRouteOutputTag> () == 0)
336
  if (!p->PeekPacketTag (tag))
337
    {
336
    {
337
      Ptr<DeferredRouteOutputTag> tag = CreateObject<DeferredRouteOutputTag> (iif);
338
      p->AddPacketTag (tag);
338
      p->AddPacketTag (tag);
339
    }
339
    }
340
  return LoopbackRoute (header, oif);
340
  return LoopbackRoute (header, oif);
 Lines 385-392   RoutingProtocol::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Link Here 
385
  // Deferred route request
385
  // Deferred route request
386
  if (idev == m_lo)
386
  if (idev == m_lo)
387
    {
387
    {
388
      DeferredRouteOutputTag tag;
388
      if (p->PeekPacketTag<DeferredRouteOutputTag> () != 0)
389
      if (p->PeekPacketTag (tag))
390
        {
389
        {
391
          DeferredRouteOutput (p, header, ucb, ecb);
390
          DeferredRouteOutput (p, header, ucb, ecb);
392
          return true;
391
          return true;
 Lines 1574-1584   RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route) Link Here 
1574
  QueueEntry queueEntry;
1573
  QueueEntry queueEntry;
1575
  while (m_queue.Dequeue (dst, queueEntry))
1574
  while (m_queue.Dequeue (dst, queueEntry))
1576
    {
1575
    {
1577
      DeferredRouteOutputTag tag;
1578
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1576
      Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
1579
      if (p->RemovePacketTag (tag) && 
1577
      Ptr<const DeferredRouteOutputTag> tag = p->RemovePacketTag<DeferredRouteOutputTag> ();
1580
          tag.oif != -1 && 
1578
      if (tag != 0 && 
1581
          tag.oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1579
          tag->oif != -1 && 
1580
          tag->oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
1582
        {
1581
        {
1583
          NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1582
          NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
1584
          return;
1583
          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 754-763   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address src, Ipv6Add Link Here 
754
{
754
{
755
  NS_LOG_FUNCTION (this << packet << src << dst << (uint32_t)ttl);
755
  NS_LOG_FUNCTION (this << packet << src << dst << (uint32_t)ttl);
756
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
756
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
757
  SocketIpTtlTag tag;
758
  NS_ASSERT (ipv6 != 0);
757
  NS_ASSERT (ipv6 != 0);
759
758
760
  tag.SetTtl (ttl);
759
  Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
760
  tag->SetTtl (ttl);
761
  packet->AddPacketTag (tag);
761
  packet->AddPacketTag (tag);
762
  m_downTarget (packet, src, dst, PROT_NUMBER, 0);
762
  m_downTarget (packet, src, dst, PROT_NUMBER, 0);
763
}
763
}
 Lines 768-774   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H Link Here 
768
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
768
  Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
769
  NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
769
  NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
770
  Ipv6Header header;
770
  Ipv6Header header;
771
  SocketIpTtlTag tag;
772
  Socket::SocketErrno err;
771
  Socket::SocketErrno err;
773
  Ptr<Ipv6Route> route;
772
  Ptr<Ipv6Route> route;
774
  Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
773
  Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
 Lines 779-785   void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H Link Here 
779
  if (route != 0)
778
  if (route != 0)
780
    {
779
    {
781
      NS_LOG_LOGIC ("Route exists");
780
      NS_LOG_LOGIC ("Route exists");
782
      tag.SetTtl (ttl);
781
      Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
782
      tag->SetTtl (ttl);
783
      packet->AddPacketTag (tag);
783
      packet->AddPacketTag (tag);
784
      Ipv6Address src = route->GetSource ();
784
      Ipv6Address src = route->GetSource ();
785
785
(-)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 593-604   void Ipv6L3Protocol::Send (Ptr<Packet> packet, Ipv6Address source, Ipv6Address d Link Here 
593
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol << route);
593
  NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol << route);
594
  Ipv6Header hdr;
594
  Ipv6Header hdr;
595
  uint8_t ttl = m_defaultTtl;
595
  uint8_t ttl = m_defaultTtl;
596
  SocketIpTtlTag tag;
596
  Ptr<const SocketIpTtlTag> tag = packet->RemovePacketTag<SocketIpTtlTag> ();
597
  bool found = packet->RemovePacketTag (tag);
598
597
599
  if (found)
598
  if (tag != 0)
600
    {
599
    {
601
      ttl = tag.GetTtl ();
600
      ttl = tag->GetTtl ();
602
    }
601
    }
603
602
604
  /* Handle 3 cases:
603
  /* 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 (-71 / +72 lines)
 Lines 271-300   TcpSocketBase::Bind (const Address &address) Link Here 
271
  NS_LOG_FUNCTION (this << address);
271
  NS_LOG_FUNCTION (this << address);
272
  if (InetSocketAddress::IsMatchingType (address))
272
  if (InetSocketAddress::IsMatchingType (address))
273
    {
273
    {
274
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
274
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
275
      Ipv4Address ipv4 = transport.GetIpv4 ();
275
  Ipv4Address ipv4 = transport.GetIpv4 ();
276
      uint16_t port = transport.GetPort ();
276
  uint16_t port = transport.GetPort ();
277
      if (ipv4 == Ipv4Address::GetAny () && port == 0)
277
  if (ipv4 == Ipv4Address::GetAny () && port == 0)
278
        {
278
    {
279
          m_endPoint = m_tcp->Allocate ();
279
      m_endPoint = m_tcp->Allocate ();
280
        }
280
    }
281
      else if (ipv4 == Ipv4Address::GetAny () && port != 0)
281
  else if (ipv4 == Ipv4Address::GetAny () && port != 0)
282
        {
282
    {
283
          m_endPoint = m_tcp->Allocate (port);
283
      m_endPoint = m_tcp->Allocate (port);
284
        }
284
    }
285
      else if (ipv4 != Ipv4Address::GetAny () && port == 0)
285
  else if (ipv4 != Ipv4Address::GetAny () && port == 0)
286
        {
286
    {
287
          m_endPoint = m_tcp->Allocate (ipv4);
287
      m_endPoint = m_tcp->Allocate (ipv4);
288
        }
288
    }
289
      else if (ipv4 != Ipv4Address::GetAny () && port != 0)
289
  else if (ipv4 != Ipv4Address::GetAny () && port != 0)
290
        {
290
    {
291
          m_endPoint = m_tcp->Allocate (ipv4, port);
291
      m_endPoint = m_tcp->Allocate (ipv4, port);
292
        }
292
    }
293
      if (0 == m_endPoint)
293
  if (0 == m_endPoint)
294
        {
294
    {
295
          m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
295
      m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
296
          return -1;
296
      return -1;
297
        }
297
    }
298
    }
298
    }
299
  else if (Inet6SocketAddress::IsMatchingType (address))
299
  else if (Inet6SocketAddress::IsMatchingType (address))
300
    {
300
    {
 Lines 343-366   TcpSocketBase::Connect (const Address & address) Link Here 
343
  // If haven't do so, Bind() this socket first
343
  // If haven't do so, Bind() this socket first
344
  if (InetSocketAddress::IsMatchingType (address))
344
  if (InetSocketAddress::IsMatchingType (address))
345
    {
345
    {
346
      if (m_endPoint == 0)
346
  if (m_endPoint == 0)
347
    {
348
      if (Bind () == -1)
347
        {
349
        {
348
          if (Bind () == -1)
350
          NS_ASSERT (m_endPoint == 0);
349
            {
351
          return -1; // Bind() failed
350
              NS_ASSERT (m_endPoint == 0);
351
              return -1; // Bind() failed
352
            }
353
          NS_ASSERT (m_endPoint != 0);
354
        }
352
        }
355
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
353
      NS_ASSERT (m_endPoint != 0);
356
      m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
354
    }
355
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
356
  m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
357
      m_endPoint6 = 0;
357
      m_endPoint6 = 0;
358
358
359
      // Get the appropriate local address and port number from the routing protocol and set up endpoint
359
  // Get the appropriate local address and port number from the routing protocol and set up endpoint
360
      if (SetupEndpoint () != 0)
360
  if (SetupEndpoint () != 0)
361
        { // Route to destination does not exist
361
    { // Route to destination does not exist
362
          return -1;
362
      return -1;
363
        }
363
    }
364
    }
364
    }
365
  else if (Inet6SocketAddress::IsMatchingType (address) )
365
  else if (Inet6SocketAddress::IsMatchingType (address) )
366
    {
366
    {
 Lines 516-530   TcpSocketBase::Recv (uint32_t maxSize, uint32_t flags) Link Here 
516
  Ptr<Packet> outPacket = m_rxBuffer.Extract (maxSize);
516
  Ptr<Packet> outPacket = m_rxBuffer.Extract (maxSize);
517
  if (outPacket != 0 && outPacket->GetSize () != 0)
517
  if (outPacket != 0 && outPacket->GetSize () != 0)
518
    {
518
    {
519
      SocketAddressTag tag;
519
      Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
520
      if (m_endPoint != 0)
520
      if (m_endPoint != 0)
521
        {
521
        {
522
          tag.SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
522
          tag->SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
523
        }
523
        }
524
      else if (m_endPoint6 != 0)
524
      else if (m_endPoint6 != 0)
525
        {
525
        {
526
          tag.SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
526
          tag->SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
527
        }
527
        }
528
      
528
      outPacket->AddPacketTag (tag);
529
      outPacket->AddPacketTag (tag);
529
    }
530
    }
530
  return outPacket;
531
  return outPacket;
 Lines 611-617   TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice) Link Here 
611
612
612
  if (m_endPoint != 0)
613
  if (m_endPoint != 0)
613
    {
614
    {
614
      m_endPoint->BindToNetDevice (netdevice);
615
  m_endPoint->BindToNetDevice (netdevice);
615
    }
616
    }
616
  // No BindToNetDevice() for Ipv6EndPoint
617
  // No BindToNetDevice() for Ipv6EndPoint
617
  return;
618
  return;
 Lines 629-636   TcpSocketBase::SetupCallback (void) Link Here 
629
    }
630
    }
630
  if (m_endPoint != 0)
631
  if (m_endPoint != 0)
631
    {
632
    {
632
      m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this))); 
633
  m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this)));
633
      m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
634
  m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
634
    }
635
    }
635
  if (m_endPoint6 != 0)
636
  if (m_endPoint6 != 0)
636
    {
637
    {
 Lines 1139-1146   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1139
      m_txBuffer.SetHeadSequence (m_nextTxSequence);
1140
      m_txBuffer.SetHeadSequence (m_nextTxSequence);
1140
      if (m_endPoint)
1141
      if (m_endPoint)
1141
        {
1142
        {
1142
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1143
      m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1143
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1144
                           InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1144
        }
1145
        }
1145
      else if (m_endPoint6)
1146
      else if (m_endPoint6)
1146
        {
1147
        {
 Lines 1173-1180   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1173
          m_txBuffer.SetHeadSequence (m_nextTxSequence);
1174
          m_txBuffer.SetHeadSequence (m_nextTxSequence);
1174
          if (m_endPoint)
1175
          if (m_endPoint)
1175
            {
1176
            {
1176
              m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1177
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1177
                                   InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1178
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1178
            }
1179
            }
1179
          else if (m_endPoint6)
1180
          else if (m_endPoint6)
1180
            {
1181
            {
 Lines 1191-1198   TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader, Link Here 
1191
          NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
1192
          NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
1192
          if (m_endPoint)
1193
          if (m_endPoint)
1193
            {
1194
            {
1194
              m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1195
          m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1195
                                   InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1196
                               InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1196
            }
1197
            }
1197
          else if (m_endPoint6)
1198
          else if (m_endPoint6)
1198
            {
1199
            {
 Lines 1425-1436   TcpSocketBase::Destroy (void) Link Here 
1425
  m_endPoint = 0;
1426
  m_endPoint = 0;
1426
  if (m_tcp != 0)
1427
  if (m_tcp != 0)
1427
    {
1428
    {
1428
      std::vector<Ptr<TcpSocketBase> >::iterator it
1429
  std::vector<Ptr<TcpSocketBase> >::iterator it
1429
        = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
1430
    = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
1430
      if (it != m_tcp->m_sockets.end ())
1431
  if (it != m_tcp->m_sockets.end ())
1431
        {
1432
    {
1432
          m_tcp->m_sockets.erase (it);
1433
      m_tcp->m_sockets.erase (it);
1433
        }
1434
    }
1434
    }
1435
    }
1435
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1436
  NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
1436
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
1437
                (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
 Lines 1486-1493   TcpSocketBase::SendEmptyPacket (uint8_t flags) Link Here 
1486
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1487
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1487
  if (m_endPoint != 0)
1488
  if (m_endPoint != 0)
1488
    {
1489
    {
1489
      header.SetSourcePort (m_endPoint->GetLocalPort ());
1490
  header.SetSourcePort (m_endPoint->GetLocalPort ());
1490
      header.SetDestinationPort (m_endPoint->GetPeerPort ());
1491
  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1491
    }
1492
    }
1492
  else
1493
  else
1493
    {
1494
    {
 Lines 1576-1582   TcpSocketBase::DeallocateEndPoint (void) Link Here 
1576
      if (it != m_tcp->m_sockets.end ())
1577
      if (it != m_tcp->m_sockets.end ())
1577
        {
1578
        {
1578
          m_tcp->m_sockets.erase (it);
1579
          m_tcp->m_sockets.erase (it);
1579
        }
1580
}
1580
      CancelAllTimers ();
1581
      CancelAllTimers ();
1581
    }
1582
    }
1582
}
1583
}
 Lines 1652-1661   TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h, Link Here 
1652
  // Get port and address from peer (connecting host)
1653
  // Get port and address from peer (connecting host)
1653
  if (InetSocketAddress::IsMatchingType (toAddress))
1654
  if (InetSocketAddress::IsMatchingType (toAddress))
1654
    {
1655
    {
1655
      m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
1656
  m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
1656
                                    InetSocketAddress::ConvertFrom (toAddress).GetPort (),
1657
                                InetSocketAddress::ConvertFrom (toAddress).GetPort (),
1657
                                    InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1658
                                InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
1658
                                    InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1659
                                InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
1659
      m_endPoint6 = 0;
1660
      m_endPoint6 = 0;
1660
    }
1661
    }
1661
  else if (Inet6SocketAddress::IsMatchingType (toAddress))
1662
  else if (Inet6SocketAddress::IsMatchingType (toAddress))
 Lines 1723-1730   TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with Link Here 
1723
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1724
  header.SetAckNumber (m_rxBuffer.NextRxSequence ());
1724
  if (m_endPoint)
1725
  if (m_endPoint)
1725
    {
1726
    {
1726
      header.SetSourcePort (m_endPoint->GetLocalPort ());
1727
  header.SetSourcePort (m_endPoint->GetLocalPort ());
1727
      header.SetDestinationPort (m_endPoint->GetPeerPort ());
1728
  header.SetDestinationPort (m_endPoint->GetPeerPort ());
1728
    }
1729
    }
1729
  else
1730
  else
1730
    {
1731
    {
 Lines 1744-1751   TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with Link Here 
1744
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
1745
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
1745
  if (m_endPoint)
1746
  if (m_endPoint)
1746
    {
1747
    {
1747
      m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1748
  m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
1748
                         m_endPoint->GetPeerAddress (), m_boundnetdevice);
1749
                     m_endPoint->GetPeerAddress (), m_boundnetdevice);
1749
    }
1750
    }
1750
  else
1751
  else
1751
    {
1752
    {
 Lines 2024-2031   TcpSocketBase::PersistTimeout () Link Here 
2024
  tcpHeader.SetWindowSize (AdvertisedWindowSize ());
2025
  tcpHeader.SetWindowSize (AdvertisedWindowSize ());
2025
  if (m_endPoint != 0)
2026
  if (m_endPoint != 0)
2026
    {
2027
    {
2027
      tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
2028
  tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
2028
      tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
2029
  tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
2029
    }
2030
    }
2030
  else
2031
  else
2031
    {
2032
    {
 Lines 2036-2043   TcpSocketBase::PersistTimeout () Link Here 
2036
2037
2037
  if (m_endPoint != 0)
2038
  if (m_endPoint != 0)
2038
    {
2039
    {
2039
      m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
2040
  m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
2040
                         m_endPoint->GetPeerAddress (), m_boundnetdevice);
2041
                     m_endPoint->GetPeerAddress (), m_boundnetdevice);
2041
    }
2042
    }
2042
  else
2043
  else
2043
    {
2044
    {
(-)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/model/packet-tag-list.cc (-126 / +122 lines)
 Lines 28-177   NS_LOG_COMPONENT_DEFINE ("PacketTagList"); Link Here 
28
28
29
namespace ns3 {
29
namespace ns3 {
30
30
31
#ifdef USE_FREE_LIST
32
33
struct PacketTagList::TagData *PacketTagList::g_free = 0;
34
uint32_t PacketTagList::g_nfree = 0;
35
36
struct PacketTagList::TagData *
37
PacketTagList::AllocData (void) const
38
{
39
  NS_LOG_FUNCTION (g_nfree);
40
  struct PacketTagList::TagData *retval;
41
  if (g_free != 0) 
42
    {
43
      retval = g_free;
44
      g_free = g_free->m_next;
45
      g_nfree--;
46
    } 
47
  else 
48
    {
49
      retval = new struct PacketTagList::TagData ();
50
    }
51
  return retval;
52
}
53
54
void
31
void
55
PacketTagList::FreeData (struct TagData *data) const
32
PacketTagList::Add (Ptr<const Tag> tag)
56
{
57
  NS_LOG_FUNCTION (g_nfree << data);
58
  if (g_nfree > 1000) 
59
    {
60
      delete data;
61
      return;
62
    }
63
  g_nfree++;
64
  data->next = g_free;
65
  data->tid = TypeId ();
66
  g_free = data;
67
}
68
#else
69
struct PacketTagList::TagData *
70
PacketTagList::AllocData (void) const
71
{
33
{
72
  NS_LOG_FUNCTION_NOARGS ();
34
  NS_LOG_FUNCTION (this << tag->GetInstanceTypeId ());
73
  struct PacketTagList::TagData *retval;
74
  retval = new struct PacketTagList::TagData ();
75
  return retval;
76
}
77
35
78
void
36
  NS_ASSERT_MSG (Peek (tag->GetInstanceTypeId ()) == 0,
79
PacketTagList::FreeData (struct TagData *data) const
37
                 "Only one tag type per packet is allowed");
80
{
38
81
  NS_LOG_FUNCTION (data);
39
  push_back (tag);
82
  delete data;
83
}
40
}
84
#endif
85
41
86
bool
42
Ptr<const Tag>
87
PacketTagList::Remove (Tag &tag)
43
PacketTagList::Remove (TypeId tagType)
88
{
44
{
89
  NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
45
  NS_LOG_FUNCTION (this << tagType);
90
  TypeId tid = tag.GetInstanceTypeId ();
46
  
91
  bool found = false;
47
  for (iterator tag = begin (); tag != end (); tag++)
92
  for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
93
    {
94
      if (cur->tid == tid) 
95
        {
96
          found = true;
97
          tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
98
        }
99
    }
100
  if (!found) 
101
    {
48
    {
102
      return false;
49
      if ((*tag)->GetInstanceTypeId () == tagType)
103
    }
104
  struct TagData *start = 0;
105
  struct TagData **prevNext = &start;
106
  for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
107
    {
108
      if (cur->tid == tid) 
109
        {
50
        {
110
          /**
51
          Ptr<const Tag> retval = *tag;
111
           * XXX
52
          erase (tag);
112
           * Note: I believe that we could optimize this to
53
          return retval;
113
           * avoid copying each TagData located after the target id
114
           * and just link the already-copied list to the next tag.
115
           */
116
          continue;
117
        }
54
        }
118
      struct TagData *copy = AllocData ();
119
      copy->tid = cur->tid;
120
      copy->count = 1;
121
      copy->next = 0;
122
      memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
123
      *prevNext = copy;
124
      prevNext = &copy->next;
125
    }
55
    }
126
  *prevNext = 0;
127
  RemoveAll ();
128
  m_next = start;
129
  return true;
130
}
131
56
132
void 
57
  return 0;
133
PacketTagList::Add (const Tag &tag) const
134
{
135
  NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
136
  // ensure this id was not yet added
137
  for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
138
    {
139
      NS_ASSERT (cur->tid != tag.GetInstanceTypeId ());
140
    }
141
  struct TagData *head = AllocData ();
142
  head->count = 1;
143
  head->next = 0;
144
  head->tid = tag.GetInstanceTypeId ();
145
  head->next = m_next;
146
  NS_ASSERT (tag.GetSerializedSize () <= PACKET_TAG_MAX_SIZE);
147
  tag.Serialize (TagBuffer (head->data, head->data+tag.GetSerializedSize ()));
148
149
  const_cast<PacketTagList *> (this)->m_next = head;
150
}
58
}
151
59
152
bool
60
Ptr<const Tag>
153
PacketTagList::Peek (Tag &tag) const
61
PacketTagList::Peek (TypeId tagType) const
154
{
62
{
155
  NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
63
  NS_LOG_FUNCTION (this << tagType);
156
  TypeId tid = tag.GetInstanceTypeId ();
64
  for (const_iterator tag = begin (); tag != end (); tag++)
157
  for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
158
    {
65
    {
159
      if (cur->tid == tid) 
66
      if ((*tag)->GetInstanceTypeId () == tagType)
160
        {
67
        return *tag;
161
          /* found tag */
162
          tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
163
          return true;
164
        }
165
    }
68
    }
166
  /* no tag found */
167
  return false;
168
}
169
69
170
const struct PacketTagList::TagData *
70
  return 0;
171
PacketTagList::Head (void) const
172
{
173
  return m_next;
174
}
71
}
175
72
73
74
// bool
75
// PacketTagList::Remove (Tag &tag)
76
// {
77
//   NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
78
79
//   return false;
80
  
81
//   // TypeId tid = tag.GetInstanceTypeId ();
82
//   // bool found = false;
83
//   // for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
84
//   //   {
85
//   //     if (cur->tid == tid) 
86
//   //       {
87
//   //         found = true;
88
//   //         tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
89
//   //       }
90
//   //   }
91
//   // if (!found) 
92
//   //   {
93
//   //     return false;
94
//   //   }
95
//   // struct TagData *start = 0;
96
//   // struct TagData **prevNext = &start;
97
//   // for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
98
//   //   {
99
//   //     if (cur->tid == tid) 
100
//   //       {
101
//   //         /**
102
//   //          * XXX
103
//   //          * Note: I believe that we could optimize this to
104
//   //          * avoid copying each TagData located after the target id
105
//   //          * and just link the already-copied list to the next tag.
106
//   //          */
107
//   //         continue;
108
//   //       }
109
//   //     struct TagData *copy = AllocData ();
110
//   //     copy->tid = cur->tid;
111
//   //     copy->count = 1;
112
//   //     copy->next = 0;
113
//   //     memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
114
//   //     *prevNext = copy;
115
//   //     prevNext = &copy->next;
116
//   //   }
117
//   // *prevNext = 0;
118
//   // RemoveAll ();
119
//   // m_next = start;
120
//   // return true;
121
// }
122
123
// void 
124
// PacketTagList::Add (const Tag &tag) const
125
// {
126
//   NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
127
//   // ensure this id was not yet added
128
129
//   // for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
130
//   //   {
131
//   //     NS_ASSERT (cur->tid != tag.GetInstanceTypeId ());
132
//   //   }
133
134
//   // struct TagData *head = AllocData ();
135
//   // head->count = 1;
136
//   // head->next = 0;
137
//   // head->tid = tag.GetInstanceTypeId ();
138
//   // head->next = m_next;
139
//   // NS_ASSERT (tag.GetSerializedSize () <= PACKET_TAG_MAX_SIZE);
140
//   // tag.Serialize (TagBuffer (head->data, head->data+tag.GetSerializedSize ()));
141
142
//   // const_cast<PacketTagList *> (this)->m_next = head;
143
144
//   // m_tags.
145
// }
146
147
// bool
148
// PacketTagList::Peek (Tag &tag) const
149
// {
150
//   NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
151
//   // TypeId tid = tag.GetInstanceTypeId ();
152
//   // for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
153
//   //   {
154
//   //     if (cur->tid == tid) 
155
//   //       {
156
//   //         /* found tag */
157
//   //         tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
158
//   //         return true;
159
//   //       }
160
//   //   }
161
  
162
//   /* no tag found */
163
//   return false;
164
// }
165
166
// // const struct PacketTagList::TagData *
167
// // PacketTagList::Head (void) const
168
// // {
169
// //   return m_next;
170
// // }
171
176
} // namespace ns3
172
} // namespace ns3
177
173
(-)a/src/network/model/packet-tag-list.h (-87 / +50 lines)
 Lines 21-27    Link Here 
21
#define PACKET_TAG_LIST_H
21
#define PACKET_TAG_LIST_H
22
22
23
#include <stdint.h>
23
#include <stdint.h>
24
#include <ostream>
24
#include <list>
25
#include "ns3/type-id.h"
25
#include "ns3/type-id.h"
26
26
27
namespace ns3 {
27
namespace ns3 {
 Lines 34-73   class Tag; Link Here 
34
 * The maximum size (in bytes) of a Tag is stored
34
 * The maximum size (in bytes) of a Tag is stored
35
 * in this constant.
35
 * in this constant.
36
 */
36
 */
37
#define PACKET_TAG_MAX_SIZE 20
37
// #define PACKET_TAG_MAX_SIZE 20
38
38
39
class PacketTagList 
39
class PacketTagList : public std::list<Ptr<const Tag> >
40
{
40
{
41
public:
41
public:
42
  struct TagData {
42
  // struct TagData {
43
    uint8_t data[PACKET_TAG_MAX_SIZE];
43
  //   std::vector<uint8_t> data;
44
    struct TagData *next;
44
  //   TypeId tid;
45
    TypeId tid;
45
  //   uint32_t count;
46
    uint32_t count;
46
  // };
47
  };
48
47
49
  inline PacketTagList ();
48
  // inline PacketTagList ();
50
  inline PacketTagList (PacketTagList const &o);
49
  // inline PacketTagList (PacketTagList const &o);
51
  inline PacketTagList &operator = (PacketTagList const &o);
50
  // inline PacketTagList &operator = (PacketTagList const &o);
52
  inline ~PacketTagList ();
51
  // inline ~PacketTagList ();
53
52
54
  void Add (Tag const&tag) const;
53
  void
55
  bool Remove (Tag &tag);
54
  Add (Ptr<const Tag> tag);
56
  bool Peek (Tag &tag) const;
57
  inline void RemoveAll (void);
58
55
59
  const struct PacketTagList::TagData *Head (void) const;
56
  Ptr<const Tag>
57
  Remove (TypeId tagType);
60
58
61
private:
59
  Ptr<const Tag>
62
60
  Peek (TypeId tagType) const;
63
  bool Remove (TypeId tid);
64
  struct PacketTagList::TagData *AllocData (void) const;
65
  void FreeData (struct TagData *data) const;
66
67
  static struct PacketTagList::TagData *g_free;
68
  static uint32_t g_nfree;
69
70
  struct TagData *m_next;
71
};
61
};
72
62
73
} // namespace ns3
63
} // namespace ns3
 Lines 78-142   private: Link Here 
78
68
79
namespace ns3 {
69
namespace ns3 {
80
70
81
PacketTagList::PacketTagList ()
71
// PacketTagList::PacketTagList ()
82
  : m_next ()
72
// {
83
{
73
// }
84
}
74
85
75
// PacketTagList::PacketTagList (PacketTagList const &o)
86
PacketTagList::PacketTagList (PacketTagList const &o)
76
//   : m_tags (o.m_tags)
87
  : m_next (o.m_next)
77
// {
88
{
78
// }
89
  if (m_next != 0)
79
90
    {
80
// PacketTagList &
91
      m_next->count++;
81
// PacketTagList::operator = (PacketTagList const &o)
92
    }
82
// {
93
}
83
//   // self assignment
94
84
//   if (&o == this)
95
PacketTagList &
85
//     {
96
PacketTagList::operator = (PacketTagList const &o)
86
//       return *this;
97
{
87
//     }
98
  // self assignment
88
//   // RemoveAll (); // ???
99
  if (m_next == o.m_next) 
89
//   m_tags = o.m_tags;
100
    {
90
//   return *this;
101
      return *this;
91
// }
102
    }
92
103
  RemoveAll ();
93
// PacketTagList::~PacketTagList ()
104
  m_next = o.m_next;
94
// {
105
  if (m_next != 0) 
95
//   RemoveAll ();
106
    {
96
// }
107
      m_next->count++;
97
108
    }
98
// void
109
  return *this;
99
// PacketTagList::RemoveAll (void)
110
}
100
// {
111
101
//   m_tags.clear ();
112
PacketTagList::~PacketTagList ()
102
// }
113
{
114
  RemoveAll ();
115
}
116
117
void
118
PacketTagList::RemoveAll (void)
119
{
120
  struct TagData *prev = 0;
121
  for (struct TagData *cur = m_next; cur != 0; cur = cur->next) 
122
    {
123
      cur->count--;
124
      if (cur->count > 0) 
125
        {
126
          break;
127
        }
128
      if (prev != 0) 
129
        {
130
          FreeData (prev);
131
        }
132
      prev = cur;
133
    }
134
  if (prev != 0) 
135
    {
136
      FreeData (prev);
137
    }
138
  m_next = 0;
139
}
140
103
141
} // namespace ns3
104
} // namespace ns3
142
105
(-)a/src/network/model/packet.cc (-66 / +96 lines)
 Lines 81-119   ByteTagIterator::ByteTagIterator (ByteTagList::Iterator i) Link Here 
81
}
81
}
82
82
83
83
84
PacketTagIterator::PacketTagIterator (const struct PacketTagList::TagData *head)
84
// PacketTagIterator::PacketTagIterator (const struct PacketTagList::TagData *head)
85
  : m_current (head)
85
//   : m_current (head)
86
{
86
// {
87
}
87
// }
88
bool
88
// bool
89
PacketTagIterator::HasNext (void) const
89
// PacketTagIterator::HasNext (void) const
90
{
90
// {
91
  return m_current != 0;
91
//   return m_current != 0;
92
}
92
// }
93
PacketTagIterator::Item
93
// PacketTagIterator::Item
94
PacketTagIterator::Next (void)
94
// PacketTagIterator::Next (void)
95
{
95
// {
96
  NS_ASSERT (HasNext ());
96
//   NS_ASSERT (HasNext ());
97
  const struct PacketTagList::TagData *prev = m_current;
97
//   const struct PacketTagList::TagData *prev = m_current;
98
  m_current = m_current->next;
98
//   m_current = m_current->next;
99
  return PacketTagIterator::Item (prev);
99
//   return PacketTagIterator::Item (prev);
100
}
100
// }
101
101
102
PacketTagIterator::Item::Item (const struct PacketTagList::TagData *data)
102
// PacketTagIterator::Item::Item (const struct PacketTagList::TagData *data)
103
  : m_data (data)
103
//   : m_data (data)
104
{
104
// {
105
}
105
// }
106
TypeId
106
// TypeId
107
PacketTagIterator::Item::GetTypeId (void) const
107
// PacketTagIterator::Item::GetTypeId (void) const
108
{
108
// {
109
  return m_data->tid;
109
//   return m_data->tid;
110
}
110
// }
111
void
111
// void
112
PacketTagIterator::Item::GetTag (Tag &tag) const
112
// PacketTagIterator::Item::GetTag (Tag &tag) const
113
{
113
// {
114
  NS_ASSERT (tag.GetInstanceTypeId () == m_data->tid);
114
//   NS_ASSERT (tag.GetInstanceTypeId () == m_data->tid);
115
  tag.Deserialize (TagBuffer ((uint8_t*)m_data->data, (uint8_t*)m_data->data+PACKET_TAG_MAX_SIZE));
115
//   tag.Deserialize (TagBuffer ((uint8_t*)m_data->data, (uint8_t*)m_data->data+PACKET_TAG_MAX_SIZE));
116
}
116
// }
117
117
118
118
119
Ptr<Packet> 
119
Ptr<Packet> 
 Lines 835-894   Packet::FindFirstMatchingByteTag (Tag &tag) const Link Here 
835
  return false;
835
  return false;
836
}
836
}
837
837
838
void 
838
// void 
839
Packet::AddPacketTag (const Tag &tag) const
839
// Packet::AddPacketTag (const Tag &tag) const
840
// {
841
//   NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
842
//   m_packetTagList.Add (tag);
843
// }
844
// bool 
845
// Packet::RemovePacketTag (Tag &tag)
846
// {
847
//   NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
848
//   bool found = m_packetTagList.Remove (tag);
849
//   return found;
850
// }
851
// bool 
852
// Packet::PeekPacketTag (Tag &tag) const
853
// {
854
//   bool found = m_packetTagList.Peek (tag);
855
//   return found;
856
// }
857
858
void
859
Packet::AddPacketTag (Ptr<const Tag> tag)
840
{
860
{
841
  NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
842
  m_packetTagList.Add (tag);
861
  m_packetTagList.Add (tag);
843
}
862
}
844
bool 
863
845
Packet::RemovePacketTag (Tag &tag)
864
Ptr<const Tag>
865
Packet::RemovePacketTag (TypeId tagType)
846
{
866
{
847
  NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
867
  return m_packetTagList.Remove (tagType);
848
  bool found = m_packetTagList.Remove (tag);
849
  return found;
850
}
868
}
851
bool 
869
852
Packet::PeekPacketTag (Tag &tag) const
870
Ptr<const Tag>
871
Packet::PeekPacketTag (TypeId tagType) const
853
{
872
{
854
  bool found = m_packetTagList.Peek (tag);
873
  return m_packetTagList.Peek (tagType);
855
  return found;
856
}
874
}
875
857
void 
876
void 
858
Packet::RemoveAllPacketTags (void)
877
Packet::RemoveAllPacketTags (void)
859
{
878
{
860
  NS_LOG_FUNCTION (this);
879
  NS_LOG_FUNCTION (this);
861
  m_packetTagList.RemoveAll ();
880
  m_packetTagList.clear ();
862
}
881
}
863
882
864
void 
883
void 
865
Packet::PrintPacketTags (std::ostream &os) const
884
Packet::PrintPacketTags (std::ostream &os) const
866
{
885
{
867
  PacketTagIterator i = GetPacketTagIterator ();
886
  for (PacketTagList::const_iterator tag = m_packetTagList.begin ();
868
  while (i.HasNext ())
887
       tag != m_packetTagList.end ();
888
       tag++)
869
    {
889
    {
870
      PacketTagIterator::Item item = i.Next ();
890
      if (tag != m_packetTagList.begin ())
871
      NS_ASSERT (item.GetTypeId ().HasConstructor ());
872
      Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
873
      NS_ASSERT (!constructor.IsNull ());
874
      ObjectBase *instance = constructor ();
875
      Tag *tag = dynamic_cast<Tag *> (instance);
876
      NS_ASSERT (tag != 0);
877
      item.GetTag (*tag);
878
      tag->Print (os);
879
      delete tag;
880
      if (i.HasNext ())
881
        {
891
        {
882
          os << " ";
892
          os << " ";
883
        }
893
        }
884
    }
885
}
886
894
887
PacketTagIterator 
895
      (*tag)->Print (os);
888
Packet::GetPacketTagIterator (void) const
896
    }
889
{
897
  // PacketTagIterator i = GetPacketTagIterator ();
890
  return PacketTagIterator (m_packetTagList.Head ());
898
  // while (i.HasNext ())
891
}
899
  //   {
900
  //     PacketTagIterator::Item item = i.Next ();
901
  //     NS_ASSERT (item.GetTypeId ().HasConstructor ());
902
  //     Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
903
  //     NS_ASSERT (!constructor.IsNull ());
904
  //     ObjectBase *instance = constructor ();
905
  //     Tag *tag = dynamic_cast<Tag *> (instance);
906
  //     NS_ASSERT (tag != 0);
907
  //     item.GetTag (*tag);
908
  //     tag->Print (os);
909
  //     delete tag;
910
  //     if (i.HasNext ())
911
  //       {
912
  //         os << " ";
913
  //       }
914
  //   }
915
}
916
917
// PacketTagIterator 
918
// Packet::GetPacketTagIterator (void) const
919
// {
920
//   return PacketTagIterator (m_packetTagList.Head ());
921
// }
892
922
893
std::ostream& operator<< (std::ostream& os, const Packet &packet)
923
std::ostream& operator<< (std::ostream& os, const Packet &packet)
894
{
924
{
(-)a/src/network/model/packet.h (-75 / +98 lines)
 Lines 104-155   private: Link Here 
104
  ByteTagList::Iterator m_current;
104
  ByteTagList::Iterator m_current;
105
};
105
};
106
106
107
/**
107
// /**
108
 * \ingroup packet
108
//  * \ingroup packet
109
 * \brief Iterator over the set of 'packet' tags in a packet
109
//  * \brief Iterator over the set of 'packet' tags in a packet
110
 *
110
//  *
111
 * This is a java-style iterator.
111
//  * This is a java-style iterator.
112
 */
112
//  */
113
class PacketTagIterator
113
// class PacketTagIterator
114
{
114
// {
115
public:
115
// public:
116
  /**
116
//   /**
117
   * Identifies a tag within a packet.
117
//    * Identifies a tag within a packet.
118
   */
118
//    */
119
  class Item 
119
//   class Item 
120
  {
120
//   {
121
public:
121
// public:
122
    /**
122
//     /**
123
     * \returns the ns3::TypeId associated to this tag.
123
//      * \returns the ns3::TypeId associated to this tag.
124
     */
124
//      */
125
    TypeId GetTypeId (void) const;
125
//     TypeId GetTypeId (void) const;
126
    /**
126
//     /**
127
     * \param tag the user tag to which the data should be copied.
127
//      * \param tag the user tag to which the data should be copied.
128
     *
128
//      *
129
     * Read the requested tag and store it in the user-provided
129
//      * Read the requested tag and store it in the user-provided
130
     * tag instance. This method will crash if the type of the
130
//      * tag instance. This method will crash if the type of the
131
     * tag provided by the user does not match the type of
131
//      * tag provided by the user does not match the type of
132
     * the underlying tag.
132
//      * the underlying tag.
133
     */
133
//      */
134
    void GetTag (Tag &tag) const;
134
//     void GetTag (Tag &tag) const;
135
private:
135
// private:
136
    friend class PacketTagIterator;
136
//     friend class PacketTagIterator;
137
    Item (const struct PacketTagList::TagData *data);
137
//     Item (const struct PacketTagList::TagData *data);
138
    const struct PacketTagList::TagData *m_data;
138
//     const struct PacketTagList::TagData *m_data;
139
  };
139
//   };
140
  /**
140
//   /**
141
   * \returns true if calling Next is safe, false otherwise.
141
//    * \returns true if calling Next is safe, false otherwise.
142
   */
142
//    */
143
  bool HasNext (void) const;
143
//   bool HasNext (void) const;
144
  /**
144
//   /**
145
   * \returns the next item found and prepare for the next one.
145
//    * \returns the next item found and prepare for the next one.
146
   */
146
//    */
147
  Item Next (void);
147
//   Item Next (void);
148
private:
148
// private:
149
  friend class Packet;
149
//   friend class Packet;
150
  PacketTagIterator (const struct PacketTagList::TagData *head);
150
//   PacketTagIterator (const struct PacketTagList::TagData *head);
151
  const struct PacketTagList::TagData *m_current;
151
//   const struct PacketTagList::TagData *m_current;
152
};
152
// };
153
153
154
/**
154
/**
155
 * \ingroup packet
155
 * \ingroup packet
 Lines 495-528   public: Link Here 
495
   */
495
   */
496
  void PrintByteTags (std::ostream &os) const;
496
  void PrintByteTags (std::ostream &os) const;
497
497
498
  /**
498
  void
499
   * \param tag the tag to store in this packet
499
  AddPacketTag (Ptr<const Tag> tag);
500
   *
500
501
   * Add a tag to this packet. This method calls the
501
  Ptr<const Tag>
502
   * Tag::GetSerializedSize and, then, Tag::Serialize.
502
  RemovePacketTag (TypeId tagType);
503
   *
503
504
   * Note that this method is const, that is, it does not
504
  template<class T>
505
   * modify the state of this packet, which is fairly
505
  Ptr<const T>
506
   * un-intuitive.
506
  RemovePacketTag ()
507
   */
507
  {
508
  void AddPacketTag (const Tag &tag) const;
508
    return DynamicCast<const T> (RemovePacketTag (T::GetTypeId ()));
509
  /**
509
  }
510
   * \param tag the tag to remove from this packet
510
  
511
   * \returns true if the requested tag is found, false
511
  Ptr<const Tag>
512
   *          otherwise.
512
  PeekPacketTag (TypeId tagType) const;
513
   *
513
514
   * Remove a tag from this packet. This method calls
514
  template<class T>
515
   * Tag::Deserialize if the tag is found.
515
  Ptr<const T>
516
   */
516
  PeekPacketTag () const
517
  bool RemovePacketTag (Tag &tag);
517
  {
518
  /**
518
    return DynamicCast<const T> (PeekPacketTag (T::GetTypeId ()));
519
   * \param tag the tag to search in this packet
519
  }
520
   * \returns true if the requested tag is found, false
520
  
521
   *          otherwise.
521
  // /**
522
   *
522
  //  * \param tag the tag to store in this packet
523
   * Search a matching tag and call Tag::Deserialize if it is found.
523
  //  *
524
   */
524
  //  * Add a tag to this packet. This method calls the
525
  bool PeekPacketTag (Tag &tag) const;
525
  //  * Tag::GetSerializedSize and, then, Tag::Serialize.
526
  //  *
527
  //  * Note that this method is const, that is, it does not
528
  //  * modify the state of this packet, which is fairly
529
  //  * un-intuitive.
530
  //  */
531
  // void AddPacketTag (const Tag &tag) const;
532
  // /**
533
  //  * \param tag the tag to remove from this packet
534
  //  * \returns true if the requested tag is found, false
535
  //  *          otherwise.
536
  //  *
537
  //  * Remove a tag from this packet. This method calls
538
  //  * Tag::Deserialize if the tag is found.
539
  //  */
540
  // bool RemovePacketTag (Tag &tag);
541
  // /**
542
  //  * \param tag the tag to search in this packet
543
  //  * \returns true if the requested tag is found, false
544
  //  *          otherwise.
545
  //  *
546
  //  * Search a matching tag and call Tag::Deserialize if it is found.
547
  //  */
548
  // bool PeekPacketTag (Tag &tag) const;
526
  /**
549
  /**
527
   * Remove all packet tags.
550
   * Remove all packet tags.
528
   */
551
   */
 Lines 542-548   public: Link Here 
542
   * \returns an object which can be used to iterate over the list of
565
   * \returns an object which can be used to iterate over the list of
543
   *  packet tags.
566
   *  packet tags.
544
   */
567
   */
545
  PacketTagIterator GetPacketTagIterator (void) const;
568
  // PacketTagIterator GetPacketTagIterator (void) const;
546
569
547
  /* Note: These functions support a temporary solution 
570
  /* Note: These functions support a temporary solution 
548
   * to a specific problem in this generic class, i.e. 
571
   * to a specific problem in this generic class, i.e. 
(-)a/src/network/model/tag.h (-2 / +9 lines)
 Lines 20-26    Link Here 
20
#ifndef TAG_H
20
#ifndef TAG_H
21
#define TAG_H
21
#define TAG_H
22
22
23
#include "ns3/object-base.h"
23
#include "ns3/object.h"
24
#include "tag-buffer.h"
24
#include "tag-buffer.h"
25
#include <stdint.h>
25
#include <stdint.h>
26
26
 Lines 33-39   namespace ns3 { Link Here 
33
 *
33
 *
34
 * New kinds of tags can be created by subclassing this base class.
34
 * New kinds of tags can be created by subclassing this base class.
35
 */
35
 */
36
class Tag : public ObjectBase
36
class Tag : public Object
37
{
37
{
38
public:
38
public:
39
  static TypeId GetTypeId (void);
39
  static TypeId GetTypeId (void);
 Lines 71-76   public: Link Here 
71
  virtual void Print (std::ostream &os) const = 0;
71
  virtual void Print (std::ostream &os) const = 0;
72
};
72
};
73
73
74
inline std::ostream &
75
operator << (std::ostream &os, const Tag &tag)
76
{
77
  tag.Print (os);
78
  return os;
79
}
80
74
} // namespace ns3
81
} // namespace ns3
75
82
76
#endif /* TAG_H */
83
#endif /* TAG_H */
(-)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