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
dpdk-net-device-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 NITK Surathkal
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Harsh Patel <thadodaharsh10@gmail.com>
7
* Hrishikesh Hiraskar <hrishihiraskar@gmail.com>
8
*/
9
10
#include "
dpdk-net-device-helper.h
"
11
12
#include "ns3/dpdk-net-device.h"
13
14
namespace
ns3
15
{
16
17
NS_LOG_COMPONENT_DEFINE
(
"DpdkNetDeviceHelper"
);
18
19
DpdkNetDeviceHelper::DpdkNetDeviceHelper
()
20
: m_lCoreList(
"0,1"
),
21
m_pmdLibrary(
"librte_pmd_e1000.so"
),
22
m_dpdkDriver(
"uio_pci_generic"
)
23
{
24
NS_LOG_FUNCTION
(
this
);
25
SetTypeId
(
"ns3::DpdkNetDevice"
);
26
}
27
28
void
29
DpdkNetDeviceHelper::SetLCoreList
(std::string lCoreList)
30
{
31
m_lCoreList
= lCoreList;
32
}
33
34
void
35
DpdkNetDeviceHelper::SetPmdLibrary
(std::string pmdLibrary)
36
{
37
m_pmdLibrary
= pmdLibrary;
38
}
39
40
void
41
DpdkNetDeviceHelper::SetDpdkDriver
(std::string dpdkDriver)
42
{
43
m_dpdkDriver
= dpdkDriver;
44
}
45
46
Ptr<NetDevice>
47
DpdkNetDeviceHelper::InstallPriv
(
Ptr<Node>
node)
const
48
{
49
NS_LOG_FUNCTION
(
this
);
50
Ptr<NetDevice>
device =
FdNetDeviceHelper::InstallPriv
(node);
51
Ptr<DpdkNetDevice>
dpdkDevice =
DynamicCast<DpdkNetDevice>
(device);
52
dpdkDevice->SetDeviceName(
m_deviceName
);
53
54
// Set EAL arguments
55
char
** ealArgv =
new
char
*[20];
56
57
// arg[0] is program name (optional)
58
ealArgv[0] =
new
char
[20];
59
strcpy(ealArgv[0],
""
);
60
61
// Logical core usage
62
ealArgv[1] =
new
char
[20];
63
strcpy(ealArgv[1],
"-l"
);
64
ealArgv[2] =
new
char
[20];
65
strcpy(ealArgv[2],
m_lCoreList
.c_str());
66
67
// Load library
68
ealArgv[3] =
new
char
[20];
69
strcpy(ealArgv[3],
"-d"
);
70
ealArgv[4] =
new
char
[50];
71
strcpy(ealArgv[4],
m_pmdLibrary
.c_str());
72
73
// Use mempool ring library
74
ealArgv[5] =
new
char
[20];
75
strcpy(ealArgv[5],
"-d"
);
76
ealArgv[6] =
new
char
[50];
77
strcpy(ealArgv[6],
"librte_mempool_ring.so"
);
78
79
dpdkDevice->InitDpdk(7, ealArgv,
m_dpdkDriver
);
80
return
dpdkDevice;
81
}
82
83
}
// 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:35
ns3::DpdkNetDeviceHelper::m_lCoreList
std::string m_lCoreList
Logical cores to use.
Definition
dpdk-net-device-helper.h:69
ns3::DpdkNetDeviceHelper::SetDpdkDriver
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
Definition
dpdk-net-device-helper.cc:41
ns3::DpdkNetDeviceHelper::m_dpdkDriver
std::string m_dpdkDriver
DPDK Driver to bind NIC to.
Definition
dpdk-net-device-helper.h:79
ns3::DpdkNetDeviceHelper::m_pmdLibrary
std::string m_pmdLibrary
PMD Library to be used for NIC.
Definition
dpdk-net-device-helper.h:74
ns3::DpdkNetDeviceHelper::SetLCoreList
void SetLCoreList(std::string lCoreList)
Sets list of logical cores to use.
Definition
dpdk-net-device-helper.cc:29
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:47
ns3::DpdkNetDeviceHelper::DpdkNetDeviceHelper
DpdkNetDeviceHelper()
Construct a DpdkNetDeviceHelper and initialize DPDK EAL.
Definition
dpdk-net-device-helper.cc:19
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:88
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:200
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:35
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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:191
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:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DynamicCast
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition
ptr.h:580
src
fd-net-device
helper
dpdk-net-device-helper.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0