m_node->RegisterProtocolHandler (MakeCallback (&SixLowPanNetDevice::ReceiveFromDevice, this), protocolType, device, false);
Ptr<ns3::dsr::DsrRouting> DsrHelper::Create (Ptr<Node> node) const
{
NS_LOG_FUNCTION (this);
Ptr<ns3::dsr::DsrRouting> agent = m_agentFactory.Create<ns3::dsr::DsrRouting> ();
// deal with the downtargets, install UdpL4Protocol, TcpL4Protocol, Icmpv4L4Protocol
Ptr<UdpL4Protocol> udp = node->GetObject<UdpL4Protocol> ();
agent->SetDownTarget (udp->GetDownTarget ());
udp->SetDownTarget (MakeCallback (&dsr::DsrRouting::Send, agent));
Ptr<TcpL4Protocol> tcp = node->GetObject<TcpL4Protocol> ();
tcp->SetDownTarget (MakeCallback (&dsr::DsrRouting::Send, agent));
Ptr<Icmpv4L4Protocol> icmp = node->GetObject<Icmpv4L4Protocol> ();
icmp->SetDownTarget (MakeCallback (&dsr::DsrRouting::Send, agent));
node->AggregateObject (agent);
return agent;
}
void DsrRouting::NotifyNewAggregate ()
{
NS_LOG_FUNCTION (this << "NotifyNewAggregate");
if (m_node == 0)
{
Ptr<Node> node = this->GetObject<Node> ();
if (node != 0)
{
m_ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (m_ipv4 != 0)
{
this->SetNode (node);
m_ipv4->Insert (this);
this->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, m_ipv4));
}
m_ip = node->GetObject<Ipv4> ();
if (m_ip != 0)
{
NS_LOG_DEBUG ("Ipv4 started");
}
}
}
IpL4Protocol::NotifyNewAggregate ();
Simulator::ScheduleNow (&DsrRouting::Start, this);
}
m_ipV4->TraceConnectWithoutContext("MpTx", MakeCallback(&MpTransmissionProtocol::SendMpPacket, this));
Ipv4L3Protocol::Send(Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route)
{
m_mpTxTrace(packet, destination);
NS_LOG_FUNCTION(this << packet << source << destination << uint32_t (protocol) << route);
Ipv4Header ipHeader;
Ptr<TcpL4Protocol> tcp = nodes.Get(0)->GetObject<TcpL4Protocol>();
Ptr<Ipv4> ipv4 = nodes.Get(0)->GetObject<Ipv4>();tcp->SetDownTarget(MakeBoundCallback(&NewDownTagetCb, ipv4));
tcp->SetDownTarget(MakeBoundCallback(&NewDownTagetCb, ipv4));
void NewDownTagetCb(Ptr<Ipv4> ipv4, Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route)
{
//Do Something here
ipv4->Send(packet, source, destination, protocol, route);
}