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

(-)a/src/internet/helper/internet-stack-helper.cc (-1 / +190 lines)
 Lines 623-628    Link Here 
623
}
623
}
624
624
625
static void
625
static void
626
Ipv4L3ProtocolTxSinkWithoutContext (
627
  Ptr<OutputStreamWrapper> stream,
628
  Ptr<const Packet> packet,
629
  Ptr<Ipv4> ipv4, 
630
  uint32_t interface)
631
{
632
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
633
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
634
    {
635
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
636
      return;
637
    }
638
639
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
640
}
641
642
static void
643
Ipv4L3ProtocolRxSinkWithoutContext (
644
  Ptr<OutputStreamWrapper> stream,
645
  Ptr<const Packet> packet,
646
  Ptr<Ipv4> ipv4, 
647
  uint32_t interface)
648
{
649
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
650
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
651
    {
652
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
653
      return;
654
    }
655
656
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
657
}
658
659
static void
626
Ipv4L3ProtocolDropSinkWithContext (
660
Ipv4L3ProtocolDropSinkWithContext (
627
  Ptr<OutputStreamWrapper> stream,
661
  Ptr<OutputStreamWrapper> stream,
628
  std::string context,
662
  std::string context,
 Lines 655-660    Link Here 
655
#endif
689
#endif
656
}
690
}
657
691
692
static void
693
Ipv4L3ProtocolTxSinkWithContext (
694
  Ptr<OutputStreamWrapper> stream,
695
  std::string context,
696
  Ptr<const Packet> packet,
697
  Ptr<Ipv4> ipv4, 
698
  uint32_t interface)
699
{
700
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
701
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
702
    {
703
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
704
      return;
705
    }
706
707
#ifdef INTERFACE_CONTEXT
708
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
709
                        << *packet << std::endl;
710
#else
711
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " "  << *packet << std::endl;
712
#endif
713
}
714
715
static void
716
Ipv4L3ProtocolRxSinkWithContext (
717
  Ptr<OutputStreamWrapper> stream,
718
  std::string context,
719
  Ptr<const Packet> packet,
720
  Ptr<Ipv4> ipv4, 
721
  uint32_t interface)
722
{
723
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
724
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
725
    {
726
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
727
      return;
728
    }
729
730
#ifdef INTERFACE_CONTEXT
731
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
732
                        << *packet << std::endl;
733
#else
734
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " "  << *packet << std::endl;
735
#endif
736
}
737
658
bool
738
bool
659
InternetStackHelper::AsciiHooked (Ptr<Ipv4> ipv4)
739
InternetStackHelper::AsciiHooked (Ptr<Ipv4> ipv4)
660
{
740
{
 Lines 744-751    Link Here 
744
          Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
824
          Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
745
          bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", 
825
          bool __attribute__ ((unused)) result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", 
746
                                                                                             MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream));
826
                                                                                             MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream));
747
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EanableAsciiIpv4Internal():  "
827
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
748
                         "Unable to connect ipv4L3Protocol \"Drop\"");
828
                         "Unable to connect ipv4L3Protocol \"Drop\"");
829
          result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", 
830
                                                               MakeBoundCallback (&Ipv4L3ProtocolTxSinkWithoutContext, theStream));
831
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
832
                         "Unable to connect ipv4L3Protocol \"Tx\"");
833
          result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", 
834
                                                               MakeBoundCallback (&Ipv4L3ProtocolRxSinkWithoutContext, theStream));
835
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
836
                         "Unable to connect ipv4L3Protocol \"Rx\"");
749
        }
837
        }
750
838
751
      g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
839
      g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
 Lines 785-790    Link Here 
785
      oss.str ("");
873
      oss.str ("");
786
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
874
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
787
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithContext, stream));
875
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithContext, stream));
876
      oss.str ("");
877
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
878
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolTxSinkWithContext, stream));
879
      oss.str ("");
880
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
881
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolRxSinkWithContext, stream));
788
    }
882
    }
789
883
790
  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
884
  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
 Lines 818-823    Link Here 
818
}
912
}
819
913
820
static void
914
static void
915
Ipv6L3ProtocolTxSinkWithoutContext (
916
  Ptr<OutputStreamWrapper> stream,
917
  Ptr<const Packet> packet,
918
  Ptr<Ipv6> ipv6, 
919
  uint32_t interface)
920
{
921
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
922
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
923
    {
924
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
925
      return;
926
    }
927
928
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
929
}
930
931
static void
932
Ipv6L3ProtocolRxSinkWithoutContext (
933
  Ptr<OutputStreamWrapper> stream,
934
  Ptr<const Packet> packet,
935
  Ptr<Ipv6> ipv6, 
936
  uint32_t interface)
937
{
938
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
939
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
940
    {
941
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
942
      return;
943
    }
944
945
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
946
}
947
948
static void
821
Ipv6L3ProtocolDropSinkWithContext (
949
Ipv6L3ProtocolDropSinkWithContext (
822
  Ptr<OutputStreamWrapper> stream,
950
  Ptr<OutputStreamWrapper> stream,
823
  std::string context,
951
  std::string context,
 Lines 850-855    Link Here 
850
#endif
978
#endif
851
}
979
}
852
980
981
static void
982
Ipv6L3ProtocolTxSinkWithContext (
983
  Ptr<OutputStreamWrapper> stream,
984
  std::string context,
985
  Ptr<const Packet> packet,
986
  Ptr<Ipv6> ipv6, 
987
  uint32_t interface)
988
{
989
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
990
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
991
    {
992
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
993
      return;
994
    }
995
996
#ifdef INTERFACE_CONTEXT
997
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
998
                        << *packet << std::endl;
999
#else
1000
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1001
#endif
1002
}
1003
1004
static void
1005
Ipv6L3ProtocolRxSinkWithContext (
1006
  Ptr<OutputStreamWrapper> stream,
1007
  std::string context,
1008
  Ptr<const Packet> packet,
1009
  Ptr<Ipv6> ipv6, 
1010
  uint32_t interface)
1011
{
1012
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1013
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1014
    {
1015
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1016
      return;
1017
    }
1018
1019
#ifdef INTERFACE_CONTEXT
1020
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
1021
                        << *packet << std::endl;
1022
#else
1023
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1024
#endif
1025
}
1026
853
bool
1027
bool
854
InternetStackHelper::AsciiHooked (Ptr<Ipv6> ipv6)
1028
InternetStackHelper::AsciiHooked (Ptr<Ipv6> ipv6)
855
{
1029
{
 Lines 933-938    Link Here 
933
                                                                                             MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream));
1107
                                                                                             MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream));
934
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
1108
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
935
                         "Unable to connect ipv6L3Protocol \"Drop\"");
1109
                         "Unable to connect ipv6L3Protocol \"Drop\"");
1110
          result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", 
1111
                                                               MakeBoundCallback (&Ipv6L3ProtocolTxSinkWithoutContext, theStream));
1112
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
1113
                         "Unable to connect ipv6L3Protocol \"Tx\"");
1114
          result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", 
1115
                                                               MakeBoundCallback (&Ipv6L3ProtocolRxSinkWithoutContext, theStream));
1116
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
1117
                         "Unable to connect ipv6L3Protocol \"Rx\"");
936
        }
1118
        }
937
1119
938
      g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
1120
      g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
 Lines 956-963    Link Here 
956
      Ptr<Node> node = ipv6->GetObject<Node> ();
1138
      Ptr<Node> node = ipv6->GetObject<Node> ();
957
      std::ostringstream oss;
1139
      std::ostringstream oss;
958
1140
1141
      oss.str ("");
959
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
1142
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
960
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithContext, stream));
1143
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithContext, stream));
1144
      oss.str ("");
1145
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
1146
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolTxSinkWithContext, stream));
1147
      oss.str ("");
1148
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
1149
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolRxSinkWithContext, stream));
961
    }
1150
    }
962
1151
963
  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
1152
  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
(-)a/src/internet/helper/internet-stack-helper.h (-6 / +6 lines)
 Lines 209-220    Link Here 
209
                                        bool explicitFilename);
209
                                        bool explicitFilename);
210
210
211
  /**
211
  /**
212
   * @brief Enable pcap output the indicated Ipv4 and interface pair.
212
   * @brief Enable pcap output the indicated Ipv6 and interface pair.
213
   * @internal
213
   * @internal
214
   *
214
   *
215
   * @param prefix Filename prefix to use for pcap files.
215
   * @param prefix Filename prefix to use for pcap files.
216
   * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
216
   * @param ipv6 Ptr to the Ipv6 interface on which you want to enable tracing.
217
   * @param interface Interface ID on the Ipv4 on which you want to enable tracing.
217
   * @param interface Interface ID on the Ipv6 on which you want to enable tracing.
218
   */
218
   */
219
  virtual void EnablePcapIpv6Internal (std::string prefix, 
219
  virtual void EnablePcapIpv6Internal (std::string prefix, 
220
                                       Ptr<Ipv6> ipv6, 
220
                                       Ptr<Ipv6> ipv6, 
 Lines 222-235    Link Here 
222
                                       bool explicitFilename);
222
                                       bool explicitFilename);
223
223
224
  /**
224
  /**
225
   * @brief Enable ascii trace output on the indicated Ipv4 and interface pair.
225
   * @brief Enable ascii trace output on the indicated Ipv6 and interface pair.
226
   * @internal
226
   * @internal
227
   *
227
   *
228
   * @param stream An OutputStreamWrapper representing an existing file to use
228
   * @param stream An OutputStreamWrapper representing an existing file to use
229
   *               when writing trace data.
229
   *               when writing trace data.
230
   * @param prefix Filename prefix to use for ascii trace files.
230
   * @param prefix Filename prefix to use for ascii trace files.
231
   * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
231
   * @param ipv6 Ptr to the Ipv6 interface on which you want to enable tracing.
232
   * @param interface Interface ID on the Ipv4 on which you want to enable tracing.
232
   * @param interface Interface ID on the Ipv6 on which you want to enable tracing.
233
   */
233
   */
234
  virtual void EnableAsciiIpv6Internal (Ptr<OutputStreamWrapper> stream, 
234
  virtual void EnableAsciiIpv6Internal (Ptr<OutputStreamWrapper> stream, 
235
                                        std::string prefix, 
235
                                        std::string prefix, 

Return to bug 1299