
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));
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.
--
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.
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)
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/130af2fe-e657-4faf-b7bc-abf327c1ec68n%40googlegroups.com.