src/helper/pcap-helper.h
changeset 6027 8ed838dd0be5
parent 6017 050fa2b861df
equal deleted inserted replaced
6026:38a97b815052 6027:8ed838dd0be5
    20 #define PCAP_HELPER_H
    20 #define PCAP_HELPER_H
    21 
    21 
    22 #include "ns3/assert.h"
    22 #include "ns3/assert.h"
    23 #include "ns3/net-device-container.h"
    23 #include "ns3/net-device-container.h"
    24 #include "ns3/ipv4-interface-container.h"
    24 #include "ns3/ipv4-interface-container.h"
       
    25 #include "ns3/ipv6-interface-container.h"
    25 #include "ns3/node-container.h"
    26 #include "ns3/node-container.h"
    26 #include "ns3/simulator.h"
    27 #include "ns3/simulator.h"
    27 #include "ns3/pcap-file-object.h"
    28 #include "ns3/pcap-file-object.h"
    28 #include "ns3/ipv4.h"
    29 #include "ns3/ipv4.h"
       
    30 #include "ns3/ipv6.h"
    29 
    31 
    30 namespace ns3 {
    32 namespace ns3 {
    31 
    33 
    32 /**
    34 /**
    33  * \brief Manage pcap files for device models
    35  * \brief Manage pcap files for device models
    71 
    73 
    72   /**
    74   /**
    73    * @brief Let the pcap helper figure out a reasonable filename to use for the
    75    * @brief Let the pcap helper figure out a reasonable filename to use for the
    74    * pcap file associated with a node.
    76    * pcap file associated with a node.
    75    */
    77    */
    76   std::string GetFilenameFromInterfacePair (std::string prefix, Ptr<Ipv4> ipv4, 
    78   std::string GetFilenameFromInterfacePair (std::string prefix, Ptr<Object> object, 
    77                                             uint32_t interface, bool useObjectNames = true);
    79                                             uint32_t interface, bool useObjectNames = true);
    78 
    80 
    79   /**
    81   /**
    80    * @brief Create and initialize a pcap file.
    82    * @brief Create and initialize a pcap file.
    81    */
    83    */
   152    * \param promiscuous If true capture all possible packets available at the device.
   154    * \param promiscuous If true capture all possible packets available at the device.
   153    */
   155    */
   154   void EnablePcap (std::string prefix, NodeContainer n, bool promiscuous = false);
   156   void EnablePcap (std::string prefix, NodeContainer n, bool promiscuous = false);
   155 
   157 
   156   /**
   158   /**
       
   159    * @brief Enable pcap output on the device specified by a global node-id (of
       
   160    * a previously created node) and associated device-id.
       
   161    *
       
   162    * @param prefix Filename prefix to use for pcap files.
       
   163    * @param promiscuous If true capture all possible packets available at the device.
       
   164    */
       
   165   void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool promiscuous = false);
       
   166 
       
   167   /**
   157    * @brief Enable pcap output on each device (which is of the appropriate type)
   168    * @brief Enable pcap output on each device (which is of the appropriate type)
   158    * in the set of all nodes created in the simulation.
   169    * in the set of all nodes created in the simulation.
   159    *
   170    *
   160    * @param prefix Filename prefix to use for pcap files.
   171    * @param prefix Filename prefix to use for pcap files.
   161    * @param promiscuous If true capture all possible packets available at the device.
   172    * @param promiscuous If true capture all possible packets available at the device.
   162    */
   173    */
   163   void EnablePcapAll (std::string prefix, bool promiscuous = false);
   174   void EnablePcapAll (std::string prefix, bool promiscuous = false);
   164 
       
   165   /**
       
   166    * @brief Enable pcap output on the device specified by a global node-id (of
       
   167    * a previously created node) and associated device-id.
       
   168    *
       
   169    * @param prefix Filename prefix to use for pcap files.
       
   170    * @param promiscuous If true capture all possible packets available at the device.
       
   171    */
       
   172   void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool promiscuous = false);
       
   173 };
   175 };
   174 
   176 
   175 /**
   177 /**
   176  * \brief Base class providing common user-level pcap operations for helpers
   178  * \brief Base class providing common user-level pcap operations for helpers
   177  * representing IPv4 protocols .
   179  * representing IPv4 protocols .
   185    *
   187    *
   186    * @param prefix Filename prefix to use for pcap files.
   188    * @param prefix Filename prefix to use for pcap files.
   187    * @param ipv4 Ptr<Ipv4> on which you want to enable tracing.
   189    * @param ipv4 Ptr<Ipv4> on which you want to enable tracing.
   188    * @param interface Interface on ipv4 on which you want to enable tracing.
   190    * @param interface Interface on ipv4 on which you want to enable tracing.
   189    */
   191    */
   190   virtual void EnablePcapInternal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface) = 0;
   192   virtual void EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface) = 0;
   191 
   193 
   192   /**
   194   /**
   193    * @brief Enable pcap output the indicated Ipv4 and interface pair.
   195    * @brief Enable pcap output the indicated Ipv4 and interface pair.
   194    *
   196    *
   195    * @param prefix Filename prefix to use for pcap files.
   197    * @param prefix Filename prefix to use for pcap files.
   196    * @param ipv4 Ptr<Ipv4> on which you want to enable tracing.
   198    * @param ipv4 Ptr<Ipv4> on which you want to enable tracing.
   197    * @param interface Interface on ipv4 on which you want to enable tracing.
   199    * @param interface Interface on ipv4 on which you want to enable tracing.
   198    */
   200    */
   199   void EnablePcap (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
   201   void EnablePcapIpv4 (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
   200 
   202 
   201   /**
   203   /**
   202    * @brief Enable pcap output the indicated Ipv4 and interface pair using a
   204    * @brief Enable pcap output the indicated Ipv4 and interface pair using a
   203    * Ptr<Ipv4> previously named using the ns-3 object name service.
   205    * Ptr<Ipv4> previously named using the ns-3 object name service.
   204    *
   206    *
   205    * @param filename filename prefix to use for pcap files.
   207    * @param filename filename prefix to use for pcap files.
   206    * @param ipv4Name Name of the Ptr<Ipv4> on which you want to enable tracing.
   208    * @param ipv4Name Name of the Ptr<Ipv4> on which you want to enable tracing.
   207    * @param interface Interface on ipv4 on which you want to enable tracing.
   209    * @param interface Interface on ipv4 on which you want to enable tracing.
   208    */
   210    */
   209   void EnablePcap (std::string prefix, std::string ipv4Name, uint32_t interface);
   211   void EnablePcapIpv4 (std::string prefix, std::string ipv4Name, uint32_t interface);
   210 
   212 
   211   /**
   213   /**
   212    * @brief Enable pcap output on each Ipv4 and interface pair in the container.
   214    * @brief Enable pcap output on each Ipv4 and interface pair in the container.
   213    *
   215    *
   214    * @param prefix Filename prefix to use for pcap files.
   216    * @param prefix Filename prefix to use for pcap files.
   215    * @param c Ipv4InterfaceContainer of Ipv4 and interface pairs
   217    * @param c Ipv4InterfaceContainer of Ipv4 and interface pairs
   216    */
   218    */
   217   void EnablePcap (std::string prefix, Ipv4InterfaceContainer c);
   219   void EnablePcapIpv4 (std::string prefix, Ipv4InterfaceContainer c);
   218 
   220 
   219   /**
   221   /**
   220    * @brief Enable pcap output on all Ipv4 and interface pairs existing in the
   222    * @brief Enable pcap output on all Ipv4 and interface pairs existing in the
   221    * nodes provided in the container.
   223    * nodes provided in the container.
   222    *
   224    *
   223    * \param prefix Filename prefix to use for pcap files.
   225    * \param prefix Filename prefix to use for pcap files.
   224    * \param n container of nodes.
   226    * \param n container of nodes.
   225    */
   227    */
   226   void EnablePcap (std::string prefix, NodeContainer n);
   228   void EnablePcapIpv4 (std::string prefix, NodeContainer n);
   227 
       
   228   /**
       
   229    * @brief Enable pcap output on all Ipv4 and interface pairs existing in the 
       
   230    * set of all nodes created in the simulation.
       
   231    *
       
   232    * @param prefix Filename prefix to use for pcap files.
       
   233    */
       
   234   void EnablePcapAll (std::string prefix);
       
   235 
   229 
   236   /**
   230   /**
   237    * @brief Enable pcap output on the Ipv4 and interface pair specified by a 
   231    * @brief Enable pcap output on the Ipv4 and interface pair specified by a 
   238    * global node-id (of a previously created node) and interface.  Since there
   232    * global node-id (of a previously created node) and interface.  Since there
   239    * can be only one Ipv4 aggregated to a node, the node-id unambiguously 
   233    * can be only one Ipv4 aggregated to a node, the node-id unambiguously 
   240    * determines the Ipv4.
   234    * determines the Ipv4.
   241    *
   235    *
   242    * @param prefix Filename prefix to use for pcap files.
   236    * @param prefix Filename prefix to use for pcap files.
   243    */
   237    */
   244   void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t interface);
   238   void EnablePcapIpv4 (std::string prefix, uint32_t nodeid, uint32_t interface);
       
   239 
       
   240   /**
       
   241    * @brief Enable pcap output on all Ipv4 and interface pairs existing in the 
       
   242    * set of all nodes created in the simulation.
       
   243    *
       
   244    * @param prefix Filename prefix to use for pcap files.
       
   245    */
       
   246   void EnablePcapIpv4All (std::string prefix);
       
   247 
   245 };
   248 };
   246 
   249 
       
   250 /**
       
   251  * \brief Base class providing common user-level pcap operations for helpers
       
   252  * representing IPv6 protocols .
       
   253  */
       
   254 class PcapUserHelperForIpv6
       
   255 {
       
   256 public:
       
   257   /**
       
   258    * @brief Enable pcap output the indicated Ipv6 and interface pair.
       
   259    * @internal
       
   260    *
       
   261    * @param prefix Filename prefix to use for pcap files.
       
   262    * @param ipv6 Ptr<Ipv6> on which you want to enable tracing.
       
   263    * @param interface Interface on ipv6 on which you want to enable tracing.
       
   264    */
       
   265   virtual void EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface) = 0;
       
   266 
       
   267   /**
       
   268    * @brief Enable pcap output the indicated Ipv6 and interface pair.
       
   269    *
       
   270    * @param prefix Filename prefix to use for pcap files.
       
   271    * @param ipv6 Ptr<Ipv6> on which you want to enable tracing.
       
   272    * @param interface Interface on ipv6 on which you want to enable tracing.
       
   273    */
       
   274   void EnablePcapIpv6 (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface);
       
   275 
       
   276   /**
       
   277    * @brief Enable pcap output the indicated Ipv6 and interface pair using a
       
   278    * Ptr<Ipv6> previously named using the ns-3 object name service.
       
   279    *
       
   280    * @param filename filename prefix to use for pcap files.
       
   281    * @param ipv6Name Name of the Ptr<Ipv6> on which you want to enable tracing.
       
   282    * @param interface Interface on ipv6 on which you want to enable tracing.
       
   283    */
       
   284   void EnablePcapIpv6 (std::string prefix, std::string ipv6Name, uint32_t interface);
       
   285 
       
   286   /**
       
   287    * @brief Enable pcap output on each Ipv6 and interface pair in the container.
       
   288    *
       
   289    * @param prefix Filename prefix to use for pcap files.
       
   290    * @param c Ipv6InterfaceContainer of Ipv6 and interface pairs
       
   291    */
       
   292   void EnablePcapIpv6 (std::string prefix, Ipv6InterfaceContainer c);
       
   293 
       
   294   /**
       
   295    * @brief Enable pcap output on all Ipv6 and interface pairs existing in the
       
   296    * nodes provided in the container.
       
   297    *
       
   298    * \param prefix Filename prefix to use for pcap files.
       
   299    * \param n container of nodes.
       
   300    */
       
   301   void EnablePcapIpv6 (std::string prefix, NodeContainer n);
       
   302 
       
   303   /**
       
   304    * @brief Enable pcap output on the Ipv6 and interface pair specified by a 
       
   305    * global node-id (of a previously created node) and interface.  Since there
       
   306    * can be only one Ipv6 aggregated to a node, the node-id unambiguously 
       
   307    * determines the Ipv6.
       
   308    *
       
   309    * @param prefix Filename prefix to use for pcap files.
       
   310    */
       
   311   void EnablePcapIpv6 (std::string prefix, uint32_t nodeid, uint32_t interface);
       
   312 
       
   313   /**
       
   314    * @brief Enable pcap output on all Ipv6 and interface pairs existing in the 
       
   315    * set of all nodes created in the simulation.
       
   316    *
       
   317    * @param prefix Filename prefix to use for pcap files.
       
   318    */
       
   319   void EnablePcapIpv6All (std::string prefix);
       
   320 };
       
   321 
   247 } // namespace ns3
   322 } // namespace ns3
   248 
   323 
   249 #endif /* PCAP_HELPER_H */
   324 #endif /* PCAP_HELPER_H */