how modify byte buffer in packet ns3

299 views
Skip to first unread message

Belkneni Maroua

unread,
Feb 5, 2014, 5:38:48 AM2/5/14
to ns-3-...@googlegroups.com
hello, I want to invert the bits of a package sent in one wireless networks,Here is my code, please help me  :
#include "ns3/core-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/applications-module.h"
#include "ns3/internet-module.h"
#include "ns3/network-module.h"
#include "ns3/config-store-module.h"

using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("wifiScriptExample");

int main (int argc, char *argv[])
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer wifiNodes;
wifiNodes.Create (3);

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
WifiHelper wifi = WifiHelper::Default ();

NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
wifiMac.SetType("ns3::AdhocWifiMac");
NetDeviceContainer wifiDevices = wifi.Install( wifiPhy, wifiMac, wifiNodes );

MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", 
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiNodes);

InternetStackHelper internet;
internet.Install (wifiNodes);

Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer wifiInterfaces;
wifiInterfaces = address.Assign( wifiDevices );

UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get( 0 ));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (wifiInterfaces.GetAddress (0), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (2));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install ( wifiNodes.Get( 2 ) );
clientApps.Start( Seconds (2.0) );
clientApps.Stop( Seconds (10.0) );

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

Simulator::Stop (Seconds (5.05));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}

Konstantinos

unread,
Feb 5, 2014, 5:50:55 AM2/5/14
to ns-3-...@googlegroups.com
Hi,

You have made a similar question couple of days ago and you got an answer, that you have to use/modify the channel.

Here you are using the default YansWifiChannel:
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

So, I would suggest that you follow the help you are given and if you have a specific question on that, we could help.

You will not modify the packet byte buffer in your scenario script (that is what you posted) but in the channel implementation.

Belkneni Maroua

unread,
Feb 5, 2014, 6:08:57 AM2/5/14
to ns-3-...@googlegroups.com
ok, Thank you for your answer

Belkneni Maroua

unread,
Feb 7, 2014, 5:02:09 AM2/7/14
to ns-3-...@googlegroups.com
hi,I want to eliminate YansWifiChannel by default and to make a cannel by using "simple - channel.cc"  I have not find how to implement it in my code and how to associate the new canal with "wifiphy". here is my code

using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("jdidScriptExample");


int main (int argc, char *argv[])

LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);

NodeContainer wifiNodes;
wifiNodes.Create (3);

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

class SimpleChannel : public Channel
{
public:
  static TypeId GetTypeId (void);
  SimpleChannel ();

  void Send (Ptr<Packet> p, uint16_t protocol, Mac48Address to, Mac48Address from,
         Ptr<SimpleNetDevice> sender);

  void Add (Ptr<SimpleNetDevice> device);

  // inherited from ns3::Channel
  virtual uint32_t GetNDevices (void) const;
  virtual Ptr<NetDevice> GetDevice (uint32_t i) const;

private:
  std::vector<Ptr<SimpleNetDevice> > m_devices;
};

/*wifiPhy.SetChannel (SimpleChannel);*/
Reply all
Reply to author
Forward
0 new messages