A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
dpdk-net-device-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 NITK Surathkal
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
* Authors: Harsh Patel <thadodaharsh10@gmail.com>
18
* Hrishikesh Hiraskar <hrishihiraskar@gmail.com>
19
*/
20
21
#include "
dpdk-net-device-helper.h
"
22
23
#include "ns3/dpdk-net-device.h"
24
25
namespace
ns3
26
{
27
28
NS_LOG_COMPONENT_DEFINE
(
"DpdkNetDeviceHelper"
);
29
30
DpdkNetDeviceHelper::DpdkNetDeviceHelper
()
31
: m_lCoreList(
"0,1"
),
32
m_pmdLibrary(
"librte_pmd_e1000.so"
),
33
m_dpdkDriver(
"uio_pci_generic"
)
34
{
35
NS_LOG_FUNCTION
(
this
);
36
SetTypeId
(
"ns3::DpdkNetDevice"
);
37
}
38
39
void
40
DpdkNetDeviceHelper::SetLCoreList
(std::string lCoreList)
41
{
42
m_lCoreList
= lCoreList;
43
}
44
45
void
46
DpdkNetDeviceHelper::SetPmdLibrary
(std::string pmdLibrary)
47
{
48
m_pmdLibrary
= pmdLibrary;
49
}
50
51
void
52
DpdkNetDeviceHelper::SetDpdkDriver
(std::string dpdkDriver)
53
{
54
m_dpdkDriver
= dpdkDriver;
55
}
56
57
Ptr<NetDevice>
58
DpdkNetDeviceHelper::InstallPriv
(
Ptr<Node>
node)
const
59
{
60
NS_LOG_FUNCTION
(
this
);
61
Ptr<NetDevice>
device =
FdNetDeviceHelper::InstallPriv
(node);
62
Ptr<DpdkNetDevice>
dpdkDevice = DynamicCast<DpdkNetDevice>(device);
63
dpdkDevice->SetDeviceName(
m_deviceName
);
64
65
// Set EAL arguments
66
char
** ealArgv =
new
char
*[20];
67
68
// arg[0] is program name (optional)
69
ealArgv[0] =
new
char
[20];
70
strcpy(ealArgv[0],
""
);
71
72
// Logical core usage
73
ealArgv[1] =
new
char
[20];
74
strcpy(ealArgv[1],
"-l"
);
75
ealArgv[2] =
new
char
[20];
76
strcpy(ealArgv[2],
m_lCoreList
.c_str());
77
78
// Load library
79
ealArgv[3] =
new
char
[20];
80
strcpy(ealArgv[3],
"-d"
);
81
ealArgv[4] =
new
char
[50];
82
strcpy(ealArgv[4],
m_pmdLibrary
.c_str());
83
84
// Use mempool ring library
85
ealArgv[5] =
new
char
[20];
86
strcpy(ealArgv[5],
"-d"
);
87
ealArgv[6] =
new
char
[50];
88
strcpy(ealArgv[6],
"librte_mempool_ring.so"
);
89
90
dpdkDevice->InitDpdk(7, ealArgv,
m_dpdkDriver
);
91
return
dpdkDevice;
92
}
93
94
}
// namespace ns3
ns3::DpdkNetDeviceHelper::SetPmdLibrary
void SetPmdLibrary(std::string pmdLibrary)
Sets PMD Library to be used for the NIC.
Definition:
dpdk-net-device-helper.cc:46
ns3::DpdkNetDeviceHelper::m_lCoreList
std::string m_lCoreList
Logical cores to use.
Definition:
dpdk-net-device-helper.h:81
ns3::DpdkNetDeviceHelper::SetDpdkDriver
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
Definition:
dpdk-net-device-helper.cc:52
ns3::DpdkNetDeviceHelper::m_dpdkDriver
std::string m_dpdkDriver
DPDK Driver to bind NIC to.
Definition:
dpdk-net-device-helper.h:91
ns3::DpdkNetDeviceHelper::m_pmdLibrary
std::string m_pmdLibrary
PMD Library to be used for NIC.
Definition:
dpdk-net-device-helper.h:86
ns3::DpdkNetDeviceHelper::SetLCoreList
void SetLCoreList(std::string lCoreList)
Sets list of logical cores to use.
Definition:
dpdk-net-device-helper.cc:40
ns3::DpdkNetDeviceHelper::InstallPriv
Ptr< NetDevice > InstallPriv(Ptr< Node > node) const override
This method creates an ns3::FdNetDevice attached to a physical network interface.
Definition:
dpdk-net-device-helper.cc:58
ns3::DpdkNetDeviceHelper::DpdkNetDeviceHelper
DpdkNetDeviceHelper()
Construct a DpdkNetDeviceHelper and initialize DPDK EAL.
Definition:
dpdk-net-device-helper.cc:30
ns3::EmuFdNetDeviceHelper::m_deviceName
std::string m_deviceName
The Unix/Linux name of the underlying device (e.g., eth0)
Definition:
emu-fd-net-device-helper.h:99
ns3::FdNetDeviceHelper::InstallPriv
virtual Ptr< NetDevice > InstallPriv(Ptr< Node > node) const
This method creates an ns3::FdNetDevice and associates it to a node.
Definition:
fd-net-device-helper.cc:211
ns3::FdNetDeviceHelper::SetTypeId
void SetTypeId(std::string type)
Set the TypeId of the Objects to be created by this helper.
Definition:
fd-net-device-helper.cc:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
dpdk-net-device-helper.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:240
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
fd-net-device
helper
dpdk-net-device-helper.cc
Generated on Sun Mar 3 2024 17:10:57 for ns-3 by
1.9.1