examples/test-ipv6.cc
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
child 4767 7433d307ed51
permissions -rw-r--r--
Initial IPv6 capability
vincent@3852
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
vincent@3852
     2
/*
vincent@3852
     3
 * Copyright (c) 2008 Louis Pasteur University / Telecom Bretagne
vincent@3852
     4
 *
vincent@3852
     5
 * This program is free software; you can redistribute it and/or modify
vincent@3852
     6
 * it under the terms of the GNU General Public License version 2 as
vincent@3852
     7
 * published by the Free Software Foundation;
vincent@3852
     8
 *
vincent@3852
     9
 * This program is distributed in the hope that it will be useful,
vincent@3852
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
vincent@3852
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
vincent@3852
    12
 * GNU General Public License for more details.
vincent@3852
    13
 *
vincent@3852
    14
 * You should have received a copy of the GNU General Public License
vincent@3852
    15
 * along with this program; if not, write to the Free Software
vincent@3852
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
vincent@3852
    17
 *
vincent@3852
    18
 * Author: Angelos Chatzipapas <Angelos.CHATZIPAPAS@enst-bretagne.fr> /
vincent@3852
    19
 * <chatzipa@ceid.upatras.gr>
vincent@3852
    20
 */
vincent@3852
    21
vincent@3852
    22
#include "ns3/log.h"
vincent@3852
    23
//#include "ns3/ipv6.h"
vincent@3852
    24
#include "ns3/ipv6-address.h"
vincent@3852
    25
#include "ns3/node.h"
vincent@3852
    26
#include "ns3/mac48-address.h"
vincent@3852
    27
vincent@3852
    28
NS_LOG_COMPONENT_DEFINE ("TestIpv6");
vincent@3852
    29
vincent@3852
    30
using namespace ns3;
vincent@3852
    31
vincent@3852
    32
int 
vincent@3852
    33
main (int argc, char *argv[])
vincent@3852
    34
{
vincent@3852
    35
  LogComponentEnable ("TestIpv6", LOG_LEVEL_ALL);
vincent@3852
    36
vincent@3852
    37
  NS_LOG_INFO ("Test Ipv6");
vincent@3852
    38
vincent@3852
    39
  Mac48Address m_addresses[10];
vincent@3852
    40
vincent@3852
    41
  m_addresses[0]=("00:00:00:00:00:01");
vincent@3852
    42
  m_addresses[1]=("00:00:00:00:00:02");
vincent@3852
    43
  m_addresses[2]=("00:00:00:00:00:03");
vincent@3852
    44
  m_addresses[3]=("00:00:00:00:00:04");
vincent@3852
    45
  m_addresses[4]=("00:00:00:00:00:05");
vincent@3852
    46
  m_addresses[5]=("00:00:00:00:00:06");
vincent@3852
    47
  m_addresses[6]=("00:00:00:00:00:07");
vincent@3852
    48
  m_addresses[7]=("00:00:00:00:00:08");
vincent@3852
    49
  m_addresses[8]=("00:00:00:00:00:09");
vincent@3852
    50
  m_addresses[9]=("00:00:00:00:00:10");
vincent@3852
    51
vincent@3852
    52
  Ipv6Address prefix1 ("2001:1::");
vincent@3852
    53
  NS_LOG_INFO ("prefix = " << prefix1);
vincent@3852
    54
  for (uint32_t i = 0; i < 10 ; ++i)
vincent@3852
    55
    {
vincent@3852
    56
      NS_LOG_INFO ("address = " <<m_addresses[i]);
vincent@3852
    57
      Ipv6Address ipv6address=Ipv6Address::MakeAutoconfiguredAddress(m_addresses[i], prefix1);
vincent@3852
    58
      NS_LOG_INFO ("address = " <<ipv6address);
vincent@3852
    59
    }
vincent@3852
    60
vincent@3852
    61
  Ipv6Address prefix2 ("2002:1:1::");
vincent@3852
    62
vincent@3852
    63
  NS_LOG_INFO ("prefix = " << prefix2);
vincent@3852
    64
  for (uint32_t i = 0; i < 10 ; ++i)
vincent@3852
    65
    {
vincent@3852
    66
      Ipv6Address ipv6address=Ipv6Address::MakeAutoconfiguredAddress(m_addresses[i], prefix2);
vincent@3852
    67
      NS_LOG_INFO ("address = " <<ipv6address);
vincent@3852
    68
    }
vincent@3852
    69
}
vincent@3852
    70