2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from nepi.execution.attribute import Attribute, Flags, Types
20 from nepi.execution.trace import Trace, TraceAttr
21 from nepi.execution.resource import ResourceManager, clsinit_copy, \
22 ResourceState, reschedule_delay
23 from nepi.resources.ns3.ns3ipv4l3protocol import NS3BaseIpv4L3Protocol
26 class NS3Ipv4L3Protocol(NS3BaseIpv4L3Protocol):
27 _rtype = "ns3::Ipv4L3Protocol"
30 def _register_attributes(cls):
32 attr_defaulttos = Attribute("DefaultTos",
33 "The TOS value set by default on all outgoing packets generated on this node.",
38 flags = Flags.Reserved | Flags.Construct)
40 cls._register_attribute(attr_defaulttos)
42 attr_defaultttl = Attribute("DefaultTtl",
43 "The TTL value set by default on all outgoing packets generated on this node.",
48 flags = Flags.Reserved | Flags.Construct)
50 cls._register_attribute(attr_defaultttl)
52 attr_fragmentexpirationtimeout = Attribute("FragmentExpirationTimeout",
53 "When this timeout expires, the fragments will be cleared from the buffer.",
55 default = "+30000000000.0ns",
58 flags = Flags.Reserved | Flags.Construct)
60 cls._register_attribute(attr_fragmentexpirationtimeout)
62 attr_ipforward = Attribute("IpForward",
63 "Globally enable or disable IP forwarding for all current and future Ipv4 devices.",
68 flags = Flags.Reserved | Flags.Construct)
70 cls._register_attribute(attr_ipforward)
72 attr_weakesmodel = Attribute("WeakEsModel",
73 "RFC1122 term for whether host accepts datagram with a dest. address on another interface",
78 flags = Flags.Reserved | Flags.Construct)
80 cls._register_attribute(attr_weakesmodel)
85 def _register_traces(cls):
87 tx = Trace("Tx", "Send ipv4 packet to outgoing interface.")
89 cls._register_trace(tx)
91 rx = Trace("Rx", "Receive ipv4 packet from incoming interface.")
93 cls._register_trace(rx)
95 drop = Trace("Drop", "Drop ipv4 packet")
97 cls._register_trace(drop)
99 sendoutgoing = Trace("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission")
101 cls._register_trace(sendoutgoing)
103 unicastforward = Trace("UnicastForward", "A unicast IPv4 packet was received by this node and is being forwarded to another node")
105 cls._register_trace(unicastforward)
107 localdeliver = Trace("LocalDeliver", "An IPv4 packet was received by/for this node, and it is being forward up the stack")
109 cls._register_trace(localdeliver)
113 def __init__(self, ec, guid):
114 super(NS3Ipv4L3Protocol, self).__init__(ec, guid)
115 self._home = "ns3-ipv4l3protocol-%s" % self.guid