A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
16
using namespace
ns3
;
17
18
NS_LOG_COMPONENT_DEFINE
(
"TestIpv6"
);
19
20
int
21
main(
int
argc,
char
* argv[])
22
{
23
LogComponentEnable
(
"TestIpv6"
,
LOG_LEVEL_ALL
);
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
}
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6Address::MakeAutoconfiguredAddress
static Ipv6Address MakeAutoconfiguredAddress(Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address from a Mac address.
Definition
ipv6-address.cc:274
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition
log.cc:291
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition
log.h:105
examples
ipv6
test-ipv6.cc
Generated on Fri Nov 8 2024 13:58:58 for ns-3 by
1.11.0