src/internet/test/ipv6-fragmentation-test.cc
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Sat, 30 Nov 2013 12:38:22 +0100
changeset 10456 e4bc52ceab4d
parent 9855 d478e8a3b66e
child 10515 8238217cb0c3
permissions -rw-r--r--
Removed useless class from Internet tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     2
/*
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     3
 * Copyright (c) 2011 Universita' di Firenze, Italy
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     4
 *
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     8
 *
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    12
 * GNU General Public License for more details.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    13
 *
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    17
 *
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    18
 * Author: Tommaso Pecorella <[email protected]>
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    19
 */
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    20
/**
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    21
 * This is the test code for ipv6-l3protocol.cc (only the fragmentation and reassembly part).
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    22
 */
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
#define NS3_LOG_ENABLE 1
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    24
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
#include "ns3/test.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
#include "ns3/config.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
#include "ns3/uinteger.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
#include "ns3/socket-factory.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
#include "ns3/ipv4-raw-socket-factory.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
#include "ns3/ipv6-raw-socket-factory.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
#include "ns3/udp-socket-factory.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    32
#include "ns3/simulator.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    33
#include "error-channel.h"
10456
e4bc52ceab4d Removed useless class from Internet tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9855
diff changeset
    34
#include "ns3/simple-net-device.h"
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    35
#include "ns3/drop-tail-queue.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    36
#include "ns3/socket.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    37
#include "ns3/udp-socket.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    38
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    39
#include "ns3/log.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    40
#include "ns3/node.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    41
#include "ns3/inet-socket-address.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    42
#include "ns3/boolean.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    43
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    44
#include "ns3/ipv6-static-routing.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    45
#include "ns3/ipv6-list-routing.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    46
#include "ns3/inet6-socket-address.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    47
#
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    48
#include "ns3/arp-l3-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    49
#include "ns3/ipv4-l3-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    50
#include "ns3/icmpv4-l4-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    51
#include "ns3/ipv4-list-routing.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    52
#include "ns3/ipv4-static-routing.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    53
#include "ns3/udp-l4-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    54
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    55
#include "ns3/ipv6-l3-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    56
#include "ns3/icmpv6-l4-protocol.h"
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    57
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    58
#include <string>
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    59
#include <limits>
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    60
#include <netinet/in.h>
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    61
9079
1e5921e6507d Clean up core, network, internet, point-to-point tests that don't access private class attributes and methods in accordance to sample-test-suite.cc.
Vedran Miletić <rivanvx@gmail.com>
parents: 7790
diff changeset
    62
using namespace ns3;
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    63
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    64
class UdpSocketImpl;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    65
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
static void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    67
AddInternetStack (Ptr<Node> node)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    68
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    69
  //IPV6
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    70
  Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    71
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    72
  //Routing for Ipv6
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    73
  Ptr<Ipv6ListRouting> ipv6Routing = CreateObject<Ipv6ListRouting> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    74
  ipv6->SetRoutingProtocol (ipv6Routing);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    75
  Ptr<Ipv6StaticRouting> ipv6staticRouting = CreateObject<Ipv6StaticRouting> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    76
  ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    77
  node->AggregateObject (ipv6);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    78
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    79
  //ICMPv6
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    80
  Ptr<Icmpv6L4Protocol> icmp6 = CreateObject<Icmpv6L4Protocol> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    81
  node->AggregateObject (icmp6);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    82
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    83
  //Ipv6 Extensions
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    84
  ipv6->RegisterExtensions ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    85
  ipv6->RegisterOptions ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    86
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    87
  //UDP
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    88
  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    89
  node->AggregateObject (udp);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    90
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    91
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    92
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    93
class Ipv6FragmentationTest : public TestCase
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    94
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    95
  Ptr<Packet> m_sentPacketClient;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    96
  Ptr<Packet> m_receivedPacketClient;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    97
  Ptr<Packet> m_receivedPacketServer;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    98
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    99
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   100
  Ptr<Socket> m_socketServer;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   101
  Ptr<Socket> m_socketClient;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   102
  uint32_t m_dataSize;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   103
  uint8_t *m_data;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   104
  uint32_t m_size;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   105
  uint8_t m_icmpType;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   106
  uint8_t m_icmpCode;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   107
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   108
public:
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   109
  virtual void DoRun (void);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   110
  Ipv6FragmentationTest ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   111
  ~Ipv6FragmentationTest ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   112
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   113
  // server part
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   114
  void StartServer (Ptr<Node> ServerNode);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   115
  void HandleReadServer (Ptr<Socket> socket);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   116
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   117
  // client part
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   118
  void StartClient (Ptr<Node> ClientNode);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   119
  void HandleReadClient (Ptr<Socket> socket);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   120
  void HandleReadIcmpClient (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType,
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   121
                             uint8_t icmpCode,uint32_t icmpInfo);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   122
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   123
  void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   124
  Ptr<Packet> SendClient (void);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   125
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   126
};
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   127
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   128
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   129
Ipv6FragmentationTest::Ipv6FragmentationTest ()
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   130
  : TestCase ("Verify the IPv6 layer 3 protocol fragmentation and reassembly")
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   131
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   132
  m_socketServer = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   133
  m_data = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   134
  m_dataSize = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   135
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   136
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   137
Ipv6FragmentationTest::~Ipv6FragmentationTest ()
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   138
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   139
  if ( m_data )
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   140
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   141
      delete[] m_data;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   142
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   143
  m_data = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   144
  m_dataSize = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   145
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   146
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   147
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   148
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   149
Ipv6FragmentationTest::StartServer (Ptr<Node> ServerNode)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   150
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   151
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   152
  if (m_socketServer == 0)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   153
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   154
      TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   155
      m_socketServer = Socket::CreateSocket (ServerNode, tid);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   156
      Inet6SocketAddress local = Inet6SocketAddress (Ipv6Address ("2001::1"), 9);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   157
      m_socketServer->Bind (local);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   158
      Ptr<UdpSocket> udpSocket = DynamicCast<UdpSocket> (m_socketServer);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   159
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   160
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   161
  m_socketServer->SetRecvCallback (MakeCallback (&Ipv6FragmentationTest::HandleReadServer, this));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   162
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   163
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   164
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   165
Ipv6FragmentationTest::HandleReadServer (Ptr<Socket> socket)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   166
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   167
  Ptr<Packet> packet;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   168
  Address from;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   169
  while ((packet = socket->RecvFrom (from)))
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   170
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   171
      if (Inet6SocketAddress::IsMatchingType (from))
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   172
        {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   173
          packet->RemoveAllPacketTags ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   174
          packet->RemoveAllByteTags ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   175
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   176
          m_receivedPacketServer = packet->Copy ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   177
        }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   178
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   179
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   180
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   181
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   182
Ipv6FragmentationTest::StartClient (Ptr<Node> ClientNode)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   183
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   184
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   185
  if (m_socketClient == 0)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   186
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   187
      TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   188
      m_socketClient = Socket::CreateSocket (ClientNode, tid);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   189
      m_socketClient->Bind (Inet6SocketAddress (Ipv6Address::GetAny (), 9));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   190
      m_socketClient->Connect (Inet6SocketAddress (Ipv6Address ("2001::1"), 9));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   191
      CallbackValue cbValue = MakeCallback (&Ipv6FragmentationTest::HandleReadIcmpClient, this);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   192
      m_socketClient->SetAttribute ("IcmpCallback6", cbValue);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   193
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   194
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   195
  m_socketClient->SetRecvCallback (MakeCallback (&Ipv6FragmentationTest::HandleReadClient, this));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   196
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   197
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   198
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   199
Ipv6FragmentationTest::HandleReadClient (Ptr<Socket> socket)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   200
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   201
  Ptr<Packet> packet;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   202
  Address from;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   203
  while ((packet = socket->RecvFrom (from)))
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   204
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   205
      if (Inet6SocketAddress::IsMatchingType (from))
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   206
        {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   207
          m_receivedPacketClient = packet->Copy ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   208
        }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   209
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   210
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   211
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   212
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   213
Ipv6FragmentationTest::HandleReadIcmpClient (Ipv6Address icmpSource,
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   214
                                             uint8_t icmpTtl, uint8_t icmpType,
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   215
                                             uint8_t icmpCode, uint32_t icmpInfo)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   216
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   217
  m_icmpType = icmpType;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   218
  m_icmpCode = icmpCode;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   219
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   220
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   221
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   222
Ipv6FragmentationTest::SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   223
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   224
  if (dataSize != m_dataSize)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   225
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   226
      delete [] m_data;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   227
      m_data = new uint8_t [dataSize];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   228
      m_dataSize = dataSize;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   229
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   230
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   231
  if (fillSize >= dataSize)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   232
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   233
      memcpy (m_data, fill, dataSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   234
      return;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   235
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   236
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   237
  uint32_t filled = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   238
  while (filled + fillSize < dataSize)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   239
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   240
      memcpy (&m_data[filled], fill, fillSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   241
      filled += fillSize;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   242
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   243
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   244
  memcpy (&m_data[filled], fill, dataSize - filled);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   245
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   246
  m_size = dataSize;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   247
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   248
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   249
Ptr<Packet> Ipv6FragmentationTest::SendClient (void)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   250
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   251
  Ptr<Packet> p;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   252
  if (m_dataSize)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   253
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   254
      p = Create<Packet> (m_data, m_dataSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   255
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   256
  else
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   257
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   258
      p = Create<Packet> (m_size);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   259
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   260
  m_socketClient->Send (p);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   261
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   262
  return p;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   263
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   264
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   265
void
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   266
Ipv6FragmentationTest::DoRun (void)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   267
{
9855
d478e8a3b66e Bug 1720 - IPv6 Fragmentation cause crashes
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9266
diff changeset
   268
  // Create topology
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   269
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   270
  // Receiver Node
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   271
  Ptr<Node> serverNode = CreateObject<Node> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   272
  AddInternetStack (serverNode);
10456
e4bc52ceab4d Removed useless class from Internet tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9855
diff changeset
   273
  Ptr<SimpleNetDevice> serverDev;
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   274
  Ptr<BinaryErrorModel> serverDevErrorModel = CreateObject<BinaryErrorModel> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   275
  {
10456
e4bc52ceab4d Removed useless class from Internet tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9855
diff changeset
   276
    serverDev = CreateObject<SimpleNetDevice> ();
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   277
    serverDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   278
    serverDev->SetMtu (1500);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   279
    serverDev->SetReceiveErrorModel (serverDevErrorModel);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   280
    serverDevErrorModel->Disable ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   281
    serverNode->AddDevice (serverDev);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   282
    Ptr<Ipv6> ipv6 = serverNode->GetObject<Ipv6> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   283
    uint32_t netdev_idx = ipv6->AddInterface (serverDev);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   284
    Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001::1"), Ipv6Prefix (32));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   285
    ipv6->AddAddress (netdev_idx, ipv6Addr);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   286
    ipv6->SetUp (netdev_idx);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   287
  }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   288
  StartServer (serverNode);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   289
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   290
  // Sender Node
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   291
  Ptr<Node> clientNode = CreateObject<Node> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   292
  AddInternetStack (clientNode);
10456
e4bc52ceab4d Removed useless class from Internet tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9855
diff changeset
   293
  Ptr<SimpleNetDevice> clientDev;
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   294
  Ptr<BinaryErrorModel> clientDevErrorModel = CreateObject<BinaryErrorModel> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   295
  {
10456
e4bc52ceab4d Removed useless class from Internet tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 9855
diff changeset
   296
    clientDev = CreateObject<SimpleNetDevice> ();
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   297
    clientDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   298
    clientDev->SetMtu (1000);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   299
    clientDev->SetReceiveErrorModel (clientDevErrorModel);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   300
    clientDevErrorModel->Disable ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   301
    clientNode->AddDevice (clientDev);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   302
    Ptr<Ipv6> ipv6 = clientNode->GetObject<Ipv6> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   303
    uint32_t netdev_idx = ipv6->AddInterface (clientDev);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   304
    Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001::2"), Ipv6Prefix (32));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   305
    ipv6->AddAddress (netdev_idx, ipv6Addr);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   306
    ipv6->SetUp (netdev_idx);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   307
  }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   308
  StartClient (clientNode);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   309
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   310
  // link the two nodes
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   311
  Ptr<ErrorChannel> channel = CreateObject<ErrorChannel> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   312
  serverDev->SetChannel (channel);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   313
  clientDev->SetChannel (channel);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   314
  channel->SetJumpingTime (Seconds (0.5));
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   315
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   316
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   317
  // some small packets, some rather big ones
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   318
  uint32_t packetSizes[5] = {1000, 2000, 5000, 10000, 65000};
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   319
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   320
  // using the alphabet
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   321
  uint8_t fillData[78];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   322
  for ( uint32_t k = 48; k <= 125; k++ )
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   323
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   324
      fillData[k - 48] = k;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   325
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   326
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   327
  // First test: normal channel, no errors, no delays
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   328
  for ( int i = 0; i < 5; i++)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   329
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   330
      uint32_t packetSize = packetSizes[i];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   331
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   332
      SetFill (fillData, 78, packetSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   333
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   334
      m_receivedPacketServer = Create<Packet> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   335
      Simulator::ScheduleWithContext (m_socketClient->GetNode ()->GetId (), Seconds (0),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   336
                                      &Ipv6FragmentationTest::SendClient, this);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   337
      Simulator::Run ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   338
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   339
      uint8_t recvBuffer[65000];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   340
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   341
      uint16_t recvSize = m_receivedPacketServer->GetSize ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   342
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   343
      NS_TEST_EXPECT_MSG_EQ (recvSize, packetSizes[i],
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   344
                             "Packet size not correct: recvSize: " << recvSize << " packetSizes[" << i << "]: " << packetSizes[i] );
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   345
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   346
      m_receivedPacketServer->CopyData (recvBuffer, 65000);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   347
      NS_TEST_EXPECT_MSG_EQ (memcmp (m_data, recvBuffer, m_receivedPacketServer->GetSize ()),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   348
                             0, "Packet content differs");
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   349
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   350
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   351
  // Second test: normal channel, no errors, delays each 2 packets.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   352
  // Each other fragment will arrive out-of-order.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   353
  // The packets should be received correctly since reassembly will reorder the fragments.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   354
  channel->SetJumpingMode (true);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   355
  for ( int i = 0; i < 5; i++)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   356
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   357
      uint32_t packetSize = packetSizes[i];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   358
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   359
      SetFill (fillData, 78, packetSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   360
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   361
      m_receivedPacketServer = Create<Packet> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   362
      Simulator::ScheduleWithContext (m_socketClient->GetNode ()->GetId (), Seconds (0),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   363
                                      &Ipv6FragmentationTest::SendClient, this);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   364
      Simulator::Run ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   365
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   366
      uint8_t recvBuffer[65000];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   367
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   368
      uint16_t recvSize = m_receivedPacketServer->GetSize ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   369
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   370
      NS_TEST_EXPECT_MSG_EQ (recvSize, packetSizes[i],
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   371
                             "Packet size not correct: recvSize: " << recvSize << " packetSizes[" << i << "]: " << packetSizes[i] );
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   372
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   373
      m_receivedPacketServer->CopyData (recvBuffer, 65000);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   374
      NS_TEST_EXPECT_MSG_EQ (memcmp (m_data, recvBuffer, m_receivedPacketServer->GetSize ()),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   375
                             0, "Packet content differs");
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   376
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   377
  channel->SetJumpingMode (false);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   378
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   379
  // Third test: normal channel, some errors, no delays.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   380
  // The reassembly procedure should fire a timeout after 30 seconds (as specified in the RFCs).
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   381
  // Upon the timeout, the fragments received so far are discarded and an ICMP should be sent back
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   382
  // to the sender (if the first fragment has been received).
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   383
  // In this test case the first fragment is received, so we do expect an ICMP.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   384
  // Client -> Server : errors enabled
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   385
  // Server -> Client : errors disabled (we want to have back the ICMP)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   386
  clientDevErrorModel->Disable ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   387
  serverDevErrorModel->Enable ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   388
  for ( int i = 1; i < 5; i++)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   389
    {
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   390
      uint32_t packetSize = packetSizes[i];
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   391
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   392
      SetFill (fillData, 78, packetSize);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   393
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   394
      // reset the model, we want to receive the very first fragment.
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   395
      serverDevErrorModel->Reset ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   396
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   397
      m_receivedPacketServer = Create<Packet> ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   398
      m_icmpType = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   399
      m_icmpCode = 0;
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   400
      Simulator::ScheduleWithContext (m_socketClient->GetNode ()->GetId (), Seconds (0),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   401
                                      &Ipv6FragmentationTest::SendClient, this);
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   402
      Simulator::Run ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   403
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   404
      uint16_t recvSize = m_receivedPacketServer->GetSize ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   405
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   406
      NS_TEST_EXPECT_MSG_EQ ((recvSize == 0), true, "Server got a packet, something wrong");
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   407
      NS_TEST_EXPECT_MSG_EQ ((m_icmpType == Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   408
                             && (m_icmpCode == Icmpv6Header::ICMPV6_FRAGTIME),
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   409
                             true, "Client did not receive ICMPv6::TIME_EXCEEDED " << int(m_icmpType) << int(m_icmpCode) );
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   410
    }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   411
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   412
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   413
  Simulator::Destroy ();
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   414
}
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   415
//-----------------------------------------------------------------------------
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   416
class Ipv6FragmentationTestSuite : public TestSuite
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   417
{
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   418
public:
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   419
  Ipv6FragmentationTestSuite () : TestSuite ("ipv6-fragmentation", UNIT)
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   420
  {
9266
d26408b17360 bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents: 9079
diff changeset
   421
    AddTestCase (new Ipv6FragmentationTest, TestCase::QUICK);
7790
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   422
  }
47d6d575412c Bug 1362 - ICMPv6 does not forward ICMPs to upper layers
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   423
} g_ipv6fragmentationTestSuite;