Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is the second.cc: #include ns 3 / applications - module.h #include ns 3 / core - module.h #include ns
Here is the second.cc:
#include nsapplicationsmodule.h
#include nscoremodule.h
#include nscsmamodule.h
#include nsinternetmodule.h
#include nsipvglobalroutinghelper.h
#include nsnetworkmodule.h
#include nspointtopointmodule.h
Default Network Topology
n n n n n
pointtopoint
LAN
using namespace ns;
NSLOGCOMPONENTDEFINESecondScriptExample;
int
mainint argc, char argv
bool verbose true;
uintt nCsma ;
CommandLine cmdFILE;
cmdAddValuenCsma "Number of extra CSMA nodesdevices nCsma;
cmdAddValueverbose "Tell echo applications to log if true", verbose;
cmdParseargc argv;
if verbose
LogComponentEnableUdpEchoClientApplication LOGLEVELINFO;
LogComponentEnableUdpEchoServerApplication LOGLEVELINFO;
nCsma nCsma : nCsma;
NodeContainer ppNodes;
ppNodes.Create;
NodeContainer csmaNodes;
csmaNodes.AddppNodes.Get;
csmaNodes.CreatenCsma;
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttributeDataRate StringValueMbps;
pointToPoint.SetChannelAttributeDelay StringValuems;
NetDeviceContainer ppDevices;
ppDevices pointToPoint.InstallppNodes;
CsmaHelper csma;
csma.SetChannelAttributeDataRate StringValueMbps;
csma.SetChannelAttributeDelay TimeValueNanoSeconds;
NetDeviceContainer csmaDevices;
csmaDevices csma.InstallcsmaNodes;
InternetStackHelper stack;
stack.InstallppNodes.Get;
stack.InstallcsmaNodes;
IpvAddressHelper address;
address.SetBase;
IpvInterfaceContainer ppInterfaces;
ppInterfaces address.AssignppDevices;
address.SetBase;
IpvInterfaceContainer csmaInterfaces;
csmaInterfaces address.AssigncsmaDevices;
UdpEchoServerHelper echoServer;
ApplicationContainer serverApps echoServer.InstallcsmaNodesGetnCsma;
serverApps.StartSeconds;
serverApps.StopSeconds;
UdpEchoClientHelper echoClientcsmaInterfacesGetAddressnCsma;
echoClient.SetAttributeMaxPackets UintegerValue;
echoClient.SetAttributeInterval TimeValueSeconds;
echoClient.SetAttributePacketSize UintegerValue;
ApplicationContainer clientApps echoClient.InstallppNodes.Get;
clientApps.StartSeconds;
clientApps.StopSeconds;
IpvGlobalRoutingHelper::PopulateRoutingTables;
pointToPoint.EnablePcapAllsecond;
csma.EnablePcapsecond csmaDevices.Get true;
Simulator::Run;
Simulator::Destroy;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started