From 3892ea96b6dd563a57b8d25ae9995d99f58e8244 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Fri, 5 Feb 2016 01:03:57 +0100 Subject: [PATCH] flow-monitor: (fixes #2287) FlowMonitor is confused by IP over IP --- RELEASE_NOTES | 1 + .../bindings/modulegen__gcc_ILP32.py | 72 +++++++++++++++++- .../bindings/modulegen__gcc_LP64.py | 72 +++++++++++++++++- src/flow-monitor/model/ipv4-flow-probe.cc | 74 ++++++++++++++++--- 4 files changed, 207 insertions(+), 12 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index d217f5cde..929a031f5 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -94,6 +94,7 @@ Bugs fixed - Bug 2273 - WeakEs model should be enforced in Static and Global routing - Bug 2279 - Ipv[4,6]L3Protocol::GetInterfaceForDevice speedup. - Bug 2286 - Support for SLL header (de)serialization. +- Bug 2287 - FlowMonitor is confused by IP over IP. Known issues ------------ diff --git a/src/flow-monitor/bindings/modulegen__gcc_ILP32.py b/src/flow-monitor/bindings/modulegen__gcc_ILP32.py index e908ce468..a8235a6bd 100644 --- a/src/flow-monitor/bindings/modulegen__gcc_ILP32.py +++ b/src/flow-monitor/bindings/modulegen__gcc_ILP32.py @@ -186,6 +186,8 @@ def register_types(module): module.add_enum('SocketErrno', ['ERROR_NOTERROR', 'ERROR_ISCONN', 'ERROR_NOTCONN', 'ERROR_MSGSIZE', 'ERROR_AGAIN', 'ERROR_SHUTDOWN', 'ERROR_OPNOTSUPP', 'ERROR_AFNOSUPPORT', 'ERROR_INVAL', 'ERROR_BADF', 'ERROR_NOROUTETOHOST', 'ERROR_NODEV', 'ERROR_ADDRNOTAVAIL', 'ERROR_ADDRINUSE', 'SOCKET_ERRNO_LAST'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') ## socket.h (module 'network'): ns3::Socket::SocketType [enumeration] module.add_enum('SocketType', ['NS3_SOCK_STREAM', 'NS3_SOCK_SEQPACKET', 'NS3_SOCK_DGRAM', 'NS3_SOCK_RAW'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') + ## socket.h (module 'network'): ns3::Socket::Ipv6MulticastFilterMode [enumeration] + module.add_enum('Ipv6MulticastFilterMode', ['INCLUDE', 'EXCLUDE'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') ## socket.h (module 'network'): ns3::SocketAddressTag [class] module.add_class('SocketAddressTag', import_from_module='ns.network', parent=root_module['ns3::Tag']) ## socket.h (module 'network'): ns3::SocketIpTosTag [class] @@ -316,6 +318,7 @@ def register_types(module): module.add_class('AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker']) ## address.h (module 'network'): ns3::AddressValue [class] module.add_class('AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue']) + module.add_container('std::vector< ns3::Ipv6Address >', 'ns3::Ipv6Address', container_type=u'vector') module.add_container('std::vector< unsigned int >', 'unsigned int', container_type=u'vector') module.add_container('std::vector< unsigned long long >', 'long long unsigned int', container_type=u'vector') module.add_container('std::map< unsigned int, ns3::FlowMonitor::FlowStats >', ('unsigned int', 'ns3::FlowMonitor::FlowStats'), container_type=u'map') @@ -1548,7 +1551,7 @@ def register_Ns3Ipv6Address_methods(root_module, cls): cls.add_method('IsAllHostsMulticast', 'bool', [], - is_const=True) + deprecated=True, is_const=True) ## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllNodesMulticast() const [member function] cls.add_method('IsAllNodesMulticast', 'bool', @@ -3350,6 +3353,21 @@ def register_Ns3Socket_methods(root_module, cls): 'ns3::TypeId', [], is_static=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6JoinGroup(ns3::Ipv6Address address, ns3::Socket::Ipv6MulticastFilterMode filterMode, std::vector > sourceAddresses) [member function] + cls.add_method('Ipv6JoinGroup', + 'void', + [param('ns3::Ipv6Address', 'address'), param('ns3::Socket::Ipv6MulticastFilterMode', 'filterMode'), param('std::vector< ns3::Ipv6Address >', 'sourceAddresses')], + is_virtual=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6JoinGroup(ns3::Ipv6Address address) [member function] + cls.add_method('Ipv6JoinGroup', + 'void', + [param('ns3::Ipv6Address', 'address')], + is_virtual=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6LeaveGroup() [member function] + cls.add_method('Ipv6LeaveGroup', + 'void', + [], + is_virtual=True) ## socket.h (module 'network'): bool ns3::Socket::IsIpRecvTos() const [member function] cls.add_method('IsIpRecvTos', 'bool', @@ -4867,6 +4885,11 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): 'ns3::Ptr< ns3::IpL4Protocol >', [param('int', 'protocolNumber')], is_const=True, is_virtual=True) + ## ipv4-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv4L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const [member function] + cls.add_method('GetProtocol', + 'ns3::Ptr< ns3::IpL4Protocol >', + [param('int', 'protocolNumber'), param('int32_t', 'interfaceIndex')], + is_const=True, is_virtual=True) ## ipv4-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv4L3Protocol::GetRoutingProtocol() const [member function] cls.add_method('GetRoutingProtocol', 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', @@ -4882,6 +4905,10 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')], is_virtual=True) + ## ipv4-l3-protocol.h (module 'internet'): void ns3::Ipv4L3Protocol::Insert(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Insert', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv4-l3-protocol.h (module 'internet'): bool ns3::Ipv4L3Protocol::IsDestinationAddress(ns3::Ipv4Address address, uint32_t iif) const [member function] cls.add_method('IsDestinationAddress', 'bool', @@ -4910,6 +4937,10 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): cls.add_method('Remove', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv4-l3-protocol.h (module 'internet'): void ns3::Ipv4L3Protocol::Remove(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Remove', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv4-l3-protocol.h (module 'internet'): bool ns3::Ipv4L3Protocol::RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) [member function] cls.add_method('RemoveAddress', 'bool', @@ -5460,15 +5491,28 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): cls.add_method('Insert', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Insert(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Insert', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Remove(ns3::Ptr protocol) [member function] cls.add_method('Remove', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Remove(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Remove', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetProtocol(int protocolNumber) const [member function] cls.add_method('GetProtocol', 'ns3::Ptr< ns3::IpL4Protocol >', [param('int', 'protocolNumber')], is_const=True, is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const [member function] + cls.add_method('GetProtocol', + 'ns3::Ptr< ns3::IpL4Protocol >', + [param('int', 'protocolNumber'), param('int32_t', 'interfaceIndex')], + is_const=True, is_virtual=True) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::CreateRawSocket() [member function] cls.add_method('CreateRawSocket', 'ns3::Ptr< ns3::Socket >', @@ -5641,6 +5685,32 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): 'void', [param('ns3::Ipv6Header', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv6L3Protocol::DropReason', 'dropReason')], is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::AddMulticastAddress(ns3::Ipv6Address address) [member function] + cls.add_method('AddMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::AddMulticastAddress(ns3::Ipv6Address address, uint32_t interface) [member function] + cls.add_method('AddMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::RemoveMulticastAddress(ns3::Ipv6Address address) [member function] + cls.add_method('RemoveMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::RemoveMulticastAddress(ns3::Ipv6Address address, uint32_t interface) [member function] + cls.add_method('RemoveMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')]) + ## ipv6-l3-protocol.h (module 'internet'): bool ns3::Ipv6L3Protocol::IsRegisteredMulticastAddress(ns3::Ipv6Address address) const [member function] + cls.add_method('IsRegisteredMulticastAddress', + 'bool', + [param('ns3::Ipv6Address', 'address')], + is_const=True) + ## ipv6-l3-protocol.h (module 'internet'): bool ns3::Ipv6L3Protocol::IsRegisteredMulticastAddress(ns3::Ipv6Address address, uint32_t interface) const [member function] + cls.add_method('IsRegisteredMulticastAddress', + 'bool', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')], + is_const=True) ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::DoDispose() [member function] cls.add_method('DoDispose', 'void', diff --git a/src/flow-monitor/bindings/modulegen__gcc_LP64.py b/src/flow-monitor/bindings/modulegen__gcc_LP64.py index f64a5fb46..e128f7595 100644 --- a/src/flow-monitor/bindings/modulegen__gcc_LP64.py +++ b/src/flow-monitor/bindings/modulegen__gcc_LP64.py @@ -186,6 +186,8 @@ def register_types(module): module.add_enum('SocketErrno', ['ERROR_NOTERROR', 'ERROR_ISCONN', 'ERROR_NOTCONN', 'ERROR_MSGSIZE', 'ERROR_AGAIN', 'ERROR_SHUTDOWN', 'ERROR_OPNOTSUPP', 'ERROR_AFNOSUPPORT', 'ERROR_INVAL', 'ERROR_BADF', 'ERROR_NOROUTETOHOST', 'ERROR_NODEV', 'ERROR_ADDRNOTAVAIL', 'ERROR_ADDRINUSE', 'SOCKET_ERRNO_LAST'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') ## socket.h (module 'network'): ns3::Socket::SocketType [enumeration] module.add_enum('SocketType', ['NS3_SOCK_STREAM', 'NS3_SOCK_SEQPACKET', 'NS3_SOCK_DGRAM', 'NS3_SOCK_RAW'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') + ## socket.h (module 'network'): ns3::Socket::Ipv6MulticastFilterMode [enumeration] + module.add_enum('Ipv6MulticastFilterMode', ['INCLUDE', 'EXCLUDE'], outer_class=root_module['ns3::Socket'], import_from_module='ns.network') ## socket.h (module 'network'): ns3::SocketAddressTag [class] module.add_class('SocketAddressTag', import_from_module='ns.network', parent=root_module['ns3::Tag']) ## socket.h (module 'network'): ns3::SocketIpTosTag [class] @@ -316,6 +318,7 @@ def register_types(module): module.add_class('AddressChecker', import_from_module='ns.network', parent=root_module['ns3::AttributeChecker']) ## address.h (module 'network'): ns3::AddressValue [class] module.add_class('AddressValue', import_from_module='ns.network', parent=root_module['ns3::AttributeValue']) + module.add_container('std::vector< ns3::Ipv6Address >', 'ns3::Ipv6Address', container_type=u'vector') module.add_container('std::vector< unsigned int >', 'unsigned int', container_type=u'vector') module.add_container('std::vector< unsigned long >', 'long unsigned int', container_type=u'vector') module.add_container('std::map< unsigned int, ns3::FlowMonitor::FlowStats >', ('unsigned int', 'ns3::FlowMonitor::FlowStats'), container_type=u'map') @@ -1548,7 +1551,7 @@ def register_Ns3Ipv6Address_methods(root_module, cls): cls.add_method('IsAllHostsMulticast', 'bool', [], - is_const=True) + deprecated=True, is_const=True) ## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllNodesMulticast() const [member function] cls.add_method('IsAllNodesMulticast', 'bool', @@ -3350,6 +3353,21 @@ def register_Ns3Socket_methods(root_module, cls): 'ns3::TypeId', [], is_static=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6JoinGroup(ns3::Ipv6Address address, ns3::Socket::Ipv6MulticastFilterMode filterMode, std::vector > sourceAddresses) [member function] + cls.add_method('Ipv6JoinGroup', + 'void', + [param('ns3::Ipv6Address', 'address'), param('ns3::Socket::Ipv6MulticastFilterMode', 'filterMode'), param('std::vector< ns3::Ipv6Address >', 'sourceAddresses')], + is_virtual=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6JoinGroup(ns3::Ipv6Address address) [member function] + cls.add_method('Ipv6JoinGroup', + 'void', + [param('ns3::Ipv6Address', 'address')], + is_virtual=True) + ## socket.h (module 'network'): void ns3::Socket::Ipv6LeaveGroup() [member function] + cls.add_method('Ipv6LeaveGroup', + 'void', + [], + is_virtual=True) ## socket.h (module 'network'): bool ns3::Socket::IsIpRecvTos() const [member function] cls.add_method('IsIpRecvTos', 'bool', @@ -4867,6 +4885,11 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): 'ns3::Ptr< ns3::IpL4Protocol >', [param('int', 'protocolNumber')], is_const=True, is_virtual=True) + ## ipv4-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv4L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const [member function] + cls.add_method('GetProtocol', + 'ns3::Ptr< ns3::IpL4Protocol >', + [param('int', 'protocolNumber'), param('int32_t', 'interfaceIndex')], + is_const=True, is_virtual=True) ## ipv4-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv4L3Protocol::GetRoutingProtocol() const [member function] cls.add_method('GetRoutingProtocol', 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', @@ -4882,6 +4905,10 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')], is_virtual=True) + ## ipv4-l3-protocol.h (module 'internet'): void ns3::Ipv4L3Protocol::Insert(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Insert', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv4-l3-protocol.h (module 'internet'): bool ns3::Ipv4L3Protocol::IsDestinationAddress(ns3::Ipv4Address address, uint32_t iif) const [member function] cls.add_method('IsDestinationAddress', 'bool', @@ -4910,6 +4937,10 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): cls.add_method('Remove', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv4-l3-protocol.h (module 'internet'): void ns3::Ipv4L3Protocol::Remove(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Remove', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv4-l3-protocol.h (module 'internet'): bool ns3::Ipv4L3Protocol::RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) [member function] cls.add_method('RemoveAddress', 'bool', @@ -5460,15 +5491,28 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): cls.add_method('Insert', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Insert(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Insert', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Remove(ns3::Ptr protocol) [member function] cls.add_method('Remove', 'void', [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::Remove(ns3::Ptr protocol, uint32_t interfaceIndex) [member function] + cls.add_method('Remove', + 'void', + [param('ns3::Ptr< ns3::IpL4Protocol >', 'protocol'), param('uint32_t', 'interfaceIndex')]) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetProtocol(int protocolNumber) const [member function] cls.add_method('GetProtocol', 'ns3::Ptr< ns3::IpL4Protocol >', [param('int', 'protocolNumber')], is_const=True, is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const [member function] + cls.add_method('GetProtocol', + 'ns3::Ptr< ns3::IpL4Protocol >', + [param('int', 'protocolNumber'), param('int32_t', 'interfaceIndex')], + is_const=True, is_virtual=True) ## ipv6-l3-protocol.h (module 'internet'): ns3::Ptr ns3::Ipv6L3Protocol::CreateRawSocket() [member function] cls.add_method('CreateRawSocket', 'ns3::Ptr< ns3::Socket >', @@ -5641,6 +5685,32 @@ def register_Ns3Ipv6L3Protocol_methods(root_module, cls): 'void', [param('ns3::Ipv6Header', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv6L3Protocol::DropReason', 'dropReason')], is_virtual=True) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::AddMulticastAddress(ns3::Ipv6Address address) [member function] + cls.add_method('AddMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::AddMulticastAddress(ns3::Ipv6Address address, uint32_t interface) [member function] + cls.add_method('AddMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::RemoveMulticastAddress(ns3::Ipv6Address address) [member function] + cls.add_method('RemoveMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address')]) + ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::RemoveMulticastAddress(ns3::Ipv6Address address, uint32_t interface) [member function] + cls.add_method('RemoveMulticastAddress', + 'void', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')]) + ## ipv6-l3-protocol.h (module 'internet'): bool ns3::Ipv6L3Protocol::IsRegisteredMulticastAddress(ns3::Ipv6Address address) const [member function] + cls.add_method('IsRegisteredMulticastAddress', + 'bool', + [param('ns3::Ipv6Address', 'address')], + is_const=True) + ## ipv6-l3-protocol.h (module 'internet'): bool ns3::Ipv6L3Protocol::IsRegisteredMulticastAddress(ns3::Ipv6Address address, uint32_t interface) const [member function] + cls.add_method('IsRegisteredMulticastAddress', + 'bool', + [param('ns3::Ipv6Address', 'address'), param('uint32_t', 'interface')], + is_const=True) ## ipv6-l3-protocol.h (module 'internet'): void ns3::Ipv6L3Protocol::DoDispose() [member function] cls.add_method('DoDispose', 'void', diff --git a/src/flow-monitor/model/ipv4-flow-probe.cc b/src/flow-monitor/model/ipv4-flow-probe.cc index e619b6a85..24c12b270 100644 --- a/src/flow-monitor/model/ipv4-flow-probe.cc +++ b/src/flow-monitor/model/ipv4-flow-probe.cc @@ -64,8 +64,10 @@ public: * \param flowId the flow identifier * \param packetId the packet identifier * \param packetSize the packet size + * \param src packet source address + * \param dst packet destination address */ - Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize); + Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize, Ipv4Address src, Ipv4Address dst); /** * \brief Set the flow identifier * \param flowId the flow identifier @@ -96,11 +98,21 @@ public: * \returns the packet size */ uint32_t GetPacketSize (void) const; + /** + * \brief Checks if the addresses stored in tag are matching + * the arguments. + * + * This check is important for IP over IP encapsulation. + * + * \returns True if the addresses are matching. + */ + bool IsSrcDstValid (Ipv4Address src, Ipv4Address dst) const; private: uint32_t m_flowId; //!< flow identifier uint32_t m_packetId; //!< packet identifier uint32_t m_packetSize; //!< packet size - + Ipv4Address m_src; //!< IP source + Ipv4Address m_dst; //!< IP destination }; TypeId @@ -121,7 +133,7 @@ Ipv4FlowProbeTag::GetInstanceTypeId (void) const uint32_t Ipv4FlowProbeTag::GetSerializedSize (void) const { - return 4 + 4 + 4; + return 4 + 4 + 4 + 8; } void Ipv4FlowProbeTag::Serialize (TagBuffer buf) const @@ -129,6 +141,12 @@ Ipv4FlowProbeTag::Serialize (TagBuffer buf) const buf.WriteU32 (m_flowId); buf.WriteU32 (m_packetId); buf.WriteU32 (m_packetSize); + + uint8_t tBuf[4]; + m_src.Serialize (tBuf); + buf.Write (tBuf, 4); + m_dst.Serialize (tBuf); + buf.Write (tBuf, 4); } void Ipv4FlowProbeTag::Deserialize (TagBuffer buf) @@ -136,21 +154,27 @@ Ipv4FlowProbeTag::Deserialize (TagBuffer buf) m_flowId = buf.ReadU32 (); m_packetId = buf.ReadU32 (); m_packetSize = buf.ReadU32 (); + + uint8_t tBuf[4]; + buf.Read (tBuf, 4); + m_src = Ipv4Address::Deserialize (tBuf); + buf.Read (tBuf, 4); + m_dst = Ipv4Address::Deserialize (tBuf); } void Ipv4FlowProbeTag::Print (std::ostream &os) const { os << "FlowId=" << m_flowId; - os << "PacketId=" << m_packetId; - os << "PacketSize=" << m_packetSize; + os << " PacketId=" << m_packetId; + os << " PacketSize=" << m_packetSize; } Ipv4FlowProbeTag::Ipv4FlowProbeTag () : Tag () { } -Ipv4FlowProbeTag::Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize) - : Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (packetSize) +Ipv4FlowProbeTag::Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize, Ipv4Address src, Ipv4Address dst) + : Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (packetSize), m_src (src), m_dst (dst) { } @@ -183,7 +207,12 @@ uint32_t Ipv4FlowProbeTag::GetPacketSize (void) const { return m_packetSize; -} +} +bool +Ipv4FlowProbeTag::IsSrcDstValid (Ipv4Address src, Ipv4Address dst) const +{ + return ((m_src == src) && (m_dst == dst)); +} //////////////////////////////////////// // Ipv4FlowProbe class implementation // @@ -264,6 +293,13 @@ Ipv4FlowProbe::SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr return; } + Ipv4FlowProbeTag fTag; + bool found = ipPayload->FindFirstMatchingByteTag (fTag); + if (found) + { + return; + } + if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId)) { uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ()); @@ -273,7 +309,7 @@ Ipv4FlowProbe::SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr // tag the packet with the flow id and packet id, so that the packet can be identified even // when Ipv4Header is not accessible at some non-IPv4 protocol layer - Ipv4FlowProbeTag fTag (flowId, packetId, size); + Ipv4FlowProbeTag fTag (flowId, packetId, size, ipHeader.GetSource (), ipHeader.GetDestination ()); ipPayload->AddByteTag (fTag); } } @@ -286,6 +322,17 @@ Ipv4FlowProbe::ForwardLogger (const Ipv4Header &ipHeader, Ptr ipPa if (found) { + if (!ipHeader.IsLastFragment () || ipHeader.GetFragmentOffset () != 0) + { + NS_LOG_WARN ("Not counting fragmented packets"); + return; + } + if (!fTag.IsSrcDstValid (ipHeader.GetSource (), ipHeader.GetDestination ())) + { + NS_LOG_LOGIC ("Not reporting encapsulated packet"); + return; + } + FlowId flowId = fTag.GetFlowId (); FlowPacketId packetId = fTag.GetPacketId (); @@ -303,11 +350,18 @@ Ipv4FlowProbe::ForwardUpLogger (const Ipv4Header &ipHeader, Ptr ip if (found) { + if (!fTag.IsSrcDstValid (ipHeader.GetSource (), ipHeader.GetDestination ())) + { + NS_LOG_LOGIC ("Not reporting encapsulated packet"); + return; + } + FlowId flowId = fTag.GetFlowId (); FlowPacketId packetId = fTag.GetPacketId (); uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ()); - NS_LOG_DEBUG ("ReportLastRx ("<ReportLastRx (this, flowId, packetId, size); } }