A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-ipv6.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Louis Pasteur University / Telecom Bretagne
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Angelos Chatzipapas <Angelos.CHATZIPAPAS@enst-bretagne.fr> /
7 * <chatzipa@ceid.upatras.gr>
8 */
9
10#include "ns3/ipv6-address.h"
11#include "ns3/log.h"
12#include "ns3/mac48-address.h"
13#include "ns3/node.h"
14#include "ns3/simulator.h"
15
16using namespace ns3;
17
18NS_LOG_COMPONENT_DEFINE("TestIpv6");
19
20int
21main(int argc, char* argv[])
22{
24
25 NS_LOG_INFO("Test Ipv6");
26
27 Mac48Address m_addresses[10];
28
29 m_addresses[0] = ("00:00:00:00:00:01");
30 m_addresses[1] = ("00:00:00:00:00:02");
31 m_addresses[2] = ("00:00:00:00:00:03");
32 m_addresses[3] = ("00:00:00:00:00:04");
33 m_addresses[4] = ("00:00:00:00:00:05");
34 m_addresses[5] = ("00:00:00:00:00:06");
35 m_addresses[6] = ("00:00:00:00:00:07");
36 m_addresses[7] = ("00:00:00:00:00:08");
37 m_addresses[8] = ("00:00:00:00:00:09");
38 m_addresses[9] = ("00:00:00:00:00:10");
39
40 Ipv6Address prefix1("2001:1::");
41 NS_LOG_INFO("prefix = " << prefix1);
42 for (uint32_t i = 0; i < 10; ++i)
43 {
44 NS_LOG_INFO("address = " << m_addresses[i]);
45 Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress(m_addresses[i], prefix1);
46 NS_LOG_INFO("address = " << ipv6address);
47 }
48
49 Ipv6Address prefix2("2002:1:1::");
50
51 NS_LOG_INFO("prefix = " << prefix2);
52 for (uint32_t i = 0; i < 10; ++i)
53 {
54 Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress(m_addresses[i], prefix2);
55 NS_LOG_INFO("address = " << ipv6address);
56 }
57
58 return 0;
59}
Describes an IPv6 address.
static Ipv6Address MakeAutoconfiguredAddress(Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address from a Mac address.
an EUI-48 address
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105