I modified the code of the example(ns-allinone-3.19\ns-3.19\src\fd-net-device\examples\fd-tap-ping.cc)
to create a tap0 (ip:192.168.202.1) by using the TapFdNetDeviceHelper.
I also create a node0 (ip:192.168.202.2)
Now i can ping the tap0 and node0 successfully on the PC(eth0: 192.168.203.150)
If i create another tap0 (ip:192.168.202.3) and node1 (ip:192.168.202.4) using the similar way, i ping the tap1
successfully. But i can not connect the node1. How?
In a word, my problem is:
How can a real applications installed on PC connect to node0 and node1 (node0 and node1 are in the same wlan) in NS-3?
I don't understand the TapFdNetDevice.
Any node should install a FdNetDevice if they want to connect to a "real" host?
part of my code:
std::string network ("192.168.202.0");
std::string mask ("255.255.255.0");
Ipv4Address tapNetwork (network.c_str ());
Ipv4Mask tapMask (mask.c_str ());
Ipv4AddressHelper addresses;
addresses.SetBase (tapNetwork, tapMask);
std::string deviceName ("tap0");
TapFdNetDeviceHelper helper;
helper.SetDeviceName (deviceName);
helper.SetModePi (modePi);
NodeContainer nodes;
nodes.Create (2);
Ipv4Address tapIp = addresses.NewAddress ();
helper.SetTapIpv4Address (tapIp);
helper.SetTapIpv4Mask (tapMask);
NetDeviceContainer devices = helper.Install (nodes.Get(0));
Ptr<NetDevice> device = devices.Get (0);
// Add an address to the ns-3 device in the same network than one assigned to the TAP.
Ptr<Ipv4> ipv4 = nodes.Get(0)->GetObject<Ipv4> ();
uint32_t interface = ipv4->AddInterface (device);
Ipv4Address devIp = addresses.NewAddress ();
Ipv4InterfaceAddress address = Ipv4InterfaceAddress (devIp, tapMask);
ipv4->AddAddress (interface, address);
ipv4->SetMetric (interface, 1);
ipv4->SetUp (interface);
////------------------------
std::string deviceName2 ("tap1");
TapFdNetDeviceHelper helper2;
helper2.SetDeviceName (deviceName2);
helper2.SetModePi (modePi);
Ipv4Address tapIp2 = addresses.NewAddress ();
helper2.SetTapIpv4Address (tapIp2);
helper2.SetTapIpv4Mask (tapMask);
NetDeviceContainer devices2 = helper2.Install (nodes.Get(1));
Ptr<NetDevice> device2 = devices2.Get (0);
// Add an address to the ns-3 device in the same network than one assigned to the TAP.
Ptr<Ipv4> ipv42 = nodes.Get(1)->GetObject<Ipv4> ();
uint32_t interface2 = ipv42->AddInterface (device2);
Ipv4Address devIp2 = addresses.NewAddress ();
Ipv4InterfaceAddress address2 = Ipv4InterfaceAddress (devIp2, tapMask);
ipv42->AddAddress (interface2, address2);
ipv42->SetMetric (interface2, 1);
ipv42->SetUp (interface2);