Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 UCLA |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef IPV4_L3_TRACER_H |
| 22 | #define IPV4_L3_TRACER_H |
| 23 | |
| 24 | #include "ns3/ptr.h" |
| 25 | #include "ns3/simple-ref-count.h" |
| 26 | #include "ns3/ipv4-l3-protocol.h" |
| 27 | |
| 28 | namespace ns3 { |
| 29 | |
| 30 | class Node; |
| 31 | |
| 32 | class Ipv4L3Tracer : public SimpleRefCount<Ipv4L3Tracer> |
| 33 | { |
| 34 | public: |
| 35 | Ipv4L3Tracer (Ptr<Node> node); |
| 36 | virtual ~Ipv4L3Tracer () { }; |
| 37 | |
| 38 | void |
| 39 | Connect (); |
| 40 | |
| 41 | virtual void |
| 42 | PrintHeader (std::ostream &os) const = 0; |
| 43 | |
| 44 | virtual void |
| 45 | Print (std::ostream &os) const = 0; |
| 46 | |
| 47 | virtual void |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 48 | Rx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t) = 0; |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 49 | |
| 50 | virtual void |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 51 | Tx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t) = 0; |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 52 | |
| 53 | virtual void |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 54 | Drop (const Ipv4Header &, Ptr<const Packet>, Ipv4L3Protocol::DropReason, Ptr<Ipv4>, uint32_t) = 0; |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 55 | |
| 56 | protected: |
| 57 | std::string m_node; |
| 58 | Ptr<Node> m_nodePtr; |
| 59 | |
| 60 | struct Stats |
| 61 | { |
| 62 | void Reset () |
| 63 | { |
| 64 | m_in = 0; |
| 65 | m_out = 0; |
| 66 | m_drop = 0; |
| 67 | } |
| 68 | |
| 69 | uint64_t m_in; |
| 70 | uint64_t m_out; |
| 71 | uint64_t m_drop; |
| 72 | }; |
| 73 | }; |
| 74 | |
| 75 | inline std::ostream& |
| 76 | operator << (std::ostream &os, const Ipv4L3Tracer &tracer) |
| 77 | { |
| 78 | os << "# "; |
| 79 | tracer.PrintHeader (os); |
| 80 | os << "\n"; |
| 81 | tracer.Print (os); |
| 82 | return os; |
| 83 | } |
| 84 | |
| 85 | } // namespace ns3 |
| 86 | |
| 87 | #endif // IPV4_L3_TRACER_H |