diff --git a/examples/aodv2.cc b/examples/aodv2.cc index 78bea147f..d0eb29ecc 100644 --- a/examples/aodv2.cc +++ b/examples/aodv2.cc @@ -195,6 +195,7 @@ AodvExample::InstallInternetStack () stack.Install (nodes); Ipv4AddressHelper address; address.SetBase ("10.0.0.0", "255.0.0.0"); + interfaces1 = address.Assign (devices1); interfaces2 = address.Assign (devices2); diff --git a/src/internet-stack/ipv4-interface.cc b/src/internet-stack/ipv4-interface.cc index 15b957611..b1aeb61d8 100644 --- a/src/internet-stack/ipv4-interface.cc +++ b/src/internet-stack/ipv4-interface.cc @@ -178,7 +178,7 @@ Ipv4Interface::SetForwarding (bool val) void Ipv4Interface::Send (Ptr p, Ipv4Address dest) { - NS_LOG_UNCOND (dest << *p); + NS_LOG_LOGIC (dest << *p); if (!IsUp()) { return; @@ -188,7 +188,7 @@ Ipv4Interface::Send (Ptr p, Ipv4Address dest) { // XXX additional checks needed here (such as whether multicast // goes to loopback)? - NS_LOG_UNCOND ("Ipv4Interface::Send loopback"); + NS_LOG_LOGIC ("Ipv4Interface::Send loopback"); m_device->Send (p, m_device->GetBroadcast (), Ipv4L3Protocol::PROT_NUMBER); return; @@ -198,7 +198,7 @@ Ipv4Interface::Send (Ptr p, Ipv4Address dest) { if (dest == (*i).GetLocal ()) { - NS_LOG_UNCOND ("to local"); + NS_LOG_LOGIC ("to local"); Ptr ipv4 = m_node->GetObject (); ipv4->Receive (m_device, p, Ipv4L3Protocol::PROT_NUMBER, @@ -211,19 +211,19 @@ Ipv4Interface::Send (Ptr p, Ipv4Address dest) } if (m_device->NeedsArp ()) { - NS_LOG_UNCOND ("Needs ARP" << " " << dest); + NS_LOG_LOGIC ("Needs ARP" << " " << dest); Ptr arp = m_node->GetObject (); Address hardwareDestination; bool found = false; if (dest.IsBroadcast ()) { - NS_LOG_UNCOND ("All-network Broadcast"); + NS_LOG_LOGIC ("All-network Broadcast"); hardwareDestination = m_device->GetBroadcast (); found = true; } else if (dest.IsMulticast ()) { - NS_LOG_UNCOND ("IsMulticast"); + NS_LOG_LOGIC ("IsMulticast"); NS_ASSERT_MSG(m_device->IsMulticast (), "ArpIpv4Interface::SendTo (): Sending multicast packet over " "non-multicast device"); @@ -237,7 +237,7 @@ Ipv4Interface::Send (Ptr p, Ipv4Address dest) { if (dest.IsSubnetDirectedBroadcast ((*i).GetMask ())) { - NS_LOG_UNCOND ("Subnetwork Broadcast hardwareDestination " << hardwareDestination); + NS_LOG_LOGIC ("Subnetwork Broadcast hardwareDestination " << hardwareDestination); hardwareDestination = m_device->GetBroadcast (); found = true; break; @@ -245,21 +245,21 @@ Ipv4Interface::Send (Ptr p, Ipv4Address dest) } if (!found) { - NS_LOG_UNCOND ("ARP Lookup"); + NS_LOG_LOGIC ("ARP Lookup"); found = arp->Lookup (p, dest, m_device, m_cache, &hardwareDestination); } } if (found) { - NS_LOG_UNCOND ("Address Resolved. Send."); + NS_LOG_LOGIC ("Address Resolved. Send."); m_device ->Send (p, hardwareDestination, Ipv4L3Protocol::PROT_NUMBER); } } else { - NS_LOG_UNCOND ("Doesn't need ARP"); + NS_LOG_LOGIC ("Doesn't need ARP"); m_device->Send (p, m_device->GetBroadcast (), Ipv4L3Protocol::PROT_NUMBER); } diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index e521be431..620bb96bd 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -390,9 +390,9 @@ void Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { - NS_LOG_UNCOND ("Ipv4L3Protocol::Receive" << &device << p << protocol << from); + NS_LOG_FUNCTION (this << &device << p << protocol << from); - NS_LOG_UNCOND ("Packet from " << from << " received on node " << + NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); uint32_t interface = 0; @@ -430,7 +430,7 @@ Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t pr if (!ipHeader.IsChecksumOk ()) { - NS_LOG_UNCOND("bad check sum"); + NS_LOG_LOGIC("bad check sum"); m_dropTrace (packet); return; } diff --git a/src/internet-stack/raw-socket-impl.cc b/src/internet-stack/raw-socket-impl.cc index 1666f5ca7..6f620fb4f 100644 --- a/src/internet-stack/raw-socket-impl.cc +++ b/src/internet-stack/raw-socket-impl.cc @@ -253,25 +253,25 @@ RawSocketImpl::SendByInterface (Ptr p, Ptr route) // with a valid Ipv4Address as the gateway if (route && route->GetGateway () != Ipv4Address ()) { - NS_LOG_UNCOND ("RawSocketImpl::Send case 3: passed in with route"); + NS_LOG_LOGIC ("RawSocketImpl::Send case 3: passed in with route"); Ptr outDev = route->GetOutputDevice (); int32_t interface = m_ipv4->GetInterfaceForDevice (outDev); NS_ASSERT (interface >= 0); Ptr outInterface = m_ipv4->GetInterface (interface); - NS_LOG_UNCOND ("Send via NetDevice ifIndex " << outDev->GetIfIndex () << " ipv4InterfaceIndex " << interface); + NS_LOG_LOGIC ("Send via NetDevice ifIndex " << outDev->GetIfIndex () << " ipv4InterfaceIndex " << interface); NS_ASSERT (p->GetSize () <= outInterface->GetDevice ()->GetMtu ()); if (!route->GetGateway ().IsEqual (Ipv4Address ("0.0.0.0"))) { if (outInterface->IsUp ()) { - NS_LOG_UNCOND ("Send to gateway " << route->GetGateway ()); + NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ()); Ptr packetCopy = p->Copy (); outInterface->Send (packetCopy, route->GetGateway ()); } else { - NS_LOG_UNCOND ("Dropping-- outgoing interface is down: " << route->GetGateway ()); + NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetGateway ()); } } else @@ -279,12 +279,12 @@ RawSocketImpl::SendByInterface (Ptr p, Ptr route) if (outInterface->IsUp ()) { Ptr packetCopy = p->Copy (); - NS_LOG_UNCOND ("Send to destination " << destination); + NS_LOG_LOGIC ("Send to destination " << destination); outInterface->Send (packetCopy, destination); } else { - NS_LOG_UNCOND ("Dropping-- outgoing interface is down: " << destination); + NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << destination); } } return; } @@ -304,14 +304,14 @@ RawSocketImpl::GetRxAvailable (void) const Ptr RawSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { - NS_LOG_UNCOND ("RawSocketImpl::Recv" << maxSize << flags); + NS_LOG_LOGIC ("RawSocketImpl::Recv" << maxSize << flags); Address tmp; return RecvFrom (maxSize, flags, tmp); } Ptr RawSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress) { - NS_LOG_UNCOND ("RawSocketImpl::RecvFrom" << " maxSize " << maxSize << " flags " << flags << " address " < HELLO_INTERVAL) DELETE_PERIOD = Scalar(5) * ACTIVE_ROUTE_TIMEOUT; @@ -190,17 +192,52 @@ RoutingProtocol::RoutingProtocol () : TypeId RoutingProtocol::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::aodv::RoutingProtocol") .SetParent () .AddConstructor () .AddAttribute ( - "HelloInterval", "HELLO messages emission interval.", TimeValue (Seconds (1)), MakeTimeAccessor (&RoutingProtocol::HELLO_INTERVAL), - MakeTimeChecker ()) .AddAttribute ("Broadcast id save", "Broadcast id save interval.", TimeValue (Seconds (6)), MakeTimeAccessor ( - &RoutingProtocol::BCAST_ID_SAVE), MakeTimeChecker ()) .AddAttribute ("RreqRetries", - "Maximum number of retransmissions of RREQ to discover a route", UintegerValue (2), MakeUintegerAccessor (&RoutingProtocol::RREQ_RETRIES), - MakeUintegerChecker ()) .AddAttribute ("NodeTraversalTime", - "Conservative estimate of the average one hop traversal time for packets and should include" - "queuing delays, interrupt processing times and transfer times.", TimeValue (MilliSeconds (40)), MakeTimeAccessor ( - &RoutingProtocol::NODE_TRAVERSAL_TIME), MakeTimeChecker ()) .AddAttribute ("ActiveRouteTimeout", - "Period of time during which the route is considered to be valid", TimeValue (Seconds (3)), MakeTimeAccessor ( - &RoutingProtocol::ACTIVE_ROUTE_TIMEOUT), MakeTimeChecker ()) + static TypeId tid = TypeId ("ns3::aodv::RoutingProtocol") + .SetParent () + .AddConstructor () + .AddAttribute ("HelloInterval", "HELLO messages emission interval.", + TimeValue (Seconds (1)), + MakeTimeAccessor (&RoutingProtocol::HELLO_INTERVAL), + MakeTimeChecker ()) +// .AddAttribute ("Broadcast id save", "Broadcast id save interval.", +// TimeValue (Seconds (6)), +// MakeTimeAccessor (&RoutingProtocol::BCAST_ID_SAVE), +// MakeTimeChecker ()) + .AddAttribute ("RreqRetries", "Maximum number of retransmissions of RREQ to discover a route", + UintegerValue (2), + MakeUintegerAccessor (&RoutingProtocol::RREQ_RETRIES), + MakeUintegerChecker ()) + .AddAttribute ("NodeTraversalTime", "Conservative estimate of the average one hop traversal time for packets and should include" + "queuing delays, interrupt processing times and transfer times.", + TimeValue (MilliSeconds (40)), + MakeTimeAccessor (&RoutingProtocol::NODE_TRAVERSAL_TIME), + MakeTimeChecker ()) + .AddAttribute ("ActiveRouteTimeout", "Period of time during which the route is considered to be valid", + TimeValue (Seconds (3)), + MakeTimeAccessor (&RoutingProtocol::ACTIVE_ROUTE_TIMEOUT), + MakeTimeChecker ()) + .AddAttribute ("MaxQueueTime", "Maximum time packets can be queued (in seconds)", + TimeValue (Seconds (30)), + MakeTimeAccessor (&RoutingProtocol::MAX_QUEUE_TIME), + MakeTimeChecker ()) + .AddAttribute ("NetDiameter", "Net diameter measures the maximum possible number of hops between two nodes in the network", + UintegerValue (35), + MakeUintegerAccessor (&RoutingProtocol::NET_DIAMETER), + MakeUintegerChecker ()) + .AddAttribute ("TtlStart", "Initial value of TTL in RREQ when use an expanding ring search " + "(should be set to at least 2 if Hello messages are used for local connectivity information.)", + UintegerValue (1), + MakeUintegerAccessor (&RoutingProtocol::TTL_START), + MakeUintegerChecker ()) + .AddAttribute ("TtlIncrement", "Increment value of RREQ TTL when use an expanding ring search", + UintegerValue (2), + MakeUintegerAccessor (&RoutingProtocol::TTL_INCREMENT), + MakeUintegerChecker ()) + .AddAttribute ("TtlThreshold", "Threshold, beyond which TTL = NET_DIAMETER is used for each attempt in RREQ.", + UintegerValue (7), + MakeUintegerAccessor (&RoutingProtocol::TTL_THRESHOLD), + MakeUintegerChecker ()) + ; return tid; @@ -270,7 +307,6 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t bool result = m_routingTable.LookupRoute (dst, rt); if (result && (rt.GetFlag () == RTF_UP)) { - m_routingTable.Print (std::cout); route = rt.GetRoute (); NS_ASSERT (route != 0); sockerr = Socket::ERROR_NOTERROR; @@ -370,10 +406,10 @@ RoutingProtocol::RouteInput (Ptr p, const Ipv4Header &header, Ptr< } - QueueEntry newEntry (p, header, ucb, ecb, RTQ_TIMEOUT); + QueueEntry newEntry (p, header, ucb, ecb, MAX_QUEUE_TIME); m_queue.Enqueue (newEntry); NS_LOG_LOGIC("route not found to "<< dst); - m_routingTable.Print (std::cout); + // m_routingTable.Print (std::cout); return false; } @@ -754,7 +790,7 @@ RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry con RrepHeader rrepHeader ( /*prefixSize=*/0, /*hops=*/toOrigin.GetHop (), /*dst=*/rreqHeader.GetDst (), /*dstSeqNo=*/m_seqNo, /*origin=*/toOrigin.GetDestination (), /*lifeTime=*/MY_ROUTE_TIMEOUT); // TODO when?? - rrepHeader.SetAckRequired(true); +// rrepHeader.SetAckRequired(true); RoutingTableEntry toNextHop; m_routingTable.LookupRoute(toOrigin.GetNextHop (), toNextHop); toNextHop.m_ackTimer.SetFunction(&RoutingProtocol::AckTimerExpire, this); diff --git a/src/routing/aodv/aodv-routing-protocol.h b/src/routing/aodv/aodv-routing-protocol.h index cca7a3d4d..3bee9ccad 100644 --- a/src/routing/aodv/aodv-routing-protocol.h +++ b/src/routing/aodv/aodv-routing-protocol.h @@ -78,13 +78,13 @@ private: ///\name Protocol parameters. TODO document //\{ - // Time AODV_RTQ_TIMEOUT; - Time RTQ_TIMEOUT; + Time MAX_QUEUE_TIME; uint32_t RREQ_RETRIES; // 2 Time ACTIVE_ROUTE_TIMEOUT; // 3 seconds Time MY_ROUTE_TIMEOUT; // 2 * ACTIVE_ROUTE_TIMEOUT uint16_t NET_DIAMETER; Time NODE_TRAVERSAL_TIME; // 40 milliseconds + Time NET_TRAVERSAL_TIME; // 2 * NODE_TRAVERSAL_TIME * NET_DIAMETER Time BCAST_ID_SAVE; Time HELLO_INTERVAL; uint32_t ALLOWED_HELLO_LOSS; @@ -92,9 +92,11 @@ private: Time MaxHelloInterval; // (1.25 * HELLO_INTERVAL) Time MinHelloInterval; // (0.75 * HELLO_INTERVAL) Time FREQUENCY; - Time NET_TRAVERSAL_TIME; // 2 * NODE_TRAVERSAL_TIME * NET_DIAMETER Time BLACKLIST_TIMEOUT; Time NEXT_HOP_WAIT; + uint16_t TTL_START; + uint16_t TTL_INCREMENT; + uint16_t TTL_THRESHOLD; //\} /// \name Handle Broadcast sequence number cache