Attributes added

This commit is contained in:
Borovkova Elena
2009-07-31 17:11:11 +04:00
parent a7434537b2
commit c33f835d4a
6 changed files with 81 additions and 42 deletions

View File

@@ -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);

View File

@@ -178,7 +178,7 @@ Ipv4Interface::SetForwarding (bool val)
void
Ipv4Interface::Send (Ptr<Packet> p, Ipv4Address dest)
{
NS_LOG_UNCOND (dest << *p);
NS_LOG_LOGIC (dest << *p);
if (!IsUp())
{
return;
@@ -188,7 +188,7 @@ Ipv4Interface::Send (Ptr<Packet> 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<Packet> p, Ipv4Address dest)
{
if (dest == (*i).GetLocal ())
{
NS_LOG_UNCOND ("to local");
NS_LOG_LOGIC ("to local");
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
ipv4->Receive (m_device, p, Ipv4L3Protocol::PROT_NUMBER,
@@ -211,19 +211,19 @@ Ipv4Interface::Send (Ptr<Packet> p, Ipv4Address dest)
}
if (m_device->NeedsArp ())
{
NS_LOG_UNCOND ("Needs ARP" << " " << dest);
NS_LOG_LOGIC ("Needs ARP" << " " << dest);
Ptr<ArpL3Protocol> arp = m_node->GetObject<ArpL3Protocol> ();
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<Packet> 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<Packet> 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);
}

View File

@@ -390,9 +390,9 @@ void
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> 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<NetDevice> device, Ptr<const Packet> p, uint16_t pr
if (!ipHeader.IsChecksumOk ())
{
NS_LOG_UNCOND("bad check sum");
NS_LOG_LOGIC("bad check sum");
m_dropTrace (packet);
return;
}

View File

@@ -253,25 +253,25 @@ RawSocketImpl::SendByInterface (Ptr<Packet> p, Ptr<const Ipv4Route> 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<NetDevice> outDev = route->GetOutputDevice ();
int32_t interface = m_ipv4->GetInterfaceForDevice (outDev);
NS_ASSERT (interface >= 0);
Ptr<Ipv4Interface> 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<Packet> 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<Packet> p, Ptr<const Ipv4Route> route)
if (outInterface->IsUp ())
{
Ptr<Packet> 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<Packet>
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<Packet>
RawSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
{
NS_LOG_UNCOND ("RawSocketImpl::RecvFrom" << " maxSize " << maxSize << " flags " << flags << " address " <<fromAddress);
NS_LOG_LOGIC ("RawSocketImpl::RecvFrom" << " maxSize " << maxSize << " flags " << flags << " address " <<fromAddress);
if (m_recv.empty ())
{
return 0;

View File

@@ -160,12 +160,15 @@ RoutingProtocol::PurgeNeighbor ()
}
RoutingProtocol::RoutingProtocol () :
RTQ_TIMEOUT (Seconds (30)),
MAX_QUEUE_TIME (Seconds (30)),
RREQ_RETRIES (2),
ACTIVE_ROUTE_TIMEOUT (Seconds (3)),
MY_ROUTE_TIMEOUT (Scalar (2) * ACTIVE_ROUTE_TIMEOUT),
NET_DIAMETER (35),
NODE_TRAVERSAL_TIME (MilliSeconds (40)),
NET_TRAVERSAL_TIME (Scalar (2 * NET_DIAMETER) * NODE_TRAVERSAL_TIME),
BCAST_ID_SAVE ( Scalar (2) * NET_TRAVERSAL_TIME),
HELLO_INTERVAL(Seconds (1)),
ALLOWED_HELLO_LOSS (2),
FREQUENCY (Seconds (0.5)),
BLACKLIST_TIMEOUT(Scalar(RREQ_RETRIES) * NET_TRAVERSAL_TIME),
@@ -174,13 +177,12 @@ RoutingProtocol::RoutingProtocol () :
* This is to account for possible additional route discovery attempts.
*/
NEXT_HOP_WAIT(NODE_TRAVERSAL_TIME + MilliSeconds (10)),
TTL_START(1), TTL_INCREMENT(2), TTL_THRESHOLD(7),
m_requestId (0), m_broadcastId(0), m_seqNo (0), btimer (Timer::CANCEL_ON_DESTROY), htimer (Timer::CANCEL_ON_DESTROY), ntimer (Timer::CANCEL_ON_DESTROY),
rtimer (Timer::CANCEL_ON_DESTROY), lrtimer (Timer::CANCEL_ON_DESTROY), m_routeRequestTimer (Timer::CANCEL_ON_DESTROY)
{
NET_TRAVERSAL_TIME = Scalar (2 * NET_DIAMETER) * NODE_TRAVERSAL_TIME;
BCAST_ID_SAVE = Scalar (2) * NET_TRAVERSAL_TIME;
MaxHelloInterval = Scalar (1.25) * HELLO_INTERVAL;
MinHelloInterval = Scalar (0.75) * HELLO_INTERVAL;
if(ACTIVE_ROUTE_TIMEOUT > 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<Ipv4RoutingProtocol> () .AddConstructor<RoutingProtocol> () .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<uint32_t> ()) .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<Ipv4RoutingProtocol> ()
.AddConstructor<RoutingProtocol> ()
.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<uint32_t> ())
.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<uint16_t> ())
.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<uint16_t> ())
.AddAttribute ("TtlIncrement", "Increment value of RREQ TTL when use an expanding ring search",
UintegerValue (2),
MakeUintegerAccessor (&RoutingProtocol::TTL_INCREMENT),
MakeUintegerChecker<uint16_t> ())
.AddAttribute ("TtlThreshold", "Threshold, beyond which TTL = NET_DIAMETER is used for each attempt in RREQ.",
UintegerValue (7),
MakeUintegerAccessor (&RoutingProtocol::TTL_THRESHOLD),
MakeUintegerChecker<uint16_t> ())
;
return tid;
@@ -270,7 +307,6 @@ RoutingProtocol::RouteOutput (Ptr<Packet> 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<const Packet> 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);

View File

@@ -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