src/internet-node/pcap-trace.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 01 Oct 2007 14:15:56 +0200
changeset 1866 e7dbcc4df546
parent 524 082ffdd8fbd7
child 2536 08b25d309a04
permissions -rw-r--r--
do not use Packet objects directly. Use Ptr<Packet> instead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
456
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-	Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#ifndef PCAP_TRACE_H
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#define PCAP_TRACE_H
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include <string>
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <vector>
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    26
#include "ns3/ptr.h"
456
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
namespace ns3 {
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
class Packet;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
class TraceContext;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
class PcapWriter;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
class PcapTrace 
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
{
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
public:
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
  PcapTrace (std::string filename);
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
  ~PcapTrace ();
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
  void TraceAllIp (void);
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
private:
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  PcapWriter *GetStream (uint32_t nodeId, uint32_t interfaceId);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    43
  void LogIp (TraceContext const &context, Ptr<const Packet> p, uint32_t interfaceIndex);
456
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
  std::string m_filename;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
  struct Trace {
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
    uint32_t nodeId;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
    uint32_t interfaceId;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
    PcapWriter *writer;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  };
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  std::vector<Trace> m_traces;
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
};
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
}//namespace ns3
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
5361882cc2f3 put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
#endif /* PCAP_TRACE_H */