src/internet/helper/internet-stack-helper.cc
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Thu, 14 Nov 2013 22:43:53 +0100
changeset 10405 45c8fceae24e
parent 10160 5bf2fe645784
child 10968 2d29fee2b7b8
permissions -rw-r--r--
Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
/**
7149
87514e0d866b Fix doxygen groups for some new modules
Mitch Watrous <watrous@u.washington.edu>
parents: 6837
diff changeset
    23
 * \ingroup internet
4472
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
db5fab391eac bug 170
Craig Dowell <craigdo@ee.washington.edu>
parents: 2996
diff changeset
   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"
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   164
#include "ns3/node-list.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   165
#include "ns3/core-config.h"
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   166
#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
   167
#include "internet-stack-helper.h"
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   168
#include "ns3/ipv4-global-routing.h"
6648
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6206
diff changeset
   169
#include "ns3/ipv4-list-routing-helper.h"
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6206
diff changeset
   170
#include "ns3/ipv4-static-routing-helper.h"
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6206
diff changeset
   171
#include "ns3/ipv4-global-routing-helper.h"
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6206
diff changeset
   172
#include "ns3/ipv6-list-routing-helper.h"
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6206
diff changeset
   173
#include "ns3/ipv6-static-routing-helper.h"
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   174
#include "ns3/ipv6-extension.h"
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   175
#include "ns3/ipv6-extension-demux.h"
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   176
#include "ns3/ipv6-extension-header.h"
10151
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   177
#include "ns3/icmpv6-l4-protocol.h"
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   178
#include "ns3/global-router-interface.h"
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3009
diff changeset
   179
#include <limits>
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   180
#include <map>
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   181
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   182
NS_LOG_COMPONENT_DEFINE ("InternetStackHelper");
2708
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
namespace ns3 {
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   186
//
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   187
// 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
   188
// 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
   189
// 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
   190
// 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
   191
// 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
   192
// comment it out.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   193
//
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   194
#define INTERFACE_CONTEXT
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   195
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   196
//
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   197
// 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
   198
// 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
   199
// 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
   200
// 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
   201
// distinct pair to go to an individual file, so we have got to demultiplex the
6052
e146b9c9c7e7 PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6049
diff changeset
   202
// Ipv4 and interface pair into a corresponding Ptr<PcapFileWrapper> at the 
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   203
// callback.
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   204
//
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   205
// 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
   206
// 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
   207
// 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
   208
// 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
   209
// 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
   210
// 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
   211
// 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
   212
// 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
   213
// 
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   214
// 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
   215
// 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
   216
// 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
   217
// bill.
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   218
//
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   219
typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4;  /**< Ipv4/interface pair */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   220
typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4;  /**< Ipv4/interface and Pcap file wrapper container */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   221
typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4;  /**< Ipv4/interface and output stream container */
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   222
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   223
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
   224
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
   225
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   226
typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6;  /**< Ipv6/interface pair */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   227
typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6;  /**< Ipv6/interface and Pcap file wrapper container */
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   228
typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6;  /**< Ipv6/interface and output stream container */
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   229
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   230
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
   231
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
   232
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   233
InternetStackHelper::InternetStackHelper ()
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   234
  : m_routing (0),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   235
    m_routingv6 (0),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   236
    m_ipv4Enabled (true),
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   237
    m_ipv6Enabled (true),
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   238
    m_ipv4ArpJitterEnabled (true),
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   239
    m_ipv6NsRsJitterEnabled (true)
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   240
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   241
{
5356
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   242
  Initialize ();
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   243
}
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   244
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   245
// 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
   246
void
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   247
InternetStackHelper::Initialize ()
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   248
{
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   249
  SetTcp ("ns3::TcpL4Protocol");
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   250
  Ipv4StaticRoutingHelper staticRouting;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   251
  Ipv4GlobalRoutingHelper globalRouting;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   252
  Ipv4ListRoutingHelper listRouting;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   253
  Ipv6ListRoutingHelper listRoutingv6;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   254
  Ipv6StaticRoutingHelper staticRoutingv6;
5356
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   255
  listRouting.Add (staticRouting, 0);
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   256
  listRouting.Add (globalRouting, -10);
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   257
  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
   258
  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
   259
  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
   260
}
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4573
diff changeset
   261
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   262
InternetStackHelper::~InternetStackHelper ()
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   263
{
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   264
  delete m_routing;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   265
  delete m_routingv6;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   266
}
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   267
5359
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   268
InternetStackHelper::InternetStackHelper (const InternetStackHelper &o)
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   269
{
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   270
  m_routing = o.m_routing->Copy ();
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   271
  m_routingv6 = o.m_routingv6->Copy ();
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   272
  m_ipv4Enabled = o.m_ipv4Enabled;
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   273
  m_ipv6Enabled = o.m_ipv6Enabled;
5360
f9f9f1f41517 do not reinitialize in copy constructor
Tom Henderson <tomh@tomh.org>
parents: 5359
diff changeset
   274
  m_tcpFactory = o.m_tcpFactory;
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   275
  m_ipv4ArpJitterEnabled = o.m_ipv4ArpJitterEnabled;
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   276
  m_ipv6NsRsJitterEnabled = o.m_ipv6NsRsJitterEnabled;
5359
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   277
}
a2196f9bca93 add copy constructor to InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5356
diff changeset
   278
5355
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   279
InternetStackHelper &
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   280
InternetStackHelper::operator = (const InternetStackHelper &o)
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   281
{
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   282
  if (this == &o)
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   283
    {
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   284
      return *this;
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   285
    }
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   286
  m_routing = o.m_routing->Copy ();
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   287
  m_routingv6 = o.m_routingv6->Copy ();
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   288
  return *this;
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   289
}
fb4c54590532 allow assignment operator for InternetStackHelper
Tom Henderson <tomh@tomh.org>
parents: 5353
diff changeset
   290
5356
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   291
void
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   292
InternetStackHelper::Reset (void)
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   293
{
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   294
  delete m_routing;
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   295
  m_routing = 0;
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   296
  delete m_routingv6;
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   297
  m_routingv6 = 0;
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   298
  m_ipv4Enabled = true;
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   299
  m_ipv6Enabled = true;
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   300
  m_ipv4ArpJitterEnabled = true;
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   301
  m_ipv6NsRsJitterEnabled = true;
5356
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   302
  Initialize ();
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   303
}
8f693fdc3149 add ability to reset InternetStackHelper w/o assigning a temporary
Tom Henderson <tomh@tomh.org>
parents: 5355
diff changeset
   304
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
   305
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
   306
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
   307
{
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   308
  delete m_routing;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   309
  m_routing = routing.Copy ();
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   310
}
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   311
3009
db5fab391eac bug 170
Craig Dowell <craigdo@ee.washington.edu>
parents: 2996
diff changeset
   312
void
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   313
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
   314
{
5353
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   315
  delete m_routingv6;
a63513286aa0 Fix memory management of routing helpers (bug 678)
Tom Henderson <tomh@tomh.org>
parents: 5214
diff changeset
   316
  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
   317
}
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   318
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   319
void
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   320
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
   321
{
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   322
  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
   323
}
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   324
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   325
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
   326
{
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   327
  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
   328
}
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   329
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   330
void InternetStackHelper::SetIpv4ArpJitter (bool enable)
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   331
{
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   332
  m_ipv4ArpJitterEnabled = enable;
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   333
}
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   334
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   335
void InternetStackHelper::SetIpv6NsRsJitter (bool enable)
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   336
{
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   337
  m_ipv6NsRsJitterEnabled = enable;
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   338
}
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   339
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   340
int64_t
8993
d62e95085efa Make InternetStackHelper::AssignStreams instead take a node container argument
Tom Henderson <tomh@tomh.org>
parents: 8977
diff changeset
   341
InternetStackHelper::AssignStreams (NodeContainer c, int64_t stream)
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   342
{
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   343
  int64_t currentStream = stream;
8993
d62e95085efa Make InternetStackHelper::AssignStreams instead take a node container argument
Tom Henderson <tomh@tomh.org>
parents: 8977
diff changeset
   344
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   345
    {
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   346
      Ptr<Node> node = *i;
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   347
      Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   348
      if (router != 0)
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   349
        {
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   350
          Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   351
          if (gr != 0)
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   352
            {
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   353
              currentStream += gr->AssignStreams (currentStream);
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   354
            }
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   355
        }
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   356
      Ptr<Ipv6ExtensionDemux> demux = node->GetObject<Ipv6ExtensionDemux> ();
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   357
      if (demux != 0)
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   358
        {
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   359
          Ptr<Ipv6Extension> fe = demux->GetExtension (Ipv6ExtensionFragment::EXT_NUMBER);
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   360
          NS_ASSERT (fe);  // should always exist in the demux
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   361
          currentStream += fe->AssignStreams (currentStream);
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   362
        }
10151
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   363
      Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   364
      if (ipv4 != 0)
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   365
        {
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   366
          Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   367
          if (arpL3Protocol != 0)
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   368
            {
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   369
              currentStream += arpL3Protocol->AssignStreams (currentStream);
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   370
            }
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   371
        }
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   372
      Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   373
      if (ipv6 != 0)
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   374
        {
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   375
          Ptr<Icmpv6L4Protocol> icmpv6L4Protocol = ipv6->GetObject<Icmpv6L4Protocol> ();
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   376
          if (icmpv6L4Protocol != 0)
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   377
            {
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   378
              currentStream += icmpv6L4Protocol->AssignStreams (currentStream);
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   379
            }
5d5dd1b12bfc Bug 1522 - Hidden node scenario leads to ARP failure
John Abraham <john.abraham.in@gmail.com>
parents: 9695
diff changeset
   380
        }
8977
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   381
    }
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   382
  return (currentStream - stream);
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   383
}
2bd04c7f5010 Replace src/internet usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7704
diff changeset
   384
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   385
void
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   386
InternetStackHelper::SetTcp (const std::string tid)
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   387
{
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   388
  m_tcpFactory.SetTypeId (tid);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   389
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   390
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   391
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   392
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
   393
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   394
  m_tcpFactory.SetTypeId (tid);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   395
  m_tcpFactory.Set (n0,v0);
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   396
}
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   397
2708
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   398
void 
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   399
InternetStackHelper::Install (NodeContainer c) const
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
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   402
    {
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   403
      Install (*i);
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   404
    }
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   405
}
3579
9e5eaef3e082 nsc: enable network simulation cradle
Florian Westphal <fw@strlen.de>
parents: 3365
diff changeset
   406
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
   407
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
   408
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
   409
{
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4573
diff changeset
   410
  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
   411
}
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4573
diff changeset
   412
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4573
diff changeset
   413
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
   414
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
   415
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   416
  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
   417
  factory.SetTypeId (typeId);
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   418
  Ptr<Object> protocol = factory.Create <Object> ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   419
  node->AggregateObject (protocol);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   420
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4147
diff changeset
   421
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   422
void
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   423
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
   424
{
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   425
  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
   426
    {
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   427
      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
   428
        {
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   429
          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
   430
                          "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
   431
          return;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   432
        }
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   433
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   434
      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
   435
      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
   436
      CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   437
      if (m_ipv4ArpJitterEnabled == false)
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   438
        {
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   439
          Ptr<ArpL3Protocol> arp = node->GetObject<ArpL3Protocol> ();
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   440
          NS_ASSERT (arp);
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   441
          arp->SetAttribute ("RequestJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   442
        }
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   443
      // Set routing
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   444
      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
   445
      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
   446
      ipv4->SetRoutingProtocol (ipv4Routing);
2708
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   447
    }
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3579
diff changeset
   448
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   449
  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
   450
    {
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   451
      /* IPv6 stack */
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   452
      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
   453
        {
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   454
          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
   455
                          "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
   456
          return;
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   457
        }
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   458
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   459
      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
   460
      CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   461
      if (m_ipv6NsRsJitterEnabled == false)
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   462
        {
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   463
          Ptr<Icmpv6L4Protocol> icmpv6l4 = node->GetObject<Icmpv6L4Protocol> ();
10160
5bf2fe645784 Update internet-stack-helper API for jitter and CHANGES.html
John Abraham <john.abraham.in@gmail.com>
parents: 10159
diff changeset
   464
          NS_ASSERT (icmpv6l4);
10159
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   465
          icmpv6l4->SetAttribute ("SolicitationJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
4cb133203819 Addendum to bug 1522
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10151
diff changeset
   466
        }
9695
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   467
      // Set routing
4731
510db8599bfb second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4712
diff changeset
   468
      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
   469
      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
   470
      ipv6->SetRoutingProtocol (ipv6Routing);
5784
512909f442f7 More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5360
diff changeset
   471
512909f442f7 More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5360
diff changeset
   472
      /* register IPv6 extensions and options */
512909f442f7 More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5360
diff changeset
   473
      ipv6->RegisterExtensions ();
512909f442f7 More on IPv6 extensions support.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 5360
diff changeset
   474
      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
   475
    }
9695
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   476
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   477
  if (m_ipv4Enabled || m_ipv6Enabled)
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   478
    {
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   479
      CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   480
      node->AggregateObject (m_tcpFactory.Create<Object> ());
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   481
      Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   482
      node->AggregateObject (factory);
e62d00344369 Bug 1626 - Ipv6-only network can't use UDP or TCP
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 8993
diff changeset
   483
    }
2708
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
}
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
2845
2398826af6b4 Add IP layer tracing helpers to InternetStackHelper
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2834
diff changeset
   486
void
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3863
diff changeset
   487
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
   488
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3863
diff changeset
   489
  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
   490
  Install (node);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3863
diff changeset
   491
}
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   492
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   493
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   494
 * \brief Sync function for IPv4 packet - Pcap output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   495
 * \param p smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   496
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   497
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   498
 */
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   499
static void
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   500
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
   501
{
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   502
  NS_LOG_FUNCTION (p << ipv4 << interface);
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   503
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   504
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   505
  // 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
   506
  // 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
   507
  // 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
   508
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   509
  //
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   510
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   511
  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
   512
    {
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   513
      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
   514
      return;
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   515
    }
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   516
6052
e146b9c9c7e7 PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6049
diff changeset
   517
  Ptr<PcapFileWrapper> file = g_interfaceFileMapIpv4[pair];
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7224
diff changeset
   518
  file->Write (Simulator::Now (), p);
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   519
}
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   520
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   521
bool
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   522
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
   523
{
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   524
  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
   525
         i != g_interfaceFileMapIpv4.end (); 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   526
         ++i)
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   527
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   528
      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
   529
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   530
          return true;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   531
        }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   532
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   533
  return false;
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
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   536
void 
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   537
InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface, bool explicitFilename)
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   538
{
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   539
  NS_LOG_FUNCTION (prefix << ipv4 << interface);
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   540
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   541
  if (!m_ipv4Enabled)
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   542
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   543
      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
   544
      return;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   545
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   546
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
  // 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
   549
  // 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
   550
  //
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   551
  PcapHelper pcapHelper;
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   552
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   553
  std::string filename;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   554
  if (explicitFilename)
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   555
    {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   556
      filename = prefix;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   557
    }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   558
  else
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   559
    {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   560
      filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   561
    }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   562
6206
9787dc9fdd84 bug 872: ns3::PcapFileWrapper::Write explodes stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6096
diff changeset
   563
  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   564
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   565
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   566
  // 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
   567
  // 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
   568
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   569
  if (!PcapHooked (ipv4))
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   570
    {
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   571
      //
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   572
      // 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
   573
      // 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
   574
      //
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   575
      Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   576
      NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): "
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   577
                     "m_ipv4Enabled and ipv4L3Protocol inconsistent");
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   578
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   579
      bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   580
      NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal():  "
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   581
                     "Unable to connect ipv4L3Protocol \"Tx\"");
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   582
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   583
      result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   584
      NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal():  "
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   585
                     "Unable to connect ipv4L3Protocol \"Rx\"");
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   586
    }
6030
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
  g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file;
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   589
}
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   590
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   591
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   592
 * \brief Sync function for IPv6 packet - Pcap output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   593
 * \param p smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   594
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   595
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   596
 */
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   597
static void
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   598
Ipv6L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface)
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   599
{
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   600
  NS_LOG_FUNCTION (p << ipv6 << interface);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   601
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   602
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   603
  // 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
   604
  // 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
   605
  // 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
   606
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   607
  //
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   608
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   609
  if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ())
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   610
    {
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   611
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   612
      return;
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   613
    }
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   614
6052
e146b9c9c7e7 PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6049
diff changeset
   615
  Ptr<PcapFileWrapper> file = g_interfaceFileMapIpv6[pair];
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7224
diff changeset
   616
  file->Write (Simulator::Now (), p);
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   617
}
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   618
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   619
bool
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   620
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
   621
{
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   622
  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
   623
         i != g_interfaceFileMapIpv6.end (); 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   624
         ++i)
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   625
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   626
      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
   627
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   628
          return true;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   629
        }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   630
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   631
  return false;
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
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   634
void 
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   635
InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface, bool explicitFilename)
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   636
{
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   637
  NS_LOG_FUNCTION (prefix << ipv6 << interface);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   638
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   639
  if (!m_ipv6Enabled)
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   640
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   641
      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
   642
      return;
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
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   646
  // 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
   647
  // 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
   648
  //
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   649
  PcapHelper pcapHelper;
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   650
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   651
  std::string filename;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   652
  if (explicitFilename)
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   653
    {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   654
      filename = prefix;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   655
    }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   656
  else
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   657
    {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   658
      filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   659
    }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   660
6206
9787dc9fdd84 bug 872: ns3::PcapFileWrapper::Write explodes stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6096
diff changeset
   661
  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   662
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   663
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   664
  // 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
   665
  // 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
   666
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   667
  if (!PcapHooked (ipv6))
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   668
    {
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   669
      //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   670
      // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   671
      // node so we can get to Ipv6L3Protocol through Ipv6.
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   672
      //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   673
      Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   674
      NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): "
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   675
                     "m_ipv6Enabled and ipv6L3Protocol inconsistent");
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   676
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   677
      bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   678
      NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal():  "
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   679
                     "Unable to connect ipv6L3Protocol \"Tx\"");
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   680
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   681
      result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   682
      NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal():  "
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   683
                     "Unable to connect ipv6L3Protocol \"Rx\"");
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   684
    }
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   685
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   686
  g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file;
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   687
}
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   688
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   689
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   690
 * \brief Sync function for IPv4 dropped packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   691
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   692
 * \param header IPv4 header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   693
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   694
 * \param reason the reason for the dropping
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   695
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   696
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   697
 */
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   698
static void
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   699
Ipv4L3ProtocolDropSinkWithoutContext (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
   700
  Ptr<OutputStreamWrapper> stream,
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   701
  Ipv4Header const &header, 
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   702
  Ptr<const Packet> packet,
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   703
  Ipv4L3Protocol::DropReason reason, 
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   704
  Ptr<Ipv4> ipv4, 
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   705
  uint32_t interface)
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   706
{
6030
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
  // 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
   709
  // 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
   710
  // 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
   711
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   712
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   713
  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
   714
  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
   715
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   716
      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
   717
      return;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   718
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   719
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   720
  Ptr<Packet> p = packet->Copy ();
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   721
  p->AddHeader (header);
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   722
  *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
   723
}
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   724
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   725
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   726
 * \brief Sync function for IPv4 transmitted packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   727
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   728
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   729
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   730
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   731
 */
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   732
static void
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   733
Ipv4L3ProtocolTxSinkWithoutContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   734
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   735
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   736
  Ptr<Ipv4> ipv4, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   737
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   738
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   739
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   740
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   741
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   742
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   743
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   744
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   745
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   746
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   747
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   748
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   749
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   750
 * \brief Sync function for IPv4 received packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   751
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   752
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   753
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   754
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   755
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   756
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   757
Ipv4L3ProtocolRxSinkWithoutContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   758
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   759
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   760
  Ptr<Ipv4> ipv4, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   761
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   762
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   763
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   764
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   765
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   766
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   767
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   768
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   769
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   770
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   771
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   772
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   773
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   774
 * \brief Sync function for IPv4 dropped packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   775
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   776
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   777
 * \param header IPv4 header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   778
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   779
 * \param reason the reason for the dropping
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   780
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   781
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   782
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   783
static void
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   784
Ipv4L3ProtocolDropSinkWithContext (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
   785
  Ptr<OutputStreamWrapper> stream,
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   786
  std::string context,
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   787
  Ipv4Header const &header, 
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   788
  Ptr<const Packet> packet,
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   789
  Ipv4L3Protocol::DropReason reason, 
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   790
  Ptr<Ipv4> ipv4, 
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   791
  uint32_t interface)
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   792
{
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   793
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   794
  // 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
   795
  // 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
   796
  // 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
   797
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   798
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   799
  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
   800
  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
   801
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   802
      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
   803
      return;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   804
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   805
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   806
  Ptr<Packet> p = packet->Copy ();
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   807
  p->AddHeader (header);
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   808
#ifdef INTERFACE_CONTEXT
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   809
  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   810
                        << *p << std::endl;
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   811
#else
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   812
  *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
   813
#endif
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   814
}
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   815
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   816
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   817
 * \brief Sync function for IPv4 transmitted packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   818
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   819
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   820
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   821
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   822
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   823
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   824
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   825
Ipv4L3ProtocolTxSinkWithContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   826
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   827
  std::string context,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   828
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   829
  Ptr<Ipv4> ipv4, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   830
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   831
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   832
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   833
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   834
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   835
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   836
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   837
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   838
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   839
#ifdef INTERFACE_CONTEXT
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   840
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   841
                        << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   842
#else
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   843
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " "  << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   844
#endif
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   845
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   846
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   847
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   848
 * \brief Sync function for IPv4 received packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   849
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   850
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   851
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   852
 * \param ipv4 smart pointer to the node's IPv4 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   853
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
   854
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   855
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   856
Ipv4L3ProtocolRxSinkWithContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   857
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   858
  std::string context,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   859
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   860
  Ptr<Ipv4> ipv4, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   861
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   862
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   863
  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   864
  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   865
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   866
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   867
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   868
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   869
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   870
#ifdef INTERFACE_CONTEXT
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   871
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   872
                        << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   873
#else
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   874
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " "  << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   875
#endif
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   876
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   877
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   878
bool
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   879
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
   880
{
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   881
  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
   882
         i != g_interfaceStreamMapIpv4.end (); 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   883
         ++i)
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   884
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   885
      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
   886
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   887
          return true;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   888
        }
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
  return false;
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   891
}
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   892
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   893
void 
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   894
InternetStackHelper::EnableAsciiIpv4Internal (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
   895
  Ptr<OutputStreamWrapper> stream, 
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   896
  std::string prefix, 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   897
  Ptr<Ipv4> ipv4, 
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   898
  uint32_t interface,
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   899
  bool explicitFilename)
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   900
{
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   901
  if (!m_ipv4Enabled)
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   902
    {
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   903
      NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   904
      return;
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   905
    }
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
   906
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   907
  //
6015
e9e4575cb6f3 clean up internet stack helper tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
   908
  // Our trace sinks are going to use packet printing, so we have to 
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   909
  // make sure that is turned on.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   910
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   911
  Packet::EnablePrinting ();
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   912
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   913
  //
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
   914
  // If we are not provided an OutputStreamWrapper, 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
   915
  // one using the usual trace filename conventions and hook WithoutContext
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   916
  // since there will be one file per context and therefore the context would
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   917
  // be redundant.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   918
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   919
  if (stream == 0)
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   920
    {
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   921
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   922
      // Set up an output stream object to deal with private ofstream copy 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   923
      // constructor and lifetime issues.  Let the helper decide the actual
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   924
      // name of the file given the prefix.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   925
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   926
      // 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
   927
      // 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
   928
      // protocol.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   929
      //
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   930
      AsciiTraceHelper asciiTraceHelper;
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   931
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   932
      std::string filename;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   933
      if (explicitFilename)
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   934
        {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   935
          filename = prefix;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   936
        }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   937
      else
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   938
        {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   939
          filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   940
        }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
   941
6206
9787dc9fdd84 bug 872: ns3::PcapFileWrapper::Write explodes stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6096
diff changeset
   942
      Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   943
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   944
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   945
      // 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
   946
      // calls per event (connect is independent of interface).
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   947
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   948
      if (!AsciiHooked (ipv4))
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   949
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   950
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   951
          // 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
   952
          // 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
   953
          // 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
   954
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   955
          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
   956
          asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
   957
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   958
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   959
          // 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
   960
          // 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
   961
          // 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
   962
          // 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
   963
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   964
          Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
7704
aef733235832 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <mazo@iitp.ru>
parents: 7628
diff changeset
   965
          bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
aef733235832 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <mazo@iitp.ru>
parents: 7628
diff changeset
   966
                                                                    MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream));
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   967
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   968
                         "Unable to connect ipv4L3Protocol \"Drop\"");
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   969
          result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   970
                                                               MakeBoundCallback (&Ipv4L3ProtocolTxSinkWithoutContext, theStream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   971
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   972
                         "Unable to connect ipv4L3Protocol \"Tx\"");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   973
          result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   974
                                                               MakeBoundCallback (&Ipv4L3ProtocolRxSinkWithoutContext, theStream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   975
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal():  "
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
   976
                         "Unable to connect ipv4L3Protocol \"Rx\"");
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   977
        }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   978
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   979
      g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   980
      return;
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   981
    }
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   982
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   983
  //
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
   984
  // If we are provided an OutputStreamWrapper, 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
   985
  // to provide a context.  We are free to come up with our own context if we
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   986
  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   987
  // compatibility and simplicity, we just use Config::Connect and let it deal
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   988
  // with the context.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   989
  //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   990
  // 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
   991
  // 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
   992
  // 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
   993
  // of interface).
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   994
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   995
  if (!AsciiHooked (ipv4))
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   996
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   997
      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
   998
      std::ostringstream oss;
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
   999
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1000
      //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1001
      // 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
  1002
      // 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
  1003
      // 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
  1004
      // 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
  1005
      //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1006
      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
  1007
      Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
  1008
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1009
      //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1010
      // 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
  1011
      // own sink.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1012
      //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1013
      oss.str ("");
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1014
      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
  1015
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithContext, stream));
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1016
      oss.str ("");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1017
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1018
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolTxSinkWithContext, stream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1019
      oss.str ("");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1020
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1021
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolRxSinkWithContext, stream));
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1022
    }
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
  1023
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1024
  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
  1025
}
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 5873
diff changeset
  1026
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1027
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1028
 * \brief Sync function for IPv6 dropped packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1029
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1030
 * \param header IPv6 header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1031
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1032
 * \param reason the reason for the dropping
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1033
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1034
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1035
 */
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1036
static void
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1037
Ipv6L3ProtocolDropSinkWithoutContext (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
  1038
  Ptr<OutputStreamWrapper> stream,
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1039
  Ipv6Header const &header, 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1040
  Ptr<const Packet> packet,
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1041
  Ipv6L3Protocol::DropReason reason, 
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1042
  Ptr<Ipv6> ipv6, 
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1043
  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
  1044
{
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1045
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1046
  // 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
  1047
  // 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
  1048
  // 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
  1049
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1050
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1051
  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
  1052
  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
  1053
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1054
      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
  1055
      return;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1056
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1057
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1058
  Ptr<Packet> p = packet->Copy ();
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1059
  p->AddHeader (header);
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1060
  *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
  1061
}
4222173d1e6d Add an InternetStackHelper method to do ascii tracing on drop events
Tom Henderson <tomh@tomh.org>
parents: 3848
diff changeset
  1062
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1063
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1064
 * \brief Sync function for IPv6 transmitted packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1065
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1066
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1067
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1068
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1069
 */
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1070
static void
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1071
Ipv6L3ProtocolTxSinkWithoutContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1072
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1073
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1074
  Ptr<Ipv6> ipv6, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1075
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1076
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1077
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1078
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1079
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1080
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1081
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1082
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1083
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1084
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1085
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1086
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1087
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1088
 * \brief Sync function for IPv6 received packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1089
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1090
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1091
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1092
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1093
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1094
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1095
Ipv6L3ProtocolRxSinkWithoutContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1096
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1097
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1098
  Ptr<Ipv6> ipv6, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1099
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1100
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1101
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1102
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1103
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1104
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1105
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1106
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1107
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1108
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1109
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1110
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1111
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1112
 * \brief Sync function for IPv6 dropped packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1113
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1114
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1115
 * \param header IPv6 header
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1116
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1117
 * \param reason the reason for the dropping
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1118
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1119
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1120
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1121
static void
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1122
Ipv6L3ProtocolDropSinkWithContext (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
  1123
  Ptr<OutputStreamWrapper> stream,
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1124
  std::string context,
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1125
  Ipv6Header const &header, 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1126
  Ptr<const Packet> packet,
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1127
  Ipv6L3Protocol::DropReason reason, 
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1128
  Ptr<Ipv6> ipv6, 
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1129
  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
  1130
{
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1131
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1132
  // 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
  1133
  // 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
  1134
  // 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
  1135
  // has expressed interest.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1136
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1137
  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
  1138
  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
  1139
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1140
      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
  1141
      return;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1142
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1143
5214
ed1c7a9d95c3 Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4731
diff changeset
  1144
  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
  1145
  p->AddHeader (header);
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1146
#ifdef INTERFACE_CONTEXT
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1147
  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
  1148
                        << *p << std::endl;
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1149
#else
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1150
  *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
  1151
#endif
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1152
}
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1153
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1154
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1155
 * \brief Sync function for IPv6 transmitted packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1156
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1157
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1158
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1159
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1160
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1161
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1162
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1163
Ipv6L3ProtocolTxSinkWithContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1164
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1165
  std::string context,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1166
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1167
  Ptr<Ipv6> ipv6, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1168
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1169
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1170
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1171
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1172
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1173
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1174
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1175
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1176
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1177
#ifdef INTERFACE_CONTEXT
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1178
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1179
                        << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1180
#else
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1181
  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1182
#endif
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1183
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1184
10405
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1185
/**
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1186
 * \brief Sync function for IPv6 received packet - Ascii output
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1187
 * \param stream the output stream
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1188
 * \param context the context
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1189
 * \param packet smart pointer to the packet
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1190
 * \param ipv6 smart pointer to the node's IPv6 stack
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1191
 * \param interface incoming interface
45c8fceae24e Doxygen fixes to Topology-read, Ipv6, and tcp-socket
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10160
diff changeset
  1192
 */
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1193
static void
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1194
Ipv6L3ProtocolRxSinkWithContext (
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1195
  Ptr<OutputStreamWrapper> stream,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1196
  std::string context,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1197
  Ptr<const Packet> packet,
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1198
  Ptr<Ipv6> ipv6, 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1199
  uint32_t interface)
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1200
{
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1201
  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1202
  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1203
    {
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1204
      NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1205
      return;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1206
    }
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1207
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1208
#ifdef INTERFACE_CONTEXT
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1209
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") " 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1210
                        << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1211
#else
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1212
  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1213
#endif
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1214
}
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1215
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1216
bool
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1217
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
  1218
{
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1219
  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
  1220
         i != g_interfaceStreamMapIpv6.end (); 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
  1221
         ++i)
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1222
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1223
      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
  1224
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1225
          return true;
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1226
        }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1227
    }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1228
  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
  1229
}
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1230
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1231
void 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1232
InternetStackHelper::EnableAsciiIpv6Internal (
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
  1233
  Ptr<OutputStreamWrapper> stream, 
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1234
  std::string prefix, 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1235
  Ptr<Ipv6> ipv6, 
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1236
  uint32_t interface,
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1237
  bool explicitFilename)
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1238
{
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1239
  if (!m_ipv6Enabled)
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1240
    {
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1241
      NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1242
      return;
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1243
    }
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1244
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1245
  //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1246
  // Our trace sinks are going to use packet printing, so we have to 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1247
  // make sure that is turned on.
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1248
  //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1249
  Packet::EnablePrinting ();
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1250
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1251
  //
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
  1252
  // If we are not provided an OutputStreamWrapper, 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
  1253
  // one using the usual trace filename conventions and do a hook WithoutContext
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1254
  // since there will be one file per context and therefore the context would
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1255
  // be redundant.
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1256
  //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1257
  if (stream == 0)
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1258
    {
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1259
      //
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1260
      // Set up an output stream object to deal with private ofstream copy 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1261
      // constructor and lifetime issues.  Let the helper decide the actual
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1262
      // name of the file given the prefix.
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1263
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1264
      // 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
  1265
      // 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
  1266
      // protocol.
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1267
      //
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1268
      AsciiTraceHelper asciiTraceHelper;
6096
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1269
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1270
      std::string filename;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1271
      if (explicitFilename)
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1272
        {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1273
          filename = prefix;
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1274
        }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1275
      else
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1276
        {
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1277
          filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1278
        }
96deefc231fa plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 6053
diff changeset
  1279
6206
9787dc9fdd84 bug 872: ns3::PcapFileWrapper::Write explodes stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6096
diff changeset
  1280
      Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1281
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1282
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1283
      // 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
  1284
      // calls per event (connect is independent of interface).
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1285
      //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1286
      if (!AsciiHooked (ipv6))
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1287
        {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1288
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1289
          // 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
  1290
          // 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
  1291
          // 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
  1292
          // 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
  1293
          //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1294
          Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
7704
aef733235832 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <mazo@iitp.ru>
parents: 7628
diff changeset
  1295
          bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop",
aef733235832 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <mazo@iitp.ru>
parents: 7628
diff changeset
  1296
                                                                    MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithoutContext, theStream));
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1297
          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
  1298
                         "Unable to connect ipv6L3Protocol \"Drop\"");
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1299
          result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1300
                                                               MakeBoundCallback (&Ipv6L3ProtocolTxSinkWithoutContext, theStream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1301
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1302
                         "Unable to connect ipv6L3Protocol \"Tx\"");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1303
          result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", 
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1304
                                                               MakeBoundCallback (&Ipv6L3ProtocolRxSinkWithoutContext, theStream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1305
          NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal():  "
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1306
                         "Unable to connect ipv6L3Protocol \"Rx\"");
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1307
        }
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1308
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1309
      g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1310
      return;
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1311
    }
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1312
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1313
  //
6053
b17ea72acee9 OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6052
diff changeset
  1314
  // If we are provided an OutputStreamWrapper, 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
  1315
  // to provide a context.  We are free to come up with our own context if we
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1316
  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for 
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1317
  // compatibility and simplicity, we just use Config::Connect and let it deal
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1318
  // with the context.
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1319
  //
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1320
  // 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
  1321
  // 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
  1322
  // 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
  1323
  // of interface).
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1324
  //
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1325
  if (!AsciiHooked (ipv6))
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1326
    {
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1327
      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
  1328
      std::ostringstream oss;
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7149
diff changeset
  1329
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1330
      oss.str ("");
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1331
      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
  1332
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolDropSinkWithContext, stream));
7628
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1333
      oss.str ("");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1334
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1335
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolTxSinkWithContext, stream));
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1336
      oss.str ("");
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1337
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
ae99bd34ef5c Fix bug 1299
Adrian S Tam <adrian.sw.tam@gmail.com>
parents: 7256
diff changeset
  1338
      Config::Connect (oss.str (), MakeBoundCallback (&Ipv6L3ProtocolRxSinkWithContext, stream));
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1339
    }
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1340
6030
7b67e0413b57 linearize mixins and make internet stack helper work correctly
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
  1341
  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
6027
8ed838dd0be5 add ipv6
Craig Dowell <craigdo@ee.washington.edu>
parents: 6015
diff changeset
  1342
}
5214
ed1c7a9d95c3 Fix InternetStackHelper::EnableAsciiAll to work with the new Drop signature
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4731
diff changeset
  1343
2708
83cc896e501c InternetStackHelper.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
  1344
} // namespace ns3