src/dsdv/model/dsdv-routing-protocol.cc
changeset 10933 7442f5603ef4
parent 10652 dc18deba4502
child 10968 2d29fee2b7b8
equal deleted inserted replaced
10932:d5783e5a8b7e 10933:7442f5603ef4
   954     }
   954     }
   955   // Create a socket to listen only on this interface
   955   // Create a socket to listen only on this interface
   956   Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),UdpSocketFactory::GetTypeId ());
   956   Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),UdpSocketFactory::GetTypeId ());
   957   NS_ASSERT (socket != 0);
   957   NS_ASSERT (socket != 0);
   958   socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvDsdv,this));
   958   socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvDsdv,this));
       
   959   socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), DSDV_PORT));
   959   socket->BindToNetDevice (l3->GetNetDevice (i));
   960   socket->BindToNetDevice (l3->GetNetDevice (i));
   960   socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), DSDV_PORT));
       
   961   socket->SetAllowBroadcast (true);
   961   socket->SetAllowBroadcast (true);
   962   socket->SetAttribute ("IpTtl",UintegerValue (1));
   962   socket->SetAttribute ("IpTtl",UintegerValue (1));
   963   m_socketAddresses.insert (std::make_pair (socket,iface));
   963   m_socketAddresses.insert (std::make_pair (socket,iface));
   964   // Add local broadcast record to the routing table
   964   // Add local broadcast record to the routing table
   965   Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
   965   Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
  1011           return;
  1011           return;
  1012         }
  1012         }
  1013       Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),UdpSocketFactory::GetTypeId ());
  1013       Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),UdpSocketFactory::GetTypeId ());
  1014       NS_ASSERT (socket != 0);
  1014       NS_ASSERT (socket != 0);
  1015       socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvDsdv,this));
  1015       socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvDsdv,this));
  1016       socket->BindToNetDevice (l3->GetNetDevice (i));
       
  1017       // Bind to any IP address so that broadcasts can be received
  1016       // Bind to any IP address so that broadcasts can be received
  1018       socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), DSDV_PORT));
  1017       socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), DSDV_PORT));
       
  1018       socket->BindToNetDevice (l3->GetNetDevice (i));
  1019       socket->SetAllowBroadcast (true);
  1019       socket->SetAllowBroadcast (true);
  1020       m_socketAddresses.insert (std::make_pair (socket,iface));
  1020       m_socketAddresses.insert (std::make_pair (socket,iface));
  1021       Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
  1021       Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
  1022       RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (),/*seqno=*/ 0, /*iface=*/ iface,/*hops=*/ 0,
  1022       RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (),/*seqno=*/ 0, /*iface=*/ iface,/*hops=*/ 0,
  1023                                         /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
  1023                                         /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());