diff --git a/bindings/python/ns3_module_core.py b/bindings/python/ns3_module_core.py index 5f2250b16..92599fd5c 100644 --- a/bindings/python/ns3_module_core.py +++ b/bindings/python/ns3_module_core.py @@ -2025,6 +2025,10 @@ def register_functions(root_module): module.add_function('MakeStringChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) + ## type-id.h: extern ns3::Ptr ns3::MakeTypeIdChecker() [free function] + module.add_function('MakeTypeIdChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) ## ptr.h: extern ns3::Ptr ns3::Create() [free function] module.add_function('Create', 'ns3::Ptr< ns3::PointerValue >', @@ -2039,10 +2043,6 @@ def register_functions(root_module): module.add_function('LogComponentEnableAll', 'void', [param('ns3::LogLevel', 'level')]) - ## type-id.h: extern ns3::Ptr ns3::MakeTypeIdChecker() [free function] - module.add_function('MakeTypeIdChecker', - 'ns3::Ptr< ns3::AttributeChecker const >', - []) ## object-factory.h: extern ns3::Ptr ns3::MakeObjectFactoryChecker() [free function] module.add_function('MakeObjectFactoryChecker', 'ns3::Ptr< ns3::AttributeChecker const >', diff --git a/bindings/python/ns3_module_internet_stack.py b/bindings/python/ns3_module_internet_stack.py index 439307348..687d37841 100644 --- a/bindings/python/ns3_module_internet_stack.py +++ b/bindings/python/ns3_module_internet_stack.py @@ -3,6 +3,20 @@ from pybindgen import Module, FileCodeSink, param, retval, cppclass def register_types(module): root_module = module.get_root() + ## icmpv4.h: ns3::Icmpv4DestinationUnreachable [class] + module.add_class('Icmpv4DestinationUnreachable', parent=root_module['ns3::Header']) + ## icmpv4.h: ns3::Icmpv4DestinationUnreachable [enumeration] + module.add_enum('', ['NET_UNREACHABLE', 'HOST_UNREACHABLE', 'PROTOCOL_UNREACHABLE', 'PORT_UNREACHABLE', 'FRAG_NEEDED', 'SOURCE_ROUTE_FAILED'], outer_class=root_module['ns3::Icmpv4DestinationUnreachable']) + ## icmpv4.h: ns3::Icmpv4Echo [class] + module.add_class('Icmpv4Echo', parent=root_module['ns3::Header']) + ## icmpv4.h: ns3::Icmpv4Header [class] + module.add_class('Icmpv4Header', parent=root_module['ns3::Header']) + ## icmpv4.h: ns3::Icmpv4Header [enumeration] + module.add_enum('', ['ECHO_REPLY', 'DEST_UNREACH', 'ECHO', 'TIME_EXCEEDED'], outer_class=root_module['ns3::Icmpv4Header']) + ## icmpv4.h: ns3::Icmpv4TimeExceeded [class] + module.add_class('Icmpv4TimeExceeded', parent=root_module['ns3::Header']) + ## icmpv4.h: ns3::Icmpv4TimeExceeded [enumeration] + module.add_enum('', ['TIME_TO_LIVE', 'FRAGMENT_REASSEMBLY'], outer_class=root_module['ns3::Icmpv4TimeExceeded']) ## tcp-header.h: ns3::TcpHeader [class] module.add_class('TcpHeader', parent=root_module['ns3::Header']) ## tcp-header.h: ns3::TcpHeader::Flags_t [enumeration] @@ -57,6 +71,10 @@ def register_types_ns3_olsr(module): def register_methods(root_module): + register_Ns3Icmpv4DestinationUnreachable_methods(root_module, root_module['ns3::Icmpv4DestinationUnreachable']) + register_Ns3Icmpv4Echo_methods(root_module, root_module['ns3::Icmpv4Echo']) + register_Ns3Icmpv4Header_methods(root_module, root_module['ns3::Icmpv4Header']) + register_Ns3Icmpv4TimeExceeded_methods(root_module, root_module['ns3::Icmpv4TimeExceeded']) register_Ns3TcpHeader_methods(root_module, root_module['ns3::TcpHeader']) register_Ns3UdpHeader_methods(root_module, root_module['ns3::UdpHeader']) register_Ns3Ipv4Interface_methods(root_module, root_module['ns3::Ipv4Interface']) @@ -64,6 +82,248 @@ def register_methods(root_module): register_Ns3Ipv4StaticRouting_methods(root_module, root_module['ns3::Ipv4StaticRouting']) return +def register_Ns3Icmpv4DestinationUnreachable_methods(root_module, cls): + ## icmpv4.h: ns3::Icmpv4DestinationUnreachable::Icmpv4DestinationUnreachable(ns3::Icmpv4DestinationUnreachable const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Icmpv4DestinationUnreachable const &', 'arg0')]) + ## icmpv4.h: static ns3::TypeId ns3::Icmpv4DestinationUnreachable::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## icmpv4.h: ns3::Icmpv4DestinationUnreachable::Icmpv4DestinationUnreachable() [constructor] + cls.add_constructor([]) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::SetNextHopMtu(uint16_t mtu) [member function] + cls.add_method('SetNextHopMtu', + 'void', + [param('uint16_t', 'mtu')]) + ## icmpv4.h: uint16_t ns3::Icmpv4DestinationUnreachable::GetNextHopMtu() const [member function] + cls.add_method('GetNextHopMtu', + 'uint16_t', + [], + is_const=True) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::SetData(ns3::Ptr data) [member function] + cls.add_method('SetData', + 'void', + [param('ns3::Ptr< ns3::Packet const >', 'data')]) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::SetHeader(ns3::Ipv4Header header) [member function] + cls.add_method('SetHeader', + 'void', + [param('ns3::Ipv4Header', 'header')]) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::GetData(uint8_t * payload) const [member function] + cls.add_method('GetData', + 'void', + [param('uint8_t *', 'payload')], + is_const=True) + ## icmpv4.h: ns3::Ipv4Header ns3::Icmpv4DestinationUnreachable::GetHeader() const [member function] + cls.add_method('GetHeader', + 'ns3::Ipv4Header', + [], + is_const=True) + ## icmpv4.h: ns3::TypeId ns3::Icmpv4DestinationUnreachable::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, visibility='private', is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4DestinationUnreachable::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, visibility='private', is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, visibility='private', is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4DestinationUnreachable::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + visibility='private', is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4DestinationUnreachable::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, visibility='private', is_virtual=True) + return + +def register_Ns3Icmpv4Echo_methods(root_module, cls): + ## icmpv4.h: ns3::Icmpv4Echo::Icmpv4Echo(ns3::Icmpv4Echo const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Icmpv4Echo const &', 'arg0')]) + ## icmpv4.h: void ns3::Icmpv4Echo::SetIdentifier(uint16_t id) [member function] + cls.add_method('SetIdentifier', + 'void', + [param('uint16_t', 'id')]) + ## icmpv4.h: void ns3::Icmpv4Echo::SetSequenceNumber(uint16_t seq) [member function] + cls.add_method('SetSequenceNumber', + 'void', + [param('uint16_t', 'seq')]) + ## icmpv4.h: void ns3::Icmpv4Echo::SetData(ns3::Ptr data) [member function] + cls.add_method('SetData', + 'void', + [param('ns3::Ptr< ns3::Packet const >', 'data')]) + ## icmpv4.h: uint16_t ns3::Icmpv4Echo::GetIdentifier() const [member function] + cls.add_method('GetIdentifier', + 'uint16_t', + [], + is_const=True) + ## icmpv4.h: uint16_t ns3::Icmpv4Echo::GetSequenceNumber() const [member function] + cls.add_method('GetSequenceNumber', + 'uint16_t', + [], + is_const=True) + ## icmpv4.h: ns3::Ptr ns3::Icmpv4Echo::GetData() const [member function] + cls.add_method('GetData', + 'ns3::Ptr< ns3::Packet const >', + [], + is_const=True) + ## icmpv4.h: static ns3::TypeId ns3::Icmpv4Echo::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## icmpv4.h: ns3::Icmpv4Echo::Icmpv4Echo() [constructor] + cls.add_constructor([]) + ## icmpv4.h: ns3::TypeId ns3::Icmpv4Echo::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4Echo::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4Echo::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4Echo::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4Echo::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + return + +def register_Ns3Icmpv4Header_methods(root_module, cls): + ## icmpv4.h: ns3::Icmpv4Header::Icmpv4Header(ns3::Icmpv4Header const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Icmpv4Header const &', 'arg0')]) + ## icmpv4.h: void ns3::Icmpv4Header::EnableChecksum() [member function] + cls.add_method('EnableChecksum', + 'void', + []) + ## icmpv4.h: void ns3::Icmpv4Header::SetType(uint8_t type) [member function] + cls.add_method('SetType', + 'void', + [param('uint8_t', 'type')]) + ## icmpv4.h: void ns3::Icmpv4Header::SetCode(uint8_t code) [member function] + cls.add_method('SetCode', + 'void', + [param('uint8_t', 'code')]) + ## icmpv4.h: uint8_t ns3::Icmpv4Header::GetType() const [member function] + cls.add_method('GetType', + 'uint8_t', + [], + is_const=True) + ## icmpv4.h: uint8_t ns3::Icmpv4Header::GetCode() const [member function] + cls.add_method('GetCode', + 'uint8_t', + [], + is_const=True) + ## icmpv4.h: static ns3::TypeId ns3::Icmpv4Header::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## icmpv4.h: ns3::Icmpv4Header::Icmpv4Header() [constructor] + cls.add_constructor([]) + ## icmpv4.h: ns3::TypeId ns3::Icmpv4Header::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4Header::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4Header::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4Header::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4Header::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + return + +def register_Ns3Icmpv4TimeExceeded_methods(root_module, cls): + ## icmpv4.h: ns3::Icmpv4TimeExceeded::Icmpv4TimeExceeded(ns3::Icmpv4TimeExceeded const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Icmpv4TimeExceeded const &', 'arg0')]) + ## icmpv4.h: void ns3::Icmpv4TimeExceeded::SetData(ns3::Ptr data) [member function] + cls.add_method('SetData', + 'void', + [param('ns3::Ptr< ns3::Packet const >', 'data')]) + ## icmpv4.h: void ns3::Icmpv4TimeExceeded::SetHeader(ns3::Ipv4Header header) [member function] + cls.add_method('SetHeader', + 'void', + [param('ns3::Ipv4Header', 'header')]) + ## icmpv4.h: void ns3::Icmpv4TimeExceeded::GetData(uint8_t * payload) const [member function] + cls.add_method('GetData', + 'void', + [param('uint8_t *', 'payload')], + is_const=True) + ## icmpv4.h: ns3::Ipv4Header ns3::Icmpv4TimeExceeded::GetHeader() const [member function] + cls.add_method('GetHeader', + 'ns3::Ipv4Header', + [], + is_const=True) + ## icmpv4.h: static ns3::TypeId ns3::Icmpv4TimeExceeded::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## icmpv4.h: ns3::Icmpv4TimeExceeded::Icmpv4TimeExceeded() [constructor] + cls.add_constructor([]) + ## icmpv4.h: ns3::TypeId ns3::Icmpv4TimeExceeded::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4TimeExceeded::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4TimeExceeded::Serialize(ns3::Buffer::Iterator start) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::Buffer::Iterator', 'start')], + is_const=True, is_virtual=True) + ## icmpv4.h: uint32_t ns3::Icmpv4TimeExceeded::Deserialize(ns3::Buffer::Iterator start) [member function] + cls.add_method('Deserialize', + 'uint32_t', + [param('ns3::Buffer::Iterator', 'start')], + is_virtual=True) + ## icmpv4.h: void ns3::Icmpv4TimeExceeded::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + return + def register_Ns3TcpHeader_methods(root_module, cls): ## tcp-header.h: ns3::TcpHeader::TcpHeader(ns3::TcpHeader const & arg0) [copy constructor] cls.add_constructor([param('ns3::TcpHeader const &', 'arg0')]) @@ -354,6 +614,14 @@ def register_Ns3Ipv4L3Protocol_methods(root_module, cls): cls.add_method('SetNode', 'void', [param('ns3::Ptr< ns3::Node >', 'node')]) + ## ipv4-l3-protocol.h: ns3::Ptr ns3::Ipv4L3Protocol::CreateRawSocket() [member function] + cls.add_method('CreateRawSocket', + 'ns3::Ptr< ns3::Socket >', + []) + ## ipv4-l3-protocol.h: void ns3::Ipv4L3Protocol::DeleteRawSocket(ns3::Ptr socket) [member function] + cls.add_method('DeleteRawSocket', + 'void', + [param('ns3::Ptr< ns3::Socket >', 'socket')]) ## ipv4-l3-protocol.h: void ns3::Ipv4L3Protocol::Insert(ns3::Ptr protocol) [member function] cls.add_method('Insert', 'void', diff --git a/bindings/python/ns3_module_node.py b/bindings/python/ns3_module_node.py index 805e8747e..61c624b2d 100644 --- a/bindings/python/ns3_module_node.py +++ b/bindings/python/ns3_module_node.py @@ -67,6 +67,8 @@ def register_types(module): module.add_class('SocketFactory', parent=root_module['ns3::Object']) ## socket.h: ns3::SocketIpTtlTag [class] module.add_class('SocketIpTtlTag', parent=root_module['ns3::Tag']) + ## socket.h: ns3::SocketSetDontFragmentTag [class] + module.add_class('SocketSetDontFragmentTag', parent=root_module['ns3::Tag']) ## tcp-socket.h: ns3::TcpSocket [class] module.add_class('TcpSocket', parent=root_module['ns3::Socket']) ## tcp-socket-factory.h: ns3::TcpSocketFactory [class] @@ -91,6 +93,8 @@ def register_types(module): module.add_class('EthernetTrailer', parent=root_module['ns3::Trailer']) ## ipv4.h: ns3::Ipv4 [class] module.add_class('Ipv4', parent=root_module['ns3::Object']) + ## ipv4-raw-socket-factory.h: ns3::Ipv4RawSocketFactory [class] + module.add_class('Ipv4RawSocketFactory', parent=root_module['ns3::SocketFactory']) ## ipv4.h: ns3::Ipv4RoutingProtocol [class] module.add_class('Ipv4RoutingProtocol', parent=root_module['ns3::Object']) ## net-device.h: ns3::NetDevice [class] @@ -172,6 +176,7 @@ def register_methods(root_module): register_Ns3SocketAddressTag_methods(root_module, root_module['ns3::SocketAddressTag']) register_Ns3SocketFactory_methods(root_module, root_module['ns3::SocketFactory']) register_Ns3SocketIpTtlTag_methods(root_module, root_module['ns3::SocketIpTtlTag']) + register_Ns3SocketSetDontFragmentTag_methods(root_module, root_module['ns3::SocketSetDontFragmentTag']) register_Ns3TcpSocket_methods(root_module, root_module['ns3::TcpSocket']) register_Ns3TcpSocketFactory_methods(root_module, root_module['ns3::TcpSocketFactory']) register_Ns3UdpSocket_methods(root_module, root_module['ns3::UdpSocket']) @@ -184,6 +189,7 @@ def register_methods(root_module): register_Ns3EthernetHeader_methods(root_module, root_module['ns3::EthernetHeader']) register_Ns3EthernetTrailer_methods(root_module, root_module['ns3::EthernetTrailer']) register_Ns3Ipv4_methods(root_module, root_module['ns3::Ipv4']) + register_Ns3Ipv4RawSocketFactory_methods(root_module, root_module['ns3::Ipv4RawSocketFactory']) register_Ns3Ipv4RoutingProtocol_methods(root_module, root_module['ns3::Ipv4RoutingProtocol']) register_Ns3NetDevice_methods(root_module, root_module['ns3::NetDevice']) register_Ns3Node_methods(root_module, root_module['ns3::Node']) @@ -1507,6 +1513,56 @@ def register_Ns3SocketIpTtlTag_methods(root_module, cls): is_const=True, is_virtual=True) return +def register_Ns3SocketSetDontFragmentTag_methods(root_module, cls): + ## socket.h: ns3::SocketSetDontFragmentTag::SocketSetDontFragmentTag(ns3::SocketSetDontFragmentTag const & arg0) [copy constructor] + cls.add_constructor([param('ns3::SocketSetDontFragmentTag const &', 'arg0')]) + ## socket.h: ns3::SocketSetDontFragmentTag::SocketSetDontFragmentTag() [constructor] + cls.add_constructor([]) + ## socket.h: void ns3::SocketSetDontFragmentTag::Enable() [member function] + cls.add_method('Enable', + 'void', + []) + ## socket.h: void ns3::SocketSetDontFragmentTag::Disable() [member function] + cls.add_method('Disable', + 'void', + []) + ## socket.h: bool ns3::SocketSetDontFragmentTag::IsEnabled() const [member function] + cls.add_method('IsEnabled', + 'bool', + [], + is_const=True) + ## socket.h: static ns3::TypeId ns3::SocketSetDontFragmentTag::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## socket.h: ns3::TypeId ns3::SocketSetDontFragmentTag::GetInstanceTypeId() const [member function] + cls.add_method('GetInstanceTypeId', + 'ns3::TypeId', + [], + is_const=True, is_virtual=True) + ## socket.h: uint32_t ns3::SocketSetDontFragmentTag::GetSerializedSize() const [member function] + cls.add_method('GetSerializedSize', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## socket.h: void ns3::SocketSetDontFragmentTag::Serialize(ns3::TagBuffer i) const [member function] + cls.add_method('Serialize', + 'void', + [param('ns3::TagBuffer', 'i')], + is_const=True, is_virtual=True) + ## socket.h: void ns3::SocketSetDontFragmentTag::Deserialize(ns3::TagBuffer i) [member function] + cls.add_method('Deserialize', + 'void', + [param('ns3::TagBuffer', 'i')], + is_virtual=True) + ## socket.h: void ns3::SocketSetDontFragmentTag::Print(std::ostream & os) const [member function] + cls.add_method('Print', + 'void', + [param('std::ostream &', 'os')], + is_const=True, is_virtual=True) + return + def register_Ns3TcpSocket_methods(root_module, cls): ## tcp-socket.h: ns3::TcpSocket::TcpSocket(ns3::TcpSocket const & arg0) [copy constructor] cls.add_constructor([param('ns3::TcpSocket const &', 'arg0')]) @@ -1661,6 +1717,16 @@ def register_Ns3UdpSocket_methods(root_module, cls): 'uint32_t', [], is_pure_virtual=True, is_const=True, visibility='private', is_virtual=True) + ## udp-socket.h: void ns3::UdpSocket::SetMtuDiscover(bool discover) [member function] + cls.add_method('SetMtuDiscover', + 'void', + [param('bool', 'discover')], + is_pure_virtual=True, visibility='private', is_virtual=True) + ## udp-socket.h: bool ns3::UdpSocket::GetMtuDiscover() const [member function] + cls.add_method('GetMtuDiscover', + 'bool', + [], + is_pure_virtual=True, is_const=True, visibility='private', is_virtual=True) return def register_Ns3UdpSocketFactory_methods(root_module, cls): @@ -2167,6 +2233,18 @@ def register_Ns3Ipv4_methods(root_module, cls): is_virtual=True) return +def register_Ns3Ipv4RawSocketFactory_methods(root_module, cls): + ## ipv4-raw-socket-factory.h: ns3::Ipv4RawSocketFactory::Ipv4RawSocketFactory(ns3::Ipv4RawSocketFactory const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Ipv4RawSocketFactory const &', 'arg0')]) + ## ipv4-raw-socket-factory.h: ns3::Ipv4RawSocketFactory::Ipv4RawSocketFactory() [constructor] + cls.add_constructor([]) + ## ipv4-raw-socket-factory.h: static ns3::TypeId ns3::Ipv4RawSocketFactory::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + return + def register_Ns3Ipv4RoutingProtocol_methods(root_module, cls): ## ipv4.h: ns3::Ipv4RoutingProtocol::IF_INDEX_ANY [variable] cls.add_static_attribute('IF_INDEX_ANY', 'uint32_t const', is_const=True) diff --git a/examples/csma-ping.cc b/examples/csma-ping.cc new file mode 100644 index 000000000..ffddd9c6f --- /dev/null +++ b/examples/csma-ping.cc @@ -0,0 +1,140 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +// Port of ns-2/tcl/ex/simple.tcl to ns-3 +// +// Network topology +// +// n0 n1 n2 n3 +// | | | | +// ===================== +// +// - CBR/UDP flows from n0 to n1, and from n3 to n0 +// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. +// (i.e., DataRate of 448,000 bps) +// - DropTail queues +// - Tracing of queues and packet receptions to file "csma-one-subnet.tr" + +#include +#include +#include +#include + +#include "ns3/core-module.h" +#include "ns3/simulator-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/global-route-manager.h" + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("CsmaPingExample"); + +static void SinkRx (Ptr p, const Address &ad) +{ + //std::cout << *p << std::endl; +} + +static void PingRtt (std::string context, Time rtt) +{ + //std::cout << context << " " << rtt << std::endl; +} + +int +main (int argc, char *argv[]) +{ + // + // Make the random number generators generate reproducible results. + // + RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8); + + CommandLine cmd; + cmd.Parse (argc, argv); + + // Here, we will explicitly create four nodes. + NS_LOG_INFO ("Create nodes."); + NodeContainer c; + c.Create (4); + + // connect all our nodes to a shared channel. + NS_LOG_INFO ("Build Topology."); + CsmaHelper csma; + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); + csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); + NetDeviceContainer devs = csma.Install (c); + + // add an ip stack to all nodes. + NS_LOG_INFO ("Add ip stack."); + InternetStackHelper ipStack; + ipStack.Install (c); + + // assign ip addresses + NS_LOG_INFO ("Assign ip addresses."); + Ipv4AddressHelper ip; + ip.SetBase ("192.168.1.0", "255.255.255.0"); + Ipv4InterfaceContainer addresses = ip.Assign (devs); + + // setup global router + GlobalRouteManager::PopulateRoutingTables (); + NS_LOG_INFO ("Create Source"); + Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); + InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); + OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0))); + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); + onoff.SetAttribute ("DataRate", DataRateValue (DataRate (15000))); + onoff.SetAttribute ("PacketSize", UintegerValue (1200)); + + + ApplicationContainer apps = onoff.Install (c.Get (0)); + apps.Start (Seconds (1.0)); + apps.Stop (Seconds (10.0)); + + NS_LOG_INFO ("Create Sink."); + PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); + apps = sink.Install (c.Get (3)); + apps.Start (Seconds (0.0)); + apps.Stop (Seconds (11.0)); + + NS_LOG_INFO ("Create pinger"); + V4PingHelper ping = V4PingHelper (addresses.GetAddress (2)); + NodeContainer pingers; + pingers.Add (c.Get (0)); + pingers.Add (c.Get (1)); + pingers.Add (c.Get (3)); + apps = ping.Install (pingers); + apps.Start (Seconds (2.0)); + apps.Stop (Seconds (5.0)); + + NS_LOG_INFO ("Configure Tracing."); + // first, pcap tracing. + csma.EnablePcapAll ("csma-ping"); + // then, print what the packet sink receives. + Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", + MakeCallback (&SinkRx)); + // finally, print the ping rtts. + Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", + MakeCallback (&PingRtt)); + + Packet::EnablePrinting (); + + + NS_LOG_INFO ("Run Simulation."); + Simulator::Run (); + Simulator::Destroy (); + NS_LOG_INFO ("Done."); +} diff --git a/examples/csma-raw-ip-socket.cc b/examples/csma-raw-ip-socket.cc new file mode 100644 index 000000000..37f4dab51 --- /dev/null +++ b/examples/csma-raw-ip-socket.cc @@ -0,0 +1,122 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +// Port of ns-2/tcl/ex/simple.tcl to ns-3 +// +// Network topology +// +// n0 n1 n2 n3 +// | | | | +// ===================== +// +// - CBR/UDP flows from n0 to n1, and from n3 to n0 +// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. +// (i.e., DataRate of 448,000 bps) +// - DropTail queues +// - Tracing of queues and packet receptions to file "csma-one-subnet.tr" + +#include +#include +#include +#include + +#include "ns3/core-module.h" +#include "ns3/simulator-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("CsmaPacketSocketExample"); + +static void SinkRx (Ptr p, const Address &ad) +{ + //std::cout << *p << std::endl; +} + +int +main (int argc, char *argv[]) +{ +#if 0 + LogComponentEnable ("CsmaPacketSocketExample", LOG_LEVEL_INFO); +#endif + + // + // Make the random number generators generate reproducible results. + // + RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8); + + CommandLine cmd; + cmd.Parse (argc, argv); + + // Here, we will explicitly create four nodes. + NS_LOG_INFO ("Create nodes."); + NodeContainer c; + c.Create (4); + + // connect all our nodes to a shared channel. + NS_LOG_INFO ("Build Topology."); + CsmaHelper csma; + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); + csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); + NetDeviceContainer devs = csma.Install (c); + + // add an ip stack to all nodes. + NS_LOG_INFO ("Add ip stack."); + InternetStackHelper ipStack; + ipStack.Install (c); + + // assign ip addresses + NS_LOG_INFO ("Assign ip addresses."); + Ipv4AddressHelper ip; + ip.SetBase ("192.168.1.0", "255.255.255.0"); + Ipv4InterfaceContainer addresses = ip.Assign (devs); + + NS_LOG_INFO ("Create Source"); + Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); + InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); + OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0))); + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0))); + onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000))); + onoff.SetAttribute ("PacketSize", UintegerValue (1200)); + + ApplicationContainer apps = onoff.Install (c.Get (0)); + apps.Start (Seconds (1.0)); + apps.Stop (Seconds (10.0)); + + NS_LOG_INFO ("Create Sink."); + PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); + apps = sink.Install (c.Get (3)); + apps.Start (Seconds (0.0)); + apps.Stop (Seconds (11.0)); + + NS_LOG_INFO ("Configure Tracing."); + // first, pcap tracing. + csma.EnablePcapAll ("csma-raw-ip-socket"); + // then, print what the packet sink receives. + Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", + MakeCallback (&SinkRx)); + + Packet::EnablePrinting (); + + + NS_LOG_INFO ("Run Simulation."); + Simulator::Run (); + Simulator::Destroy (); + NS_LOG_INFO ("Done."); +} diff --git a/examples/wscript b/examples/wscript index e68afba06..4cae9dfc4 100644 --- a/examples/wscript +++ b/examples/wscript @@ -94,3 +94,11 @@ def build(bld): ['core', 'simulator', 'mobility', 'wifi', 'csma', 'helper', 'bridge']) obj.source = 'wifi-wired-bridging.cc' + + obj = bld.create_ns3_program('csma-raw-ip-socket', + ['csma', 'internet-stack']) + obj.source = 'csma-raw-ip-socket.cc' + + obj = bld.create_ns3_program('csma-ping', + ['csma', 'internet-stack', 'v4ping']) + obj.source = 'csma-ping.cc' diff --git a/regression/tests/test-csma-ping.py b/regression/tests/test-csma-ping.py new file mode 100644 index 000000000..b1fe044b1 --- /dev/null +++ b/regression/tests/test-csma-ping.py @@ -0,0 +1,12 @@ +#! /usr/bin/env python + +"""Generic trace-comparison-type regression test.""" + +import os +import shutil +import tracediff + +def run(verbose, generate, refDirName): + """Execute a test.""" + + return tracediff.run_test(verbose, generate, refDirName, "csma-ping") diff --git a/regression/tests/test-csma-raw-ip-socket.py b/regression/tests/test-csma-raw-ip-socket.py new file mode 100644 index 000000000..e6e916be6 --- /dev/null +++ b/regression/tests/test-csma-raw-ip-socket.py @@ -0,0 +1,12 @@ +#! /usr/bin/env python + +"""Generic trace-comparison-type regression test.""" + +import os +import shutil +import tracediff + +def run(verbose, generate, refDirName): + """Execute a test.""" + + return tracediff.run_test(verbose, generate, refDirName, "csma-raw-ip-socket") diff --git a/src/applications/onoff/onoff-application.cc b/src/applications/onoff/onoff-application.cc index 11f2f4a4b..664d43e82 100644 --- a/src/applications/onoff/onoff-application.cc +++ b/src/applications/onoff/onoff-application.cc @@ -147,7 +147,14 @@ void OnOffApplication::StopApplication() // Called at time specified by Stop NS_LOG_FUNCTION_NOARGS (); CancelEvents (); - m_socket->Close (); + if(m_socket != 0) + { + m_socket->Close (); + } + else + { + NS_LOG_WARN("OnOffApplication found null socket to close in StopApplication"); + } } void OnOffApplication::CancelEvents () diff --git a/src/applications/v4ping/v4ping.cc b/src/applications/v4ping/v4ping.cc new file mode 100644 index 000000000..e70917e60 --- /dev/null +++ b/src/applications/v4ping/v4ping.cc @@ -0,0 +1,155 @@ +#include "v4ping.h" +#include "ns3/icmpv4.h" +#include "ns3/assert.h" +#include "ns3/log.h" +#include "ns3/ipv4-address.h" +#include "ns3/socket.h" +#include "ns3/uinteger.h" +#include "ns3/inet-socket-address.h" +#include "ns3/packet.h" +#include "ns3/trace-source-accessor.h" +#include "ns3/simulator.h" + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("V4Ping"); +NS_OBJECT_ENSURE_REGISTERED (V4Ping); + +TypeId +V4Ping::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::V4Ping") + .SetParent () + .AddConstructor () + .AddAttribute ("Remote", + "The address of the machine we want to ping.", + Ipv4AddressValue (), + MakeIpv4AddressAccessor (&V4Ping::m_remote), + MakeIpv4AddressChecker ()) + .AddTraceSource ("Rtt", + "The rtt calculated by the ping.", + MakeTraceSourceAccessor (&V4Ping::m_traceRtt)); + ; + return tid; +} + +V4Ping::V4Ping () + : m_socket (0), + m_seq (0) +{} +V4Ping::~V4Ping () +{} + +void +V4Ping::DoDispose (void) +{ + NS_LOG_FUNCTION (this); + m_socket = 0; + Application::DoDispose (); +} + +uint32_t +V4Ping::GetApplicationId (void) const +{ + Ptr node = GetNode (); + for (uint32_t i = 0; i < node->GetNApplications (); ++i) + { + if (node->GetApplication (i) == this) + { + return i; + } + } + NS_ASSERT_MSG (false, "forgot to add application to node"); + return 0; // quiet compiler +} + +void +V4Ping::Receive (Ptr socket) +{ + NS_LOG_FUNCTION (this << socket); + while (m_socket->GetRxAvailable () > 0) + { + Address from; + Ptr p = m_socket->RecvFrom (0xffffffff, 0, from); + NS_LOG_DEBUG ("recv " << p->GetSize () << " bytes"); + NS_ASSERT (InetSocketAddress::IsMatchingType (from)); + InetSocketAddress realFrom = InetSocketAddress::ConvertFrom (from); + NS_ASSERT (realFrom.GetPort () == 1); // protocol should be icmp. + Ipv4Header ipv4; + p->RemoveHeader (ipv4); + NS_ASSERT (ipv4.GetProtocol () == 1); // protocol should be icmp. + Icmpv4Header icmp; + p->RemoveHeader (icmp); + if (icmp.GetType () == Icmpv4Header::ECHO_REPLY) + { + Icmpv4Echo echo; + p->RemoveHeader (echo); + if (echo.GetSequenceNumber () == (m_seq - 1) && + echo.GetIdentifier () == 0) + { + Ptr data = echo.GetData (); + if (data->GetSize () == 16) + { + uint32_t *buf = (uint32_t *)data->PeekData (); + if (buf[0] == GetNode ()->GetId () && + buf[1] == GetApplicationId ()) + { + int64_t ts = buf[3]; + ts <<= 32; + ts |= buf[2]; + Time sendTime = TimeStep (ts); + NS_ASSERT (Simulator::Now () > sendTime); + Time delta = Simulator::Now () - sendTime; + m_traceRtt (delta); + } + } + } + } + } +} + +void +V4Ping::StartApplication (void) +{ + NS_LOG_FUNCTION (this); + m_socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory")); + NS_ASSERT (m_socket != 0); + m_socket->SetAttribute ("Protocol", UintegerValue (1)); // icmp + m_socket->SetRecvCallback (MakeCallback (&V4Ping::Receive, this)); + InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0); + int status; + status = m_socket->Bind (src); + NS_ASSERT (status != -1); + InetSocketAddress dst = InetSocketAddress (m_remote, 0); + status = m_socket->Connect (dst); + NS_ASSERT (status != -1); + Ptr p = Create (); + Icmpv4Echo echo; + echo.SetSequenceNumber (m_seq); + m_seq++; + echo.SetIdentifier (0); + uint32_t data[4]; + data[0] = GetNode ()->GetId (); + data[1] = GetApplicationId (); + int64_t now = Simulator::Now ().GetTimeStep (); + data[2] = now & 0xffffffff; + now >>= 32; + data[3] = now & 0xffffffff; + Ptr dataPacket = Create ((uint8_t *) &data, 16); + echo.SetData (dataPacket); + p->AddHeader (echo); + Icmpv4Header header; + header.SetType (Icmpv4Header::ECHO); + header.SetCode (0); + p->AddHeader (header); + m_socket->Send (p, 0); + +} +void +V4Ping::StopApplication (void) +{ + NS_LOG_FUNCTION (this); +} + + +} // namespace ns3 diff --git a/src/applications/v4ping/v4ping.h b/src/applications/v4ping/v4ping.h new file mode 100644 index 000000000..800ab1fbb --- /dev/null +++ b/src/applications/v4ping/v4ping.h @@ -0,0 +1,36 @@ +#ifndef V4PING_H +#define V4PING_H + +#include "ns3/application.h" +#include "ns3/traced-callback.h" +#include "ns3/nstime.h" + +namespace ns3 { + +class Socket; + +class V4Ping : public Application +{ +public: + static TypeId GetTypeId (void); + + V4Ping (); + virtual ~V4Ping (); + +private: + // inherited from Application base class. + virtual void StartApplication (void); + virtual void StopApplication (void); + virtual void DoDispose (void); + uint32_t GetApplicationId (void) const; + void Receive (Ptr socket); + + Ipv4Address m_remote; + Ptr m_socket; + uint16_t m_seq; + TracedCallback