3
3
h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/netanim-module.h"
#include "ns3/flow-monitor-module.h"
NS_LOG_COMPONENT_DEFINE ("StarTopologyBroadcastExample");
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer nodes;
nodes.Create (8);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
NetDeviceContainer devices[7];
for (int i = 0; i < 7; ++i) {
devices[i] = pointToPoint.Install(nodes.Get(0), nodes.Get(i + 1));
}
InternetStackHelper stack;
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces[7];
for (int i = 0; i < 7; ++i) {
interfaces[i] = address.Assign(devices[i]);
}
AnimationInterface anim("output/star_topology_broadcast.xml");
anim.SetConstantPosition(nodes.Get(0), 300, 300);
AsciiTraceHelper ascii;
pointToPoint.EnableAsciiAll(ascii.CreateFileStream("trace.tr"));
Simulator::Run();
Simulator::Destroy();
return 0;
}
Dontpad uses cookies and similar technologies to improve your experience and to
show you more relevant ads, according to our cookie policy. By clicking 'Accept'
you are indicating that you have read and that you accept our Cookie Policy,
Privacy Policy and Content Policy.
Accept