Created
May 3, 2015 00:17
-
-
Save thehajime/26be8606ddbb924f357c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ns3/network-module.h" | |
#include "ns3/core-module.h" | |
#include "ns3/internet-module.h" | |
#include "ns3/dce-module.h" | |
#include "ns3/point-to-point-module.h" | |
#include "ns3/csma-module.h" | |
#include "ns3/applications-module.h" | |
using namespace ns3; | |
// =========================================================================== | |
// | |
// node 0 node 1 | |
// +----------------+ +----------------+ | |
// | | | | | |
// +----------------+ +----------------+ | |
// | 2001:1::1 | | 2001:1::2 | | |
// +----------------+ +----------------+ | |
// | point-to-point | | point-to-point | | |
// +----------------+ +----------------+ | |
// | | | |
// +---------------------+ | |
// 5 Mbps, 1 ms | |
// | |
// Just a ping ! | |
// =========================================================================== | |
int main (int argc, char *argv[]) | |
{ | |
CommandLine cmd; | |
cmd.Parse (argc, argv); | |
NodeContainer nodes; | |
Ptr<Node> node1 = CreateObject<Node> (0); | |
Ptr<Node> node2 = CreateObject<Node> (1); | |
nodes.Add (node1); | |
nodes.Add (node2); | |
PointToPointHelper pointToPoint; | |
CsmaHelper csma; | |
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); | |
pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms")); | |
NetDeviceContainer devices; | |
devices = pointToPoint.Install (nodes); | |
DceManagerHelper dceManager; | |
dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so")); | |
LinuxStackHelper::RunIp (nodes.Get (0), Seconds (0.2), "-6 addr add 2001:1::1/64 dev sim0"); | |
LinuxStackHelper::RunIp (nodes.Get (0), Seconds (0.2), "link set sim0 up arp off"); | |
LinuxStackHelper::RunIp (nodes.Get (1), Seconds (0.2), "-6 addr add 2001:1::2/64 dev sim0"); | |
LinuxStackHelper::RunIp (nodes.Get (1), Seconds (0.4), "link set sim0 up arp off"); | |
dceManager.Install (nodes); | |
DceApplicationHelper dce; | |
ApplicationContainer apps; | |
dce.SetStackSize (1 << 20); | |
// Launch ping on node 0 | |
dce.SetBinary ("ping6"); | |
dce.ResetArguments (); | |
dce.ResetEnvironment (); | |
dce.AddArgument ("-c 10"); | |
dce.AddArgument ("-s 1000"); | |
dce.AddArgument ("2001:1::2"); | |
apps = dce.Install (node1); | |
apps.Start (Seconds (1.0)); | |
pointToPoint.EnablePcapAll ("dce-ping6"); | |
LinuxStackHelper::RunIp (nodes.Get (0), Seconds (2.0), "link"); | |
LinuxStackHelper::RunIp (nodes.Get (0), Seconds (2.0), "-6 a"); | |
LinuxStackHelper::RunIp (nodes.Get (0), Seconds (2.0), "-6 r show"); | |
LinuxStackHelper::RunIp (nodes.Get (1), Seconds (2.0), "link"); | |
LinuxStackHelper::RunIp (nodes.Get (1), Seconds (2.0), "-6 a"); | |
LinuxStackHelper::RunIp (nodes.Get (1), Seconds (2.0), "-6 r show"); | |
Simulator::Stop (Seconds (40.0)); | |
Simulator::Run (); | |
Simulator::Destroy (); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment