author | Craig Dowell <craigdo@ee.washington.edu> |
Thu, 28 Jan 2010 17:21:04 -0800 | |
changeset 6030 | 7b67e0413b57 |
parent 6028 | 96fb92f73f3d |
child 6036 | 5d89e247af46 |
permissions | -rw-r--r-- |
2833
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
2 |
/* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
4 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
7 |
* published by the Free Software Foundation; |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
8 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
12 |
* GNU General Public License for more details. |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
13 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
17 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
19 |
* Author: Faker Moatamri <faker.moatamri@sophia.inria.fr> |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
20 |
*/ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
21 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
22 |
/** |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
23 |
* \ingroup internetStack |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
24 |
* \defgroup internetStackModel Internet Stack Model |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
25 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
26 |
* \section internetStackTracingModel Tracing in the Internet Stack |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
27 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
28 |
* The internet stack provides a number of trace sources in its various |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
29 |
* protocol implementations. These trace sources can be hooked using your own |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
30 |
* custom trace code, or you can use our helper functions in some cases to |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
31 |
* arrange for tracing to be enabled. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
32 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
33 |
* \subsection internetStackArpTracingModel Tracing in ARP |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
34 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
35 |
* ARP provides two trace hooks, one in the cache, and one in the layer three |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
36 |
* protocol. The trace accessor in the cache is given the name "Drop." When |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
37 |
* a packet is transmitted over an interface that requires ARP, it is first |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
38 |
* queued for transmission in the ARP cache until the required MAC address is |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
39 |
* resolved. There are a number of retries that may be done trying to get the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
40 |
* address, and if the maximum retry count is exceeded the packet in question |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
41 |
* is dropped by ARP. The single trace hook in the ARP cache is called, |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
42 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
43 |
* - If an outbound packet is placed in the ARP cache pending address resolution |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
44 |
* and no resolution can be made within the maximum retry count, the outbound |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
45 |
* packet is dropped and this trace is fired; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
46 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
47 |
* A second trace hook lives in the ARP L3 protocol (also named "Drop") and may |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
48 |
* be called for a number of reasons. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
49 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
50 |
* - If an ARP reply is received for an entry that is not waiting for a reply, |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
51 |
* the ARP reply packet is dropped and this trace is fired; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
52 |
* - If an ARP reply is received for a non-existant entry, the ARP reply packet |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
53 |
* is dropped and this trace is fired; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
54 |
* - If an ARP cache entry is in the DEAD state (has timed out) and an ARP reply |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
55 |
* packet is received, the reply packet is dropped and this trace is fired. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
56 |
* - Each ARP cache entry has a queue of pending packets. If the size of the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
57 |
* queue is exceeded, the outbound packet is dropped and this trace is fired. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
58 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
59 |
* \subsection internetStackIpv4TracingModel Tracing in IPv4 |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
60 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
61 |
* The IPv4 layer three protocol provides three trace hooks. These are the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
62 |
* "Tx" (ns3::Ipv4L3Protocol::m_txTrace), "Rx" (ns3::Ipv4L3Protocol::m_rxTrace) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
63 |
* and "Drop" (ns3::Ipv4L3Protocol::m_dropTrace) trace sources. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
64 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
65 |
* The "Tx" trace is fired in a number of situations, all of which indicate that |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
66 |
* a given packet is about to be sent down to a given ns3::Ipv4Interface. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
67 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
68 |
* - In the case of a packet destined for the broadcast address, the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
69 |
* Ipv4InterfaceList is iterated and for every interface that is up and can |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
70 |
* fragment the packet or has a large enough MTU to transmit the packet, |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
71 |
* the trace is hit. See ns3::Ipv4L3Protocol::Send. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
72 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
73 |
* - In the case of a packet that needs routing, the "Tx" trace may be fired |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
74 |
* just before a packet is sent to the interface appropriate to the default |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
75 |
* gateway. See ns3::Ipv4L3Protocol::SendRealOut. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
76 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
77 |
* - Also in the case of a packet that needs routing, the "Tx" trace may be |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
78 |
* fired just before a packet is sent to the outgoing interface appropriate |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
79 |
* to the discovered route. See ns3::Ipv4L3Protocol::SendRealOut. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
80 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
81 |
* The "Rx" trace is fired when a packet is passed from the device up to the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
82 |
* ns3::Ipv4L3Protocol::Receive function. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
83 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
84 |
* - In the receive function, the Ipv4InterfaceList is iterated, and if the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
85 |
* Ipv4Interface corresponding to the receiving device is fount to be in the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
86 |
* UP state, the trace is fired. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
87 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
88 |
* The "Drop" trace is fired in any case where the packet is dropped (in both |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
89 |
* the transmit and receive paths). |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
90 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
91 |
* - In the ns3::Ipv4Interface::Receive function, the packet is dropped and the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
92 |
* drop trace is hit if the interface corresponding to the receiving device |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
93 |
* is in the DOWN state. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
94 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
95 |
* - Also in the ns3::Ipv4Interface::Receive function, the packet is dropped and |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
96 |
* the drop trace is hit if the checksum is found to be bad. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
97 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
98 |
* - In ns3::Ipv4L3Protocol::Send, an outgoing packet bound for the broadcast |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
99 |
* address is dropped and the "Drop" trace is fired if the "don't fragement" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
100 |
* bit is set and fragmentation is available and required. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
101 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
102 |
* - Also in ns3::Ipv4L3Protocol::Send, an outgoing packet destined for the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
103 |
* broadcast address is dropped and the "Drop" trace is hit if fragmentation |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
104 |
* is not available and is required (MTU < packet size). |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
105 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
106 |
* - In the case of a broadcast address, an outgoing packet is cloned for each |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
107 |
* outgoing interface. If any of the interfaces is in the DOWN state, the |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
108 |
* "Drop" trace event fires with a reference to the copied packet. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
109 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
110 |
* - In the case of a packet requiring a route, an outgoing packet is dropped |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
111 |
* and the "Drop" trace event fires if no route to the remote host is found. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
112 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
113 |
* - In ns3::Ipv4L3Protocol::SendRealOut, an outgoing packet being routed |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
114 |
* is dropped and the "Drop" trace is fired if the "don't fragement" bit is |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
115 |
* set and fragmentation is available and required. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
116 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
117 |
* - Also in ns3::Ipv4L3Protocol::SendRealOut, an outgoing packet being routed |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
118 |
* is dropped and the "Drop" trace is hit if fragmentation is not available |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
119 |
* and is required (MTU < packet size). |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
120 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
121 |
* - An outgoing packet being routed is dropped and the "Drop" trace event fires |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
122 |
* if the required Ipv4Interface is in the DOWN state. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
123 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
124 |
* - If a packet is being forwarded, and the TTL is exceeded (see |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
125 |
* ns3::Ipv4L3Protocol::DoForward), the packet is dropped and the "Drop" trace |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
126 |
* event is fired. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
127 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
128 |
* \subsection internetStackNs3TCPTracingModel Tracing in ns-3 TCP |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
129 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
130 |
* There is currently one trace source in the ns-3 TCP implementation named |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
131 |
* "CongestionWindow" (see ns3::TcpSocketImpl::m_cWnd). This is set in a number |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
132 |
* of places (see file tcp-socket-impl.cc) whenever the value of the congestion |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
133 |
* window is changed. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
134 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
135 |
* \subsection internetStackNscTCPTracingModel Tracing in NSC TCP |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
136 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
137 |
* There is currently one trace source in the Network Simulation Cradle TCP |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
138 |
* implementation named "CongestionWindow" (see ns3::NscTcpSocketImpl::m_cWnd). |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
139 |
* This is set in a number of places (see file nsc-tcp-socket-impl.cc) when |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
140 |
* the value of the cogestion window is initially set. Note that this is not |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
141 |
* instrumented from the underlying TCP implementaion. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
142 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
143 |
* \subsection internetStackNs3UdpTracingModel Tracing in ns-3 UDP |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
144 |
* |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
145 |
* There is currently one trace source in the ns-3 UDP implementation named |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
146 |
* "Drop" (see ns3::UdpSocketImpl::m_dropTrace). This is set when a packet |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
147 |
* is received in ns3::UdpSocketImpl::ForwardUp and the receive buffer cannot |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
148 |
* accomodate the encapsulated data. |
2833
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2737
diff
changeset
|
149 |
*/ |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
150 |
|
2995
b72805b3ca69
Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents:
2887
diff
changeset
|
151 |
#include "ns3/assert.h" |
b72805b3ca69
Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents:
2887
diff
changeset
|
152 |
#include "ns3/log.h" |
b72805b3ca69
Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents:
2887
diff
changeset
|
153 |
#include "ns3/object.h" |
4147
5d8530130930
rename object-names.{cc,h} to names.{cc,h} per convention
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
154 |
#include "ns3/names.h" |
2995
b72805b3ca69
Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents:
2887
diff
changeset
|
155 |
#include "ns3/ipv4.h" |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
156 |
#include "ns3/ipv6.h" |
2737
c692287f91da
aggregate PacketSocketFactory unconditionally.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2708
diff
changeset
|
157 |
#include "ns3/packet-socket-factory.h" |
2845
2398826af6b4
Add IP layer tracing helpers to InternetStackHelper
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
158 |
#include "ns3/config.h" |
3009 | 159 |
#include "ns3/simulator.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
160 |
#include "ns3/string.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
161 |
#include "ns3/net-device.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
162 |
#include "ns3/callback.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
163 |
#include "ns3/node.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
164 |
#include "ns3/core-config.h" |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
165 |
#include "ns3/arp-l3-protocol.h" |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
166 |
#include "internet-stack-helper.h" |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
167 |
#include "ipv4-list-routing-helper.h" |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
168 |
#include "ipv4-static-routing-helper.h" |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
169 |
#include "ipv4-global-routing-helper.h" |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
170 |
#include "ipv6-list-routing-helper.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
171 |
#include "ipv6-static-routing-helper.h" |
6028
96fb92f73f3d
merge trace helpers, rescan
Craig Dowell <craigdo@ee.washington.edu>
parents:
6027
diff
changeset
|
172 |
#include "trace-helper.h" |
3365
6409d2460601
bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3009
diff
changeset
|
173 |
#include <limits> |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
174 |
#include <map> |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
175 |
|
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
176 |
NS_LOG_COMPONENT_DEFINE ("InternetStackHelper"); |
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
177 |
|
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
namespace ns3 { |
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
180 |
// |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
181 |
// Historically, the only context written to ascii traces was the protocol. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
182 |
// Traces from the protocols include the interface, though. It is not |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
183 |
// possible to really determine where an event originated without including |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
184 |
// this. If you want the additional context information, define |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
185 |
// INTERFACE_CONTEXT. If you want compatibility with the old-style traces |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
186 |
// comment it out. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
187 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
188 |
#define INTERFACE_CONTEXT |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
189 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
190 |
// |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
191 |
// Things are going to work differently here with respect to trace file handling |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
192 |
// than in most places because the Tx and Rx trace sources we are interested in |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
193 |
// are going to multiplex receive and transmit callbacks for all Ipv4 and |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
194 |
// interface pairs through one callback. We want packets to or from each |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
195 |
// distinct pair to go to an individual file, so we have got to demultiplex the |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
196 |
// Ipv4 and interface pair into a corresponding Ptr<PcapFileObject> at the |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
197 |
// callback. |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
198 |
// |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
199 |
// A complication in this situation is that the trace sources are hooked on |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
200 |
// a protocol basis. There is no trace source hooked by an Ipv4 and interface |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
201 |
// pair. This means that if we naively proceed to hook, say, a drop trace |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
202 |
// for a given Ipv4 with interface 0, and then hook for Ipv4 with interface 1 |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
203 |
// we will hook the drop trace twice and get two callbacks per event. What |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
204 |
// we need to do is to hook the event once, and that will result in a single |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
205 |
// callback per drop event, and the trace source will provide the interface |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
206 |
// which we filter on in the trace sink. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
207 |
// |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
208 |
// This has got to continue to work properly after the helper has been |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
209 |
// destroyed; but must be cleaned up at the end of time to avoid leaks. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
210 |
// Global maps of protocol/interface pairs to file objects seems to fit the |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
211 |
// bill. |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
212 |
// |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
213 |
typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
214 |
typedef std::map<InterfacePairIpv4, Ptr<PcapFileObject> > InterfaceFileMapIpv4; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
215 |
typedef std::map<InterfacePairIpv4, Ptr<OutputStreamObject> > InterfaceStreamMapIpv4; |
6027 | 216 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
217 |
static InterfaceFileMapIpv4 g_interfaceFileMapIpv4; /**< A mapping of Ipv4/interface pairs to pcap files */ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
218 |
static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4; /**< A mapping of Ipv4/interface pairs to ascii streams */ |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
219 |
|
6027 | 220 |
typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6; |
221 |
typedef std::map<InterfacePairIpv6, Ptr<PcapFileObject> > InterfaceFileMapIpv6; |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
222 |
typedef std::map<InterfacePairIpv6, Ptr<OutputStreamObject> > InterfaceStreamMapIpv6; |
6027 | 223 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
224 |
static InterfaceFileMapIpv6 g_interfaceFileMapIpv6; /**< A mapping of Ipv6/interface pairs to pcap files */ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
225 |
static InterfaceStreamMapIpv6 g_interfaceStreamMapIpv6; /**< A mapping of Ipv6/interface pairs to pcap files */ |
2845
2398826af6b4
Add IP layer tracing helpers to InternetStackHelper
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
226 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
227 |
InternetStackHelper::InternetStackHelper () |
5353
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
228 |
: m_routing (0), |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
229 |
m_routingv6 (0), |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
230 |
m_ipv4Enabled (true), |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
231 |
m_ipv6Enabled (true) |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
232 |
{ |
5356
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
233 |
Initialize (); |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
234 |
} |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
235 |
|
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
236 |
// private method called by both constructor and Reset () |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
237 |
void |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
238 |
InternetStackHelper::Initialize () |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
239 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
240 |
SetTcp ("ns3::TcpL4Protocol"); |
5353
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
241 |
Ipv4StaticRoutingHelper staticRouting; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
242 |
Ipv4GlobalRoutingHelper globalRouting; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
243 |
Ipv4ListRoutingHelper listRouting; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
244 |
Ipv6ListRoutingHelper listRoutingv6; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
245 |
Ipv6StaticRoutingHelper staticRoutingv6; |
5356
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
246 |
listRouting.Add (staticRouting, 0); |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
247 |
listRouting.Add (globalRouting, -10); |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
248 |
listRoutingv6.Add (staticRoutingv6, 0); |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
249 |
SetRoutingHelper (listRouting); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
250 |
SetRoutingHelper (listRoutingv6); |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
251 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
252 |
|
5353
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
253 |
InternetStackHelper::~InternetStackHelper () |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
254 |
{ |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
255 |
delete m_routing; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
256 |
delete m_routingv6; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
257 |
} |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
258 |
|
5359
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
259 |
InternetStackHelper::InternetStackHelper (const InternetStackHelper &o) |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
260 |
{ |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
261 |
m_routing = o.m_routing->Copy (); |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
262 |
m_routingv6 = o.m_routingv6->Copy (); |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
263 |
m_ipv4Enabled = o.m_ipv4Enabled; |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
264 |
m_ipv6Enabled = o.m_ipv6Enabled; |
5360
f9f9f1f41517
do not reinitialize in copy constructor
Tom Henderson <tomh@tomh.org>
parents:
5359
diff
changeset
|
265 |
m_tcpFactory = o.m_tcpFactory; |
5359
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
266 |
} |
a2196f9bca93
add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5356
diff
changeset
|
267 |
|
5355
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
268 |
InternetStackHelper & |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
269 |
InternetStackHelper::operator = (const InternetStackHelper &o) |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
270 |
{ |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
271 |
if (this == &o) |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
272 |
{ |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
273 |
return *this; |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
274 |
} |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
275 |
m_routing = o.m_routing->Copy (); |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
276 |
m_routingv6 = o.m_routingv6->Copy (); |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
277 |
return *this; |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
278 |
} |
fb4c54590532
allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents:
5353
diff
changeset
|
279 |
|
5356
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
280 |
void |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
281 |
InternetStackHelper::Reset (void) |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
282 |
{ |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
283 |
delete m_routing; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
284 |
m_routing = 0; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
285 |
delete m_routingv6; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
286 |
m_routingv6 = 0; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
287 |
m_ipv4Enabled = true; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
288 |
m_ipv6Enabled = true; |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
289 |
Initialize (); |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
290 |
} |
8f693fdc3149
add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents:
5355
diff
changeset
|
291 |
|
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
292 |
void |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
293 |
InternetStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing) |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
294 |
{ |
5353
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
295 |
delete m_routing; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
296 |
m_routing = routing.Copy (); |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
297 |
} |
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
298 |
|
3009 | 299 |
void |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
300 |
InternetStackHelper::SetRoutingHelper (const Ipv6RoutingHelper &routing) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
301 |
{ |
5353
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
302 |
delete m_routingv6; |
a63513286aa0
Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents:
5214
diff
changeset
|
303 |
m_routingv6 = routing.Copy (); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
304 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
305 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
306 |
void |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
307 |
InternetStackHelper::SetIpv4StackInstall (bool enable) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
308 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
309 |
m_ipv4Enabled = enable; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
310 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
311 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
312 |
void InternetStackHelper::SetIpv6StackInstall (bool enable) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
313 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
314 |
m_ipv6Enabled = enable; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
315 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
316 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
317 |
void |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
318 |
InternetStackHelper::SetTcp (const std::string tid) |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
319 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
320 |
m_tcpFactory.SetTypeId (tid); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
321 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
322 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
323 |
void |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
324 |
InternetStackHelper::SetTcp (std::string tid, std::string n0, const AttributeValue &v0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
325 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
326 |
m_tcpFactory.SetTypeId (tid); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
327 |
m_tcpFactory.Set (n0,v0); |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
328 |
} |
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
329 |
|
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
330 |
void |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
331 |
InternetStackHelper::Install (NodeContainer c) const |
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
332 |
{ |
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
333 |
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
334 |
{ |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
335 |
Install (*i); |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
336 |
} |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
337 |
} |
3579
9e5eaef3e082
nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents:
3365
diff
changeset
|
338 |
|
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
339 |
void |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
340 |
InternetStackHelper::InstallAll (void) const |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
341 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
342 |
Install (NodeContainer::GetGlobal ()); |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
343 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
344 |
|
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
345 |
void |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4573
diff
changeset
|
346 |
InternetStackHelper::CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
347 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
348 |
ObjectFactory factory; |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
349 |
factory.SetTypeId (typeId); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
350 |
Ptr<Object> protocol = factory.Create <Object> (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
351 |
node->AggregateObject (protocol); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
352 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4147
diff
changeset
|
353 |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
354 |
void |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
355 |
InternetStackHelper::Install (Ptr<Node> node) const |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
356 |
{ |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
357 |
if (m_ipv4Enabled) |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
358 |
{ |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
359 |
if (node->GetObject<Ipv4> () != 0) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
360 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
361 |
NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating " |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
362 |
"an InternetStack to a node with an existing Ipv4 object"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
363 |
return; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
364 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
365 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
366 |
CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
367 |
CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
368 |
CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
369 |
CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
370 |
node->AggregateObject (m_tcpFactory.Create<Object> ()); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
371 |
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
372 |
node->AggregateObject (factory); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
373 |
// Set routing |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
374 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
375 |
Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
376 |
ipv4->SetRoutingProtocol (ipv4Routing); |
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
377 |
} |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3579
diff
changeset
|
378 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
379 |
if (m_ipv6Enabled) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
380 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
381 |
/* IPv6 stack */ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
382 |
if (node->GetObject<Ipv6> () != 0) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
383 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
384 |
NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating " |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
385 |
"an InternetStack to a node with an existing Ipv6 object"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
386 |
return; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
387 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
388 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
389 |
CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
390 |
CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol"); |
5873
df27945958ff
Workaround to use IPv6 over PPP (before we implement IPv6CP).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5784
diff
changeset
|
391 |
/* TODO add UdpL4Protocol/TcpL4Protocol for IPv6 */ |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
392 |
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
393 |
Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
394 |
ipv6->SetRoutingProtocol (ipv6Routing); |
5784
512909f442f7
More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5360
diff
changeset
|
395 |
|
512909f442f7
More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5360
diff
changeset
|
396 |
/* register IPv6 extensions and options */ |
512909f442f7
More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5360
diff
changeset
|
397 |
ipv6->RegisterExtensions (); |
512909f442f7
More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5360
diff
changeset
|
398 |
ipv6->RegisterOptions (); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4712
diff
changeset
|
399 |
} |
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
400 |
} |
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
401 |
|
2845
2398826af6b4
Add IP layer tracing helpers to InternetStackHelper
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
402 |
void |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3863
diff
changeset
|
403 |
InternetStackHelper::Install (std::string nodeName) const |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3863
diff
changeset
|
404 |
{ |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3863
diff
changeset
|
405 |
Ptr<Node> node = Names::Find<Node> (nodeName); |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3863
diff
changeset
|
406 |
Install (node); |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3863
diff
changeset
|
407 |
} |
6013 | 408 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
409 |
static void |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
410 |
Ipv4L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface) |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
411 |
{ |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
412 |
NS_LOG_FUNCTION (p << ipv4 << interface); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
413 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
414 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
415 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
416 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
417 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
418 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
419 |
// |
6027 | 420 |
InterfacePairIpv4 pair = std::make_pair (ipv4, interface); |
421 |
if (g_interfaceFileMapIpv4.find (pair) == g_interfaceFileMapIpv4.end ()) |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
422 |
{ |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
423 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
424 |
return; |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
425 |
} |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
426 |
|
6027 | 427 |
Ptr<PcapFileObject> file = g_interfaceFileMapIpv4[pair]; |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
428 |
file->Write(Simulator::Now(), p); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
429 |
} |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
430 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
431 |
bool |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
432 |
InternetStackHelper::PcapHooked (Ptr<Ipv4> ipv4) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
433 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
434 |
for ( InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
435 |
i != g_interfaceFileMapIpv4.end (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
436 |
++i) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
437 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
438 |
if ((*i).first.first == ipv4) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
439 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
440 |
return true; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
441 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
442 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
443 |
return false; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
444 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
445 |
|
6013 | 446 |
void |
6027 | 447 |
InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface) |
6013 | 448 |
{ |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
449 |
NS_LOG_FUNCTION (prefix << ipv4 << interface); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
450 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
451 |
if (!m_ipv4Enabled) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
452 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
453 |
NS_LOG_INFO ("Call to enable Ipv4 pcap tracing but Ipv4 not enabled"); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
454 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
455 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
456 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
457 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
458 |
// We have to create a file and a mapping from protocol/interface to file |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
459 |
// irrespective of how many times we want to trace a particular protocol. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
460 |
// |
6013 | 461 |
PcapHelper pcapHelper; |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
462 |
std::string filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface); |
6013 | 463 |
Ptr<PcapFileObject> file = pcapHelper.CreateFile (filename, "w", PcapHelper::DLT_RAW); |
464 |
||
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
465 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
466 |
// However, we only hook the trace source once to avoid multiple trace sink |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
467 |
// calls per event (connect is independent of interface). |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
468 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
469 |
if (!PcapHooked (ipv4)) |
6013 | 470 |
{ |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
471 |
// |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
472 |
// Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
473 |
// node so we can get to Ipv4L3Protocol through Ipv4. |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
474 |
// |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
475 |
Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> (); |
6027 | 476 |
NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): " |
6013 | 477 |
"m_ipv4Enabled and ipv4L3Protocol inconsistent"); |
478 |
||
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
479 |
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink)); |
6027 | 480 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): " |
481 |
"Unable to connect ipv4L3Protocol \"Tx\""); |
|
6013 | 482 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
483 |
result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink)); |
6027 | 484 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): " |
485 |
"Unable to connect ipv4L3Protocol \"Rx\""); |
|
486 |
} |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
487 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
488 |
g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file; |
6027 | 489 |
} |
490 |
||
491 |
static void |
|
492 |
Ipv6L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface) |
|
493 |
{ |
|
494 |
NS_LOG_FUNCTION (p << ipv6 << interface); |
|
495 |
||
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
496 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
497 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
498 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
499 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
500 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
501 |
// |
6027 | 502 |
InterfacePairIpv6 pair = std::make_pair (ipv6, interface); |
503 |
if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ()) |
|
504 |
{ |
|
505 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
|
506 |
return; |
|
507 |
} |
|
508 |
||
509 |
Ptr<PcapFileObject> file = g_interfaceFileMapIpv6[pair]; |
|
510 |
file->Write(Simulator::Now(), p); |
|
511 |
} |
|
512 |
||
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
513 |
bool |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
514 |
InternetStackHelper::PcapHooked (Ptr<Ipv6> ipv6) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
515 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
516 |
for ( InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
517 |
i != g_interfaceFileMapIpv6.end (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
518 |
++i) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
519 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
520 |
if ((*i).first.first == ipv6) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
521 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
522 |
return true; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
523 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
524 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
525 |
return false; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
526 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
527 |
|
6027 | 528 |
void |
529 |
InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface) |
|
530 |
{ |
|
531 |
NS_LOG_FUNCTION (prefix << ipv6 << interface); |
|
532 |
||
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
533 |
if (!m_ipv6Enabled) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
534 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
535 |
NS_LOG_INFO ("Call to enable Ipv6 pcap tracing but Ipv6 not enabled"); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
536 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
537 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
538 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
539 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
540 |
// We have to create a file and a mapping from protocol/interface to file |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
541 |
// irrespective of how many times we want to trace a particular protocol. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
542 |
// |
6027 | 543 |
PcapHelper pcapHelper; |
544 |
std::string filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface); |
|
545 |
Ptr<PcapFileObject> file = pcapHelper.CreateFile (filename, "w", PcapHelper::DLT_RAW); |
|
546 |
||
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
547 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
548 |
// However, we only hook the trace source once to avoid multiple trace sink |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
549 |
// calls per event (connect is independent of interface). |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
550 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
551 |
if (!PcapHooked (ipv6)) |
6027 | 552 |
{ |
553 |
// |
|
554 |
// Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to |
|
555 |
// node so we can get to Ipv6L3Protocol through Ipv6. |
|
556 |
// |
|
557 |
Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> (); |
|
558 |
NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): " |
|
559 |
"m_ipv6Enabled and ipv6L3Protocol inconsistent"); |
|
560 |
||
561 |
bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink)); |
|
562 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): " |
|
563 |
"Unable to connect ipv6L3Protocol \"Tx\""); |
|
564 |
||
565 |
result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink)); |
|
566 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): " |
|
567 |
"Unable to connect ipv6L3Protocol \"Rx\""); |
|
6013 | 568 |
} |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
569 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
570 |
g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file; |
6013 | 571 |
} |
572 |
||
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
573 |
static void |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
574 |
Ipv4L3ProtocolDropSinkWithoutContext ( |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
575 |
Ptr<OutputStreamObject> stream, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
576 |
Ipv4Header const &header, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
577 |
Ptr<const Packet> packet, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
578 |
Ipv4L3Protocol::DropReason reason, |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
579 |
Ptr<Ipv4> ipv4, |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
580 |
uint32_t interface) |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
581 |
{ |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
582 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
583 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
584 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
585 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
586 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
587 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
588 |
InterfacePairIpv4 pair = std::make_pair (ipv4, interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
589 |
if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ()) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
590 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
591 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
592 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
593 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
594 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
595 |
Ptr<Packet> p = packet->Copy (); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
596 |
p->AddHeader (header); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
597 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl; |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
598 |
} |
6013 | 599 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
600 |
static void |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
601 |
Ipv4L3ProtocolDropSinkWithContext ( |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
602 |
Ptr<OutputStreamObject> stream, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
603 |
std::string context, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
604 |
Ipv4Header const &header, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
605 |
Ptr<const Packet> packet, |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
606 |
Ipv4L3Protocol::DropReason reason, |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
607 |
Ptr<Ipv4> ipv4, |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
608 |
uint32_t interface) |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
609 |
{ |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
610 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
611 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
612 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
613 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
614 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
615 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
616 |
InterfacePairIpv4 pair = std::make_pair (ipv4, interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
617 |
if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ()) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
618 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
619 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
620 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
621 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
622 |
|
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
623 |
Ptr<Packet> p = packet->Copy (); |
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
624 |
p->AddHeader (header); |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
625 |
#ifdef INTERFACE_CONTEXT |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
626 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
627 |
<< *p << std::endl; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
628 |
#else |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
629 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
630 |
#endif |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
631 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
632 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
633 |
bool |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
634 |
InternetStackHelper::AsciiHooked (Ptr<Ipv4> ipv4) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
635 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
636 |
for ( InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
637 |
i != g_interfaceStreamMapIpv4.end (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
638 |
++i) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
639 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
640 |
if ((*i).first.first == ipv4) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
641 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
642 |
return true; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
643 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
644 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
645 |
return false; |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
646 |
} |
6013 | 647 |
|
648 |
void |
|
6027 | 649 |
InternetStackHelper::EnableAsciiIpv4Internal ( |
6013 | 650 |
Ptr<OutputStreamObject> stream, |
651 |
std::string prefix, |
|
652 |
Ptr<Ipv4> ipv4, |
|
653 |
uint32_t interface) |
|
654 |
{ |
|
6027 | 655 |
if (!m_ipv4Enabled) |
656 |
{ |
|
657 |
NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled"); |
|
658 |
return; |
|
659 |
} |
|
660 |
||
6013 | 661 |
// |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
662 |
// Our trace sinks are going to use packet printing, so we have to |
6013 | 663 |
// make sure that is turned on. |
664 |
// |
|
665 |
Packet::EnablePrinting (); |
|
666 |
||
667 |
// |
|
668 |
// If we are not provided an OutputStreamObject, we are expected to create |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
669 |
// one using the usual trace filename conventions and hook WithoutContext |
6013 | 670 |
// since there will be one file per context and therefore the context would |
671 |
// be redundant. |
|
672 |
// |
|
673 |
if (stream == 0) |
|
674 |
{ |
|
675 |
// |
|
676 |
// Set up an output stream object to deal with private ofstream copy |
|
677 |
// constructor and lifetime issues. Let the helper decide the actual |
|
678 |
// name of the file given the prefix. |
|
679 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
680 |
// We have to create a stream and a mapping from protocol/interface to |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
681 |
// stream irrespective of how many times we want to trace a particular |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
682 |
// protocol. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
683 |
// |
6013 | 684 |
AsciiTraceHelper asciiTraceHelper; |
6015
e9e4575cb6f3
clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
6013
diff
changeset
|
685 |
std::string filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface); |
6013 | 686 |
Ptr<OutputStreamObject> theStream = asciiTraceHelper.CreateFileStream (filename, "w"); |
687 |
||
688 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
689 |
// However, we only hook the trace sources once to avoid multiple trace sink |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
690 |
// calls per event (connect is independent of interface). |
6013 | 691 |
// |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
692 |
if (!AsciiHooked (ipv4)) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
693 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
694 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
695 |
// We can use the default drop sink for the ArpL3Protocol since it has |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
696 |
// the usual signature. We can get to the Ptr<ArpL3Protocol> through |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
697 |
// our Ptr<Ipv4> since they must both be aggregated to the same node. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
698 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
699 |
Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
700 |
asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
701 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
702 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
703 |
// The drop sink for the Ipv4L3Protocol uses a different signature than |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
704 |
// the default sink, so we have to cook one up for ourselves. We can get |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
705 |
// to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
706 |
// be aggregated to the same node. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
707 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
708 |
Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
709 |
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
710 |
MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream)); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
711 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EanableAsciiIpv4Internal(): " |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
712 |
"Unable to connect ipv4L3Protocol \"Drop\""); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
713 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
714 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
715 |
g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream; |
6013 | 716 |
return; |
717 |
} |
|
718 |
||
719 |
// |
|
720 |
// If we are provided an OutputStreamObject, we are expected to use it, and |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
721 |
// to provide a context. We are free to come up with our own context if we |
6013 | 722 |
// want, and use the AsciiTraceHelper Hook*WithContext functions, but for |
723 |
// compatibility and simplicity, we just use Config::Connect and let it deal |
|
724 |
// with the context. |
|
725 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
726 |
// We need to associate the ipv4/interface with a stream to express interest |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
727 |
// in tracing events on that pair, however, we only hook the trace sources |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
728 |
// once to avoid multiple trace sink calls per event (connect is independent |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
729 |
// of interface). |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
730 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
731 |
if (!AsciiHooked (ipv4)) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
732 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
733 |
Ptr<Node> node = ipv4->GetObject<Node> (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
734 |
std::ostringstream oss; |
6013 | 735 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
736 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
737 |
// For the ARP Drop, we are going to use the default trace sink provided by |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
738 |
// the ascii trace helper. There is actually no AsciiTraceHelper in sight |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
739 |
// here, but the default trace sinks are actually publicly available static |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
740 |
// functions that are always there waiting for just such a case. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
741 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
742 |
oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop"; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
743 |
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream)); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
744 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
745 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
746 |
// This has all kinds of parameters coming with, so we have to cook up our |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
747 |
// own sink. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
748 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
749 |
oss.str (""); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
750 |
oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop"; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
751 |
Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithContext, stream)); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
752 |
} |
6013 | 753 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
754 |
g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream; |
6013 | 755 |
} |
756 |
||
6027 | 757 |
static void |
758 |
Ipv6L3ProtocolDropSinkWithoutContext ( |
|
759 |
Ptr<OutputStreamObject> stream, |
|
760 |
Ipv6Header const &header, |
|
761 |
Ptr<const Packet> packet, |
|
762 |
Ipv6L3Protocol::DropReason reason, |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
763 |
Ptr<Ipv6> ipv6, |
6027 | 764 |
uint32_t interface) |
3863
4222173d1e6d
Add an InternetStackHelper method to do ascii tracing on drop events
Tom Henderson <tomh@tomh.org>
parents:
3848
diff
changeset
|
765 |
{ |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
766 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
767 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
768 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
769 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
770 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
771 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
772 |
InterfacePairIpv6 pair = std::make_pair (ipv6, interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
773 |
if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ()) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
774 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
775 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
776 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
777 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
778 |
|
6027 | 779 |
Ptr<Packet> p = packet->Copy (); |
780 |
p->AddHeader (header); |
|
781 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl; |
|
3863
4222173d1e6d
Add an InternetStackHelper method to do ascii tracing on drop events
Tom Henderson <tomh@tomh.org>
parents:
3848
diff
changeset
|
782 |
} |
4222173d1e6d
Add an InternetStackHelper method to do ascii tracing on drop events
Tom Henderson <tomh@tomh.org>
parents:
3848
diff
changeset
|
783 |
|
6027 | 784 |
static void |
785 |
Ipv6L3ProtocolDropSinkWithContext ( |
|
786 |
Ptr<OutputStreamObject> stream, |
|
787 |
std::string context, |
|
788 |
Ipv6Header const &header, |
|
789 |
Ptr<const Packet> packet, |
|
790 |
Ipv6L3Protocol::DropReason reason, |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
791 |
Ptr<Ipv6> ipv6, |
6027 | 792 |
uint32_t interface) |
5214
ed1c7a9d95c3
Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
793 |
{ |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
794 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
795 |
// Since trace sources are independent of interface, if we hook a source |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
796 |
// on a particular protocol we will get traces for all of its interfaces. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
797 |
// We need to filter this to only report interfaces for which the user |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
798 |
// has expressed interest. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
799 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
800 |
InterfacePairIpv6 pair = std::make_pair (ipv6, interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
801 |
if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ()) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
802 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
803 |
NS_LOG_INFO ("Ignoring packet to/from interface " << interface); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
804 |
return; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
805 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
806 |
|
5214
ed1c7a9d95c3
Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
807 |
Ptr<Packet> p = packet->Copy (); |
ed1c7a9d95c3
Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
808 |
p->AddHeader (header); |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
809 |
#ifdef INTERFACE_CONTEXT |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
810 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
811 |
<< *p << std::endl; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
812 |
#else |
6027 | 813 |
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl; |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
814 |
#endif |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
815 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
816 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
817 |
bool |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
818 |
InternetStackHelper::AsciiHooked (Ptr<Ipv6> ipv6) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
819 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
820 |
for ( InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
821 |
i != g_interfaceStreamMapIpv6.end (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
822 |
++i) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
823 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
824 |
if ((*i).first.first == ipv6) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
825 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
826 |
return true; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
827 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
828 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
829 |
return false; |
5214
ed1c7a9d95c3
Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
830 |
} |
6027 | 831 |
|
832 |
void |
|
833 |
InternetStackHelper::EnableAsciiIpv6Internal ( |
|
834 |
Ptr<OutputStreamObject> stream, |
|
835 |
std::string prefix, |
|
836 |
Ptr<Ipv6> ipv6, |
|
837 |
uint32_t interface) |
|
838 |
{ |
|
839 |
if (!m_ipv6Enabled) |
|
840 |
{ |
|
841 |
NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled"); |
|
842 |
return; |
|
843 |
} |
|
844 |
||
845 |
// |
|
846 |
// Our trace sinks are going to use packet printing, so we have to |
|
847 |
// make sure that is turned on. |
|
848 |
// |
|
849 |
Packet::EnablePrinting (); |
|
850 |
||
851 |
// |
|
852 |
// If we are not provided an OutputStreamObject, we are expected to create |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
853 |
// one using the usual trace filename conventions and do a hook WithoutContext |
6027 | 854 |
// since there will be one file per context and therefore the context would |
855 |
// be redundant. |
|
856 |
// |
|
857 |
if (stream == 0) |
|
858 |
{ |
|
859 |
// |
|
860 |
// Set up an output stream object to deal with private ofstream copy |
|
861 |
// constructor and lifetime issues. Let the helper decide the actual |
|
862 |
// name of the file given the prefix. |
|
863 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
864 |
// We have to create a stream and a mapping from protocol/interface to |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
865 |
// stream irrespective of how many times we want to trace a particular |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
866 |
// protocol. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
867 |
// |
6027 | 868 |
AsciiTraceHelper asciiTraceHelper; |
869 |
std::string filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface); |
|
870 |
Ptr<OutputStreamObject> theStream = asciiTraceHelper.CreateFileStream (filename, "w"); |
|
871 |
||
872 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
873 |
// However, we only hook the trace sources once to avoid multiple trace sink |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
874 |
// calls per event (connect is independent of interface). |
6027 | 875 |
// |
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
876 |
if (!AsciiHooked (ipv6)) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
877 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
878 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
879 |
// The drop sink for the Ipv6L3Protocol uses a different signature than |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
880 |
// the default sink, so we have to cook one up for ourselves. We can get |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
881 |
// to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
882 |
// be aggregated to the same node. |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
883 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
884 |
Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
885 |
bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
886 |
MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream)); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
887 |
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): " |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
888 |
"Unable to connect ipv6L3Protocol \"Drop\""); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
889 |
} |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
890 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
891 |
g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream; |
6027 | 892 |
return; |
893 |
} |
|
894 |
||
895 |
// |
|
896 |
// If we are provided an OutputStreamObject, we are expected to use it, and |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
897 |
// to provide a context. We are free to come up with our own context if we |
6027 | 898 |
// want, and use the AsciiTraceHelper Hook*WithContext functions, but for |
899 |
// compatibility and simplicity, we just use Config::Connect and let it deal |
|
900 |
// with the context. |
|
901 |
// |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
902 |
// We need to associate the ipv4/interface with a stream to express interest |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
903 |
// in tracing events on that pair, however, we only hook the trace sources |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
904 |
// once to avoid multiple trace sink calls per event (connect is independent |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
905 |
// of interface). |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
906 |
// |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
907 |
if (!AsciiHooked (ipv6)) |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
908 |
{ |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
909 |
Ptr<Node> node = ipv6->GetObject<Node> (); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
910 |
std::ostringstream oss; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
911 |
|
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
912 |
oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop"; |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
913 |
Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithContext, stream)); |
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
914 |
} |
6027 | 915 |
|
6030
7b67e0413b57
linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents:
6028
diff
changeset
|
916 |
g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream; |
6027 | 917 |
} |
5214
ed1c7a9d95c3
Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4731
diff
changeset
|
918 |
|
2708
83cc896e501c
InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
919 |
} // namespace ns3 |