Multi-radios Multi-interface Mesh Network

313 views
Skip to first unread message

Amira Bezzina

unread,
Jan 3, 2011, 1:02:59 PM1/3/11
to ns-3-users
Hi everybody,

I want to modify the mesh.cc script in order to have 2 interfaces for
each node. Each interface will be assigned to a channel between 3
(only 3 channels). I did:

m_nIfaces (2), // number of interfaces per node = 2
m_chan (true),

but I don't know how to deal with the variable m_chan to have 3
channels and do the assignment!
I took a look to mesh-helper and I don't know if I have to change some
instructions in Install method

NetDeviceContainer
MeshHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c)
const
{
NetDeviceContainer devices;
NS_ASSERT (m_stack != 0);
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<Node> node = *i;
// Create a mesh point device
Ptr<MeshPointDevice> mp = CreateObject<MeshPointDevice> ();
node->AddDevice (mp);
// Create wifi interfaces (single interface by default)
for (uint32_t i = 0; i < m_nInterfaces; ++i)
{
uint32_t channel = 0;
if (m_spreadChannelPolicy == ZERO_CHANNEL)
{
channel = 0;
}
if (m_spreadChannelPolicy == SPREAD_CHANNELS)
{
// should I change something here??
channel = i * 5;
}
Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node,
channel);
mp->AddInterface (iface);

}

Thanks in advance for your help.

Amira

Amira Bezzina

unread,
Jan 4, 2011, 3:49:50 PM1/4/11
to ns-3-users
Please, I need some help to assign channels to interfaces in the mesh.cc script.

Best regards,
Amira

2011/1/3 Amira Bezzina <amira....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Pavel Boyko

unread,
Jan 17, 2011, 6:03:24 AM1/17/11
to ns-3-...@googlegroups.com
Hi, Amira,

You can insert the following code sniplet in the mesh.cc anywhere
__after__ line meshDevices = mesh.Install (wifiPhy, nodes) to
re-assign channel numbers:

// loop over all mesh points
for (NetDeviceContainer::Iterator i = meshDevices.Begin(); i !=
meshDevices.End(); ++i)
{
Ptr<MeshPointDevice> mp = DynamicCast<MeshPointDevice>(*i);
NS_ASSERT (mp != 0);
// loop over all interfaces
std::vector<Ptr<NetDevice> > meshInterfaces = mp->GetInterfaces ();

for (std::vector<Ptr<NetDevice> >::iterator j =
meshInterfaces.begin(); j != meshInterfaces.end(); ++j)
{
Ptr<WifiNetDevice> ifdevice = DynamicCast<WifiNetDevice>(*j);
NS_ASSERT (ifdevice != 0);
// access MAC
Ptr<MeshWifiInterfaceMac> ifmac =
DynamicCast<MeshWifiInterfaceMac>(ifdevice->GetMac());
NS_ASSERT (ifmac != 0);
// Access channel number
NS_LOG_UNCOND ("Old channel: " << ifmac->GetFrequencyChannel ());
// Change channel number
uint16_t newChannel = ... // Add your custom channel
assignment here
ifmac->SwitchFrequencyChannel (newChannel);
NS_LOG_UNCOND ("New channel: " << ifmac->GetFrequencyChannel ());
}
}

Good luck with mesh code,
Pavel

Amira Bezzina

unread,
Mar 19, 2011, 7:23:56 PM3/19/11
to ns-3-...@googlegroups.com
Hi Pavel,
First of all thanks for your help.
I modified the code like that:


 for (NetDeviceContainer::Iterator i = meshDevices.Begin(); i != meshDevices.End(); ++i)
 {
         Ptr<MeshPointDevice> mp = DynamicCast<MeshPointDevice>(*i);
         NS_ASSERT (mp != 0);
         // loop over all interfaces
         std::vector<Ptr<NetDevice> > meshInterfaces = mp->GetInterfaces ();

     NS_LOG_UNCOND ("Mesh point ---------");

         for (std::vector<Ptr<NetDevice> >::iterator j = meshInterfaces.begin(); j != meshInterfaces.end(); ++j)
         {
                 Ptr<WifiNetDevice> ifdevice = DynamicCast<WifiNetDevice>(*j);
                 NS_ASSERT (ifdevice != 0);
                 // access MAC
                 Ptr<MeshWifiInterfaceMac> ifmac = DynamicCast<MeshWifiInterfaceMac>(ifdevice->GetMac());
                 NS_ASSERT (ifmac != 0);
                 // Access channel number
                 //NS_LOG_UNCOND ("Old channel: " << ifmac->GetFrequencyChannel ());
         UniformVariable r;
         //Change channel number
         int r1 = r.GetInteger(0,2);
         //to have two different channels for the two interfaces of the node
         if(j != meshInterfaces.begin()){
       
             Ptr<WifiNetDevice> ifdevice1 = DynamicCast<WifiNetDevice>(*(j-1));
             NS_ASSERT (ifdevice1 != 0);
             // access MAC
             Ptr<MeshWifiInterfaceMac> ifmac1 = DynamicCast<MeshWifiInterfaceMac>(ifdevice1->GetMac());
             NS_ASSERT (ifmac1 != 0);
             
             
             while (r1*5 == ifmac1->GetFrequencyChannel ()){
                r1 = r.GetInteger(0,2);
             }
         }
         
                 uint16_t newChannel = r1*5 ; // Add your custom channel assignment here

                 ifmac->SwitchFrequencyChannel (newChannel);
                 NS_LOG_UNCOND ("New channel: " << ifmac->GetFrequencyChannel ());
         }
     
 }

But I have always the same output values of channels assigned to nodes:

Mesh point ---------
New channel: 10
New channel: 0
Mesh point ---------
New channel: 0
New channel: 10
Mesh point ---------
New channel: 0
New channel: 5
Mesh point ---------
New channel: 5
New channel: 10
Mesh point ---------
New channel: 10
New channel: 5
Mesh point ---------
New channel: 0
New channel: 10
Mesh point ---------
New channel: 5
New channel: 10
Mesh point ---------
New channel: 0
New channel: 5
Mesh point ---------
New channel: 5
New channel: 10

I don't find what's wrong with my code, can you help please??

Thanks

Amira

2011/1/17 Pavel Boyko <pavel...@gmail.com>



--
Amira BEZZINA
Ingénieur en informatique
Mastère en Réseaux & Systèmes Multimédia
Equipe RAMSIS - Laboratoire CRISTAL (ENSI, Tunisie)

Pavel Boyko

unread,
Mar 21, 2011, 3:39:05 AM3/21/11
to ns-3-users
Well,

what do you expect to do writing this code? You can start improving
it by moving UniformVariable constructor outside of the loops. Then,
try "--RngRun 2" command line argument to change random "seed".

Good luck,
Pavel
> 2011/1/17 Pavel Boyko <pavel.bo...@gmail.com>
> > On Tue, Jan 4, 2011 at 11:49 PM, Amira Bezzina <amira.bezz...@gmail.com>
> > wrote:
> > > Please, I need some help to assign channels to interfaces in the mesh.cc
> > > script.
>
> > > Best regards,
> > > Amira
>
> > > 2011/1/3 Amira Bezzina <amira.bezz...@gmail.com>

Amira Bezzina

unread,
Mar 21, 2011, 4:49:11 AM3/21/11
to ns-3-...@googlegroups.com
Good morning,

Well I think I have some problems with random variables.. unfortunately,  the manual and doxygen were not so useful for me :)
I want to generate a random int between (0,2) for each channel which have to be different .. 
can you explain more how can I do that??

thanks

Amira

2011/3/21 Pavel Boyko <pavel...@gmail.com>

lara

unread,
Jun 18, 2016, 3:25:33 AM6/18/16
to ns-3-users
Dear Amira,


I am trying to simulate channel assignment in MRMC mesh networks using ns3,
I was googling about available solutions for such problem and I found your question in this group,I know this post is for 5 years ago but may I ask you help me if you have solved this problem and let me to have your codes?
 I am new to ns3 and it will be a great help.

thanks in advance for your help 
Lara
Reply all
Reply to author
Forward
0 new messages