A Discrete-Event Network Simulator
API
test-ipv6.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2008 Louis Pasteur University / Telecom Bretagne
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Angelos Chatzipapas <Angelos.CHATZIPAPAS@enst-bretagne.fr> /
19 * <chatzipa@ceid.upatras.gr>
20 */
21
22#include "ns3/log.h"
23#include "ns3/ipv6-address.h"
24#include "ns3/node.h"
25#include "ns3/mac48-address.h"
26#include "ns3/simulator.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE ("TestIpv6");
31
32int
33main (int argc, char *argv[])
34{
36
37 NS_LOG_INFO ("Test Ipv6");
38
39 Mac48Address m_addresses[10];
40
41 m_addresses[0] = ("00:00:00:00:00:01");
42 m_addresses[1] = ("00:00:00:00:00:02");
43 m_addresses[2] = ("00:00:00:00:00:03");
44 m_addresses[3] = ("00:00:00:00:00:04");
45 m_addresses[4] = ("00:00:00:00:00:05");
46 m_addresses[5] = ("00:00:00:00:00:06");
47 m_addresses[6] = ("00:00:00:00:00:07");
48 m_addresses[7] = ("00:00:00:00:00:08");
49 m_addresses[8] = ("00:00:00:00:00:09");
50 m_addresses[9] = ("00:00:00:00:00:10");
51
52 Ipv6Address prefix1 ("2001:1::");
53 NS_LOG_INFO ("prefix = " << prefix1);
54 for (uint32_t i = 0; i < 10; ++i)
55 {
56 NS_LOG_INFO ("address = " << m_addresses[i]);
57 Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress (m_addresses[i], prefix1);
58 NS_LOG_INFO ("address = " << ipv6address);
59 }
60
61 Ipv6Address prefix2 ("2002:1:1::");
62
63 NS_LOG_INFO ("prefix = " << prefix2);
64 for (uint32_t i = 0; i < 10; ++i)
65 {
66 Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress (m_addresses[i], prefix2);
67 NS_LOG_INFO ("address = " << ipv6address);
68 }
69}
70
Describes an IPv6 address.
Definition: ipv6-address.h:50
an EUI-48 address
Definition: mac48-address.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361