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