two pc ns3 node communication problem

97 views
Skip to first unread message

Harry Q

unread,
Jul 4, 2023, 3:33:17 AM7/4/23
to ns-3-users
Hi all, I'm trying to use fdnetdevice to enable ns3 nodes in two computers to communicate with each other. I have referred to ARP request the IP of other subnet (google.com)  According to this post, I can ping the node in ns3 with fdnetdevice from a real pc.  However, the following issues occurred:
Only FD devices in the NS3 of the two hosts can communicate with each other (192.168.1.3 → 192.168.1.5), but PPP devices in the NS3 of the two hosts cannot communicate with each other (10.1.1.1 → 10.1.2.2). Our network configuration and source code are shown in the following.
批注 2023-07-04 152811.png

NodeContainer p2pNodes;

   p2pNodes.Create (2);

  PointToPointHelper pointToPoint;

  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));

  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

  NetDeviceContainer p2pDevices;

  p2pDevices = pointToPoint.Install (p2pNodes);

  NodeContainer fdNodes;

  fdNodes.Add (p2pNodes.Get (0));

   p2pDevices.Get(1)->SetAttribute("Address", localMac);

   p2pDevices.Get(0)->SetAttribute("Address", PcenterMac);

   NS_LOG_INFO("Create Device");

   EmuFdNetDeviceHelper emu;

   emu.SetDeviceName(fddeviceName);

   NetDeviceContainer devices = emu.Install(fdNodes);

   Ptr<NetDevice> device = devices.Get(0);

   device->SetAttribute("Address", fdcenterMac);

  OlsrHelper olsr;

  Ipv4StaticRoutingHelper staticRouting;

  Ipv4ListRoutingHelper list;

  list.Add (staticRouting, 0);

  list.Add (olsr, 10);  

   NS_LOG_INFO("Add Internet Stack");

   InternetStackHelper internetStackHelper;

   internetStackHelper.SetIpv4StackInstall(true);

   internetStackHelper.Install(p2pNodes);

   Ipv4AddressHelper address;

   address.SetBase ("10.1.1.0", "255.255.255.0");

   Ipv4InterfaceContainer p2pInterfaces;

   p2pInterfaces = address.Assign (p2pDevices);

   address.SetBase ("192.168.1.0", "255.255.255.0","0.0.0.3");

   Ipv4InterfaceContainer fdInterfaces;

   fdInterfaces = address.Assign (device);

   AddressValue remoteAddress(InetSocketAddress(remoteIp, sinkPort));//10.1.2.2:9000

   OnOffHelper onoff("ns3::UdpSocketFactory", Address());

   onoff.SetAttribute("Remote", remoteAddress);

   onoff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));

   onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));

   onoff.SetAttribute("DataRate", DataRateValue(dataRate));

   onoff.SetAttribute("UnchangePacketSize", UintegerValue(packetSize));

   ApplicationContainer clientApps = onoff.Install(p2pNodes.Get(1));



Message has been deleted

igs...@gmail.com

unread,
Jul 4, 2023, 3:50:24 AM7/4/23
to ns-3-users

What about the Gateway IP address that you configured in the emulated devices?

Charles Pandian,

Harry Q

unread,
Jul 4, 2023, 3:58:52 AM7/4/23
to ns-3-users

Hello Charles, thanks for your replay. As shown in the code, I only set the IP and subnet mask for the network devices in ns3, as I have no idea how to set the gateway for them, so I did not set them up. I’m new to ns3. I would be very happy if you could tell me how to set up a gateway in ns3.

Charles Pandian

unread,
Jul 4, 2023, 6:03:39 AM7/4/23
to ns-3-...@googlegroups.com
Check the official example fd-emu-ping.cc.
......
main(int argc, char* argv[])
{
    NS_LOG_INFO("Ping Emulation Example");

    std::string deviceName("eth0");
    std::string remote("8.8.8.8");
    std::string localAddress("1.2.3.4");
    std::string localGateway("1.2.3.4");
#ifdef HAVE_PACKET_H
.....

Set it according to your network configuration.



Charles Pandian,



--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/bba89ef0-2b54-4f95-8b72-f725aab1e52en%40googlegroups.com.

Harry Q

unread,
Jul 5, 2023, 4:20:45 AM7/5/23
to ns-3-users

Hi Charles, thanks for your key suggestions. TCP communication between 10.1.1.1 and 10.1.2.2 is now possible. 

My gateway configuration is as follows:

The left fd node setting is (gw: 192.168.1.255, interface: 192.168.1.3) and the right fd node setting is (gw: 192.168.1.255, interface: 192.168.1.5)

Charles Pandian

unread,
Jul 5, 2023, 7:48:31 AM7/5/23
to ns-3-...@googlegroups.com
Hello Harry,

Happy to know that you resolved the issue.
Thanks for sharing it. That information will be very helpful to others.
Charles Pandian,



Reply all
Reply to author
Forward
0 new messages