tcpdump: Can't open raw Bluetooth socket: Invalid argument
#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/applications-module.h"
#include "ns3/netanim-module.h"
#include "ns3/constant-position-mobility-model.h"
#ifdef DCE_MPI
#include "ns3/mpi-interface.h"
#endif
using namespace ns3;
void setPos (Ptr<Node> n, int x, int y, int z)
{
Ptr<ConstantPositionMobilityModel> loc = CreateObject<ConstantPositionMobilityModel> ();
n->AggregateObject (loc);
Vector locVec2 (x, y, z);
loc->SetPosition (locVec2);
}
void RunIp (Ptr<Node> node, Time at, std::string str)
{
DceApplicationHelper process;
ApplicationContainer apps;
process.SetBinary ("ip");
process.SetStackSize (1 << 16);
process.ResetArguments ();
process.ParseArguments (str.c_str ());
apps = process.Install (node);
apps.Start (at);
}
void AddAddress (Ptr<Node> node, Time at, const char *name, const char *address)
{
std::ostringstream oss;
oss << "-f inet addr add " << address << " dev " << name;
RunIp (node, at, oss.str ());
}
std::string Ipv4AddressToString (Ipv4Address ad)
{
std::ostringstream oss;
ad.Print (oss);
return oss.str ();
}
int main (int argc, char *argv[])
{
uint32_t systemId = 0;
uint32_t systemCount = 1;
#ifdef DCE_MPI
// Distributed simulation setup
MpiInterface::Enable (&argc, &argv);
GlobalValue::Bind ("SimulatorImplementationType",
StringValue ("ns3::DistributedSimulatorImpl"));
systemId = MpiInterface::GetSystemId ();
systemCount = MpiInterface::GetSize ();
#endif
std::string animFile = "NetAnim.xml";
NodeContainer nodes;
Ptr<Node> node1 = CreateObject<Node> (0 % systemCount); // Create node1 with system id 0
Ptr<Node> node2 = CreateObject<Node> (1 % systemCount); // Create node2 with system id 1
nodes.Add (node1);
nodes.Add (node2);
PointToPointHelper pointToPoint;
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 stack;
Ipv4DceRoutingHelper ipv4RoutingHelper;
stack.SetRoutingHelper (ipv4RoutingHelper);
stack.Install (nodes);
AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "10.1.1.1/8");
RunIp (nodes.Get (0), Seconds (0.2), "link set sim0 up arp off");
AddAddress (nodes.Get (1), Seconds (0.3), "sim0","10.1.1.2/8");
RunIp (nodes.Get (1), Seconds (0.4), "link set sim0 up arp off");
dceManager.Install (nodes);
DceApplicationHelper dce;
ApplicationContainer apps;
dce.SetStackSize (1 << 20);
if ( systemId == node1->GetSystemId () )
{
// Launch ping on node 0
dce.SetBinary ("tcpdump");
dce.ResetArguments ();
dce.ResetEnvironment ();
dce.AddArgument ("-Nn");
//dce.AddArgument ("-b ip");
dce.AddArgument ("-tttt");
apps = dce.Install (node1);
apps.Start (Seconds (1.0));
}
if ( systemId == node2->GetSystemId ())
{
// Launch ping on node 1
dce.SetBinary ("ping");
dce.ResetArguments ();
dce.ResetEnvironment ();
dce.AddArgument ("-c 10");
dce.AddArgument ("-s 1000");
dce.AddArgument ("10.1.1.1");
apps = dce.Install (node2);
apps.Start (Seconds (1.5));
}
setPos (nodes.Get (0), 1, 10, 0);
setPos (nodes.Get (1), 50,10, 0);
// Create the animation object and configure for specified output
AnimationInterface anim (animFile);
//anim.StartAnimation ();
Simulator::Stop (Seconds (40.0));
Simulator::Run ();
Simulator::Destroy ();
#ifdef DCE_MPI
MpiInterface::Disable ();
#endif
return 0;
}
#ifndef SCRATCH_MY_NS3_PACKET_H_#define SCRATCH_MY_NS3_PACKET_H_
#include "ns3/object.h"#include "ns3/ipv4-address.h"
class MyNS3Packet : public ns3::Object{private: ns3::Ipv4Address src; int appSrcPort; ns3::Ipv4Address dst; int appDstPort; std::string msg;
public: MyNS3Packet(ns3::Ipv4Address src, int appSrcPort, ns3::Ipv4Address dst, int appDstPort, std::string msg); MyNS3Packet(); virtual ~MyNS3Packet(); ns3::Ipv4Address getSrc() const; void setSrc(ns3::Ipv4Address src); ns3::Ipv4Address getDst() const; void setDst(ns3::Ipv4Address dst); const std::string getMsg() const; void setMsg(const std::string msg); const std::string serialize(); static ns3::Ptr<MyNS3Packet> parse(std::string str); int getAppDstPort() const; void setAppDstPort(int appDstPort); int getAppSrcPort() const; void setAppSrcPort(int appSrcPort); const int getPktSize() const;};
#endif