A Discrete-Event Network Simulator
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
11
12#include "ns3/dpdk-net-device.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("DpdkNetDeviceHelper");
18
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
28void
30{
31 m_lCoreList = lCoreList;
32}
33
34void
36{
37 m_pmdLibrary = pmdLibrary;
38}
39
40void
42{
43 m_dpdkDriver = dpdkDriver;
44}
45
48{
49 NS_LOG_FUNCTION(this);
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
void SetPmdLibrary(std::string pmdLibrary)
Sets PMD Library to be used for the NIC.
std::string m_lCoreList
Logical cores to use.
void SetDpdkDriver(std::string dpdkDriver)
Sets DPDK Driver to bind NIC to.
std::string m_dpdkDriver
DPDK Driver to bind NIC to.
std::string m_pmdLibrary
PMD Library to be used for NIC.
void SetLCoreList(std::string lCoreList)
Sets list of logical cores to use.
Ptr< NetDevice > InstallPriv(Ptr< Node > node) const override
This method creates an ns3::FdNetDevice attached to a physical network interface.
DpdkNetDeviceHelper()
Construct a DpdkNetDeviceHelper and initialize DPDK EAL.
std::string m_deviceName
The Unix/Linux name of the underlying device (e.g., eth0)
virtual Ptr< NetDevice > InstallPriv(Ptr< Node > node) const
This method creates an ns3::FdNetDevice and associates it to a node.
void SetTypeId(std::string type)
Set the TypeId of the Objects to be created by this helper.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580