Hello,
first at all, thank you very much for your replies, you are being really helpful.
Regarding the ARP theme, the first thing I have tried is to make it work accessing to the ArpCache corresponding to the m_netDevice to which the VirtualLayerNetDevice is attached. Doing this:
m_ifIndex = m_node->GetObject<Ipv4L3Protocol>()->GetInterfaceForDevice(m_netDevice);
if (this->NeedsArp()) {
NS_LOG_INFO("Needs ARP" << " " << dst);
Ptr<ArpL3Protocol> arp = m_node->GetObject<ArpL3Protocol> ();
Address hardwareDestination;
bool found = false;
if (dst.IsBroadcast()) {
NS_LOG_INFO("All-network Broadcast");
hardwareDestination = m_netDevice->GetBroadcast();
found = true;
} else if (dst.IsMulticast()) {
NS_LOG_LOGIC("IsMulticast");
NS_ASSERT_MSG(m_netDevice->IsMulticast(),
"ArpIpv4Interface::SendTo (): Sending multicast packet over "
"non-multicast device");
hardwareDestination = m_netDevice->GetMulticast(dst);
found = true;
} else {
NS_LOG_INFO("ARP Lookup");
found = arp->Lookup(pkt, dst, m_netDevice, m_node->GetObject<Ipv4L3Protocol>()->GetInterface(m_ifIndex)->GetArpCache(), &hardwareDestination);
}
if (found) {
NS_LOG_INFO("Address Resolved: " << hardwareDestination << ", sending...");
m_txTrace(pkt, m_node->GetObject<VirtualLayerNetDevice> (), GetIfIndex());
NS_LOG_DEBUG("VirtualLayerNetDevice::Send " << m_node->GetId() << " " << *pkt);
m_netDevice->Send(pkt, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER);
}
} else {
NS_LOG_LOGIC("Doesn't need ARP");
m_txTrace(pkt, m_node->GetObject<VirtualLayerNetDevice> (), GetIfIndex());
NS_LOG_DEBUG("VirtualLayerNetDevice::Send " << m_node->GetId() << " " << *pkt);
m_netDevice->Send(pkt, m_netDevice->GetBroadcast(), Ipv4L3Protocol::PROT_NUMBER);
}
The program compiles, but when I execute my simulation script and the LookUp() method is called it crashes:
Needs ARP 10.1.1.2
ARP Lookup
Command ['/home/victor/Escritorio/ns-3-allinone/ns-3-dev/build/scratch/wave_ex'] terminated with signal SIGSEGV. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").
I couldn't make it work.
You are in the true when you said that I shouldn't add a dependency between the VNLayer and the IP ARP. But I don't understand what do you refer to exactly when you said: "your own pseudo-ARP at your layer, even defining different interfaces for the IP layer. Otherwise it's not virtual, it's real...".
I have tried to create my own ARP cache doing this:
m_ifIndex = m_node->GetObject<Ipv4L3Protocol>()->GetInterfaceForDevice(m_netDevice);
Ptr<ArpL3Protocol> arp = m_node->GetObject<ArpL3Protocol> ();
m_cache = arp->CreateCache(m_netDevice, m_node->GetObject<Ipv4L3Protocol>()->GetInterface(m_ifIndex));
But this doesn't eliminate the dependency. And using this new ArpCache when I call to the LookUp() function the result is this:
found = arp->Lookup(pkt, dst, m_netDevice, m_cache, &hardwareDestination);
But the result is this:
ARP Lookup
assert failed. cond="i >= 0", msg="No device found on node", file=../src/internet/model/ipv4-l3-protocol.cc, line=1055
terminate called without an active exception
Command ['/home/victor/Escritorio/ns-3-allinone/ns-3-dev/build/scratch/wave_ex'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").
The only solution that I found is sending the MAC address in the header of my VNLayer packets and store it in order to using it when the VNLayer needs to send a packet to a certain IP Address. I think that it could work, but it doesn't seem the best solution.
Could you give me a clue about how to add my own ARP to the VNLayer?
Thanks a lot in advance.
Víctor