OLSR in multi-interface

90 views
Skip to first unread message

yirui huang

unread,
Jan 8, 2020, 2:31:56 AM1/8/20
to ns-3-users
Hi !
I'm new to ns-3. Recently I am studying the OLSR protocol. In my simulation scenario, each node have two wifi interface, one for typology control message (such as Hello message and TC message in OLSR) and the second interface is used to send/receive the normal message (UDP packet) with an directional antenna. But here is my problem, when I installed the OLSR in nodes, all interfaces will transmit OLSR packet (Hello and TC). So how do I use these two interfaces separately ?
Thanks !

Here is part of my code and the directional antenna is not installed

    NodeContainer Nodes;
    Nodes.Create(nWifi);

    WifiHelper wifi;
    
    WifiMacHelper mac;
    mac.SetType("ns3::AdhocWifiMac");

    YansWifiChannelHelper channel;// = YansWifiChannelHelper::Default();
    channel.AddPropagationLoss("ns3::RangePropagationLossModel","MaxRange",DoubleValue(100));
    channel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
    YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
    phy.SetChannel(channel.Create());

    //first netdevice
    NetDeviceContainer AdhocDevices = wifi.Install(phy,mac,Nodes);

    //second netdevice
    //mac.SetType("ns3::AdhocWifiMac");
    YansWifiChannelHelper channel2;
    YansWifiPhyHelper phy2 = YansWifiPhyHelper::Default ();
    channel2.AddPropagationLoss("ns3::RangePropagationLossModel","MaxRange",DoubleValue(100));
    channel2.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
    phy2.SetChannel(channel2.Create());
    NetDeviceContainer secondDevices = wifi.Install(phy2,mac,Nodes);

    //mobility model
    /* ... */

    //routing protocol
    OlsrHelper olsr;
    Ipv4StaticRoutingHelper staticRouting;
    Ipv4ListRoutingHelper list;
    list.Add (staticRouting, 0);
    list.Add (olsr, 10);

    InternetStackHelper stack;
    stack.SetRoutingHelper(list);
    stack.Install(Nodes);

    //first interface
    Ipv4AddressHelper address;
    address.SetBase ("10.1.1.0", "255.255.255.0");
    Ipv4InterfaceContainer interface1;
    interface1 =  address.Assign (AdhocDevices);

    //second interface
    address.SetBase ("10.1.2.0", "255.255.255.0");
    Ipv4InterfaceContainer interface2;
    interface2 = address.Assign (secondDevices);

    Simulator::Stop (Seconds (30.0));

    OnOffHelper onoff1 ("ns3::UdpSocketFactory",InetSocketAddress (interface2.GetAddress (nWifi-1), 9));
    onoff1.SetConstantRate (DataRate("10kbps"));
    onoff1.SetAttribute("OffTime",StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
    onoff1.SetAttribute("PacketSize",UintegerValue(512));

    ApplicationContainer onOffApp1 = onoff1.Install (Nodes.Get (0));
    
    onOffApp1.Start (Seconds(0));
    onOffApp1.Stop (Seconds (30.0));

    PacketSinkHelper sink ("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), 9));
    NodeContainer sinks = NodeContainer (Nodes.Get (nWifi-1));
    ApplicationContainer sinkApps = sink.Install (sinks);
    sinkApps.Start (Seconds(0));
    sinkApps.Stop (Seconds (30.0));


Message has been deleted

Hassam Mughal

unread,
Mar 6, 2020, 4:14:48 AM3/6/20
to ns-3-users
Try using only internet stack helper at first, instead of this;
    OlsrHelper olsr;
    Ipv4StaticRoutingHelper staticRouting;
    Ipv4ListRoutingHelper list;
    list.Add (staticRouting, 0);
    list.Add (olsr, 10);
Just use this:
InternetStackHelper stack;
stack
.install(Nodes);

You will need to modify the routing protocol to get the desired packets at the desired interface. I am facing the same problem with DSDV.
Reply all
Reply to author
Forward
0 new messages