Removed unneeded word "struct", fixed mobility model, fixed random variable

This commit is contained in:
Kirill Andreev
2009-03-12 12:34:49 +03:00
parent 48d98b6d05
commit 16d7f9ca9d
5 changed files with 54 additions and 53 deletions

View File

@@ -80,9 +80,10 @@ main(int argc, char *argv[])
"DeltaY", DoubleValue (step),
"GridWidth", UintegerValue (xSize),
"LayoutType", StringValue("RowFirst"));
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
NS_LOG_UNCOND("Mobility");
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (nodes);
NS_LOG_UNCOND("Mobility installed");
// Setting Internet Stack:
InternetStackHelper stack;
stack.Install(nodes);

View File

@@ -70,10 +70,10 @@ HwmpRtable::AddReactivePath(
uint32_t seqnum
)
{
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
if(i == m_routes.end())
{
struct ReactiveRoute newroute;
ReactiveRoute newroute;
m_routes[destination] = newroute;
}
else
@@ -119,9 +119,9 @@ HwmpRtable::AddProactivePath(
uint32_t seqnum
)
{
struct ProactiveRoute newroute;
ProactiveRoute newroute;
m_roots[port] = newroute;
std::map<uint32_t,struct ProactiveRoute>::iterator i = m_roots.find(port);
std::map<uint32_t,ProactiveRoute>::iterator i = m_roots.find(port);
NS_ASSERT(i != m_roots.end());
i->second.root = root;
i->second.retransmitter = retransmitter;
@@ -135,7 +135,7 @@ void
HwmpRtable::AddPrecursor(Mac48Address destination, uint32_t port, Mac48Address precursor)
{
bool should_add = true;
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
if((i != m_routes.end()) && (i->second.port == port))
{
for(unsigned int j = 0 ; j < i->second.precursors.size(); j ++)
@@ -147,7 +147,7 @@ HwmpRtable::AddPrecursor(Mac48Address destination, uint32_t port, Mac48Address p
if(should_add)
i->second.precursors.push_back(precursor);
}
std::map<uint32_t,struct ProactiveRoute>::iterator k = m_roots.find(port);
std::map<uint32_t,ProactiveRoute>::iterator k = m_roots.find(port);
if(k!= m_roots.end())
{
for(unsigned int j = 0 ; j < k->second.precursors.size(); j ++)
@@ -161,7 +161,7 @@ HwmpRtable::AddPrecursor(Mac48Address destination, uint32_t port, Mac48Address p
void
HwmpRtable::DeleteProactivePath(uint32_t port)
{
std::map<uint32_t,struct ProactiveRoute>::iterator j = m_roots.find(port);
std::map<uint32_t,ProactiveRoute>::iterator j = m_roots.find(port);
if(j != m_roots.end())
m_roots.erase(j);
@@ -169,7 +169,7 @@ HwmpRtable::DeleteProactivePath(uint32_t port)
void
HwmpRtable::DeleteProactivePath(Mac48Address root, uint32_t port)
{
std::map<uint32_t,struct ProactiveRoute>::iterator j = m_roots.find(port);
std::map<uint32_t,ProactiveRoute>::iterator j = m_roots.find(port);
if((j != m_roots.end())&&(j->second.root == root))
m_roots.erase(j);
@@ -178,21 +178,21 @@ HwmpRtable::DeleteProactivePath(Mac48Address root, uint32_t port)
void
HwmpRtable::DeleteReactivePath(Mac48Address destination, uint32_t port)
{
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
if(i != m_routes.end())
if(i->second.port == port)
m_routes.erase(i);
}
struct HwmpRtable::LookupResult
HwmpRtable::LookupResult
HwmpRtable::LookupReactive(Mac48Address destination)
{
struct LookupResult result;
LookupResult result;
result.retransmitter = Mac48Address::GetBroadcast();
result.metric = MAX_METRIC;
result.ifIndex = PORT_ANY;
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
if(i == m_routes.end())
return result;
result.ifIndex = i->second.port;
@@ -206,14 +206,14 @@ HwmpRtable::LookupReactive(Mac48Address destination)
return result;
}
struct HwmpRtable::LookupResult
HwmpRtable::LookupResult
HwmpRtable::LookupProactive(uint32_t port)
{
struct LookupResult result;
LookupResult result;
result.retransmitter = Mac48Address::GetBroadcast();
result.metric = MAX_METRIC;
result.ifIndex = PORT_ANY;
std::map<uint32_t, struct ProactiveRoute, addrcmp>::iterator i = m_roots.find(port);
std::map<uint32_t, ProactiveRoute, addrcmp>::iterator i = m_roots.find(port);
if(i == m_roots.end())
return result;
result.ifIndex = i->first;
@@ -225,14 +225,14 @@ HwmpRtable::LookupProactive(uint32_t port)
return result;
}
std::vector<struct HwmpRtable::FailedDestination>
std::vector<HwmpRtable::FailedDestination>
HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port)
{
std::vector<struct FailedDestination> retval;
for(std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.begin(); i!= m_routes.end(); i++)
std::vector<FailedDestination> retval;
for(std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.begin(); i!= m_routes.end(); i++)
if((i->second.retransmitter == peerAddress)&&(i->second.port == port))
{
struct FailedDestination dst;
FailedDestination dst;
dst.destination = i->first;
i->second.seqnum ++;
dst.seqnum = i->second.seqnum;
@@ -241,10 +241,10 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port)
/**
* Lookup a path to root
*/
std::map<uint32_t, struct ProactiveRoute, addrcmp>::iterator i = m_roots.find(port);
std::map<uint32_t, ProactiveRoute, addrcmp>::iterator i = m_roots.find(port);
if((i != m_roots.end())&&(i->second.retransmitter == peerAddress))
{
struct FailedDestination dst;
FailedDestination dst;
dst.destination = i->second.root;
dst.seqnum = i->second.seqnum;
retval.push_back(dst);
@@ -254,7 +254,7 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port)
uint32_t
HwmpRtable::RequestSeqnum(Mac48Address destination)
{
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator i = m_routes.find(destination);
if(i == m_routes.end())
return 0;
return i->second.seqnum;
@@ -264,13 +264,13 @@ std::vector<Mac48Address>
HwmpRtable::GetPrecursors(Mac48Address destination, uint32_t port)
{
std::vector<Mac48Address> retval;
std::map<uint32_t, struct ProactiveRoute, addrcmp>::iterator root = m_roots.find(port);
std::map<uint32_t, ProactiveRoute, addrcmp>::iterator root = m_roots.find(port);
if((root != m_roots.end()) &&(root->second.root == destination))
{
for(unsigned int i = 0; i < root->second.precursors.size(); i ++)
retval.push_back(root->second.precursors[i]);
}
std::map<Mac48Address, struct ReactiveRoute, addrcmp>::iterator route = m_routes.find(destination);
std::map<Mac48Address, ReactiveRoute, addrcmp>::iterator route = m_routes.find(destination);
if( (route != m_routes.end()) && (route->second.port == port) )
{
for(unsigned int i = 0; i < route->second.precursors.size(); i ++)

View File

@@ -47,14 +47,14 @@ HwmpState::HwmpState()
}
void
HwmpState::SetRequestRouteCallback(
Callback<struct HwmpRtable::LookupResult, const Mac48Address&> cb)
Callback<HwmpRtable::LookupResult, const Mac48Address&> cb)
{
m_requestRouteCallback = cb;
}
void
HwmpState::SetRequestRootPathCallback(
Callback<struct HwmpRtable::LookupResult, uint32_t> cb)
Callback<HwmpRtable::LookupResult, uint32_t> cb)
{
m_requestRootPathCallback = cb;
}
@@ -87,7 +87,7 @@ HwmpState::SetRoutingInfoCallback(
void
HwmpState::SetRetransmittersOfPerrCallback(
Callback<std::vector<Mac48Address>, std::vector<struct HwmpRtable::FailedDestination>, uint32_t> cb)
Callback<std::vector<Mac48Address>, std::vector<HwmpRtable::FailedDestination>, uint32_t> cb)
{
m_retransmittersOfPerrCallback = cb;
}
@@ -133,7 +133,7 @@ HwmpState::RequestDestination(Mac48Address dst)
}
}
void
HwmpState::SendPathError(std::vector<struct HwmpRtable::FailedDestination> destinations)
HwmpState::SendPathError(std::vector<HwmpRtable::FailedDestination> destinations)
{
std::vector<Mac48Address> receivers = m_retransmittersOfPerrCallback(destinations, m_ifIndex);
NS_LOG_DEBUG("SendPathError started");
@@ -272,7 +272,7 @@ HwmpState::ReceivePreq(WifiPreqInformationElement& preq, const Mac48Address& fr
continue;
}
//check if can answer:
struct HwmpRtable::LookupResult result = m_requestRouteCallback((*i)->GetDestinationAddress());
HwmpRtable::LookupResult result = m_requestRouteCallback((*i)->GetDestinationAddress());
if((!((*i)->IsDo())) && (result.retransmitter!=Mac48Address::GetBroadcast()))
{
//have a valid information and acn answer
@@ -328,7 +328,7 @@ HwmpState::ReceivePrep(WifiPrepInformationElement& prep, const Mac48Address& fro
if(i->second > prep.GetDestinationSeqNumber())
return;
//update routing info
struct HwmpRtable::LookupResult result = m_requestRouteCallback(prep.GetDestinationAddress());
HwmpRtable::LookupResult result = m_requestRouteCallback(prep.GetDestinationAddress());
if(result.retransmitter == Mac48Address::GetBroadcast())
//try to look for default route
result = m_requestRootPathCallback(m_ifIndex);
@@ -371,7 +371,7 @@ HwmpState::ReceivePerr(WifiPerrInformationElement& perr, const Mac48Address& fro
/**
* Lookup for a valid routing information
*/
struct HwmpRtable::LookupResult result = m_requestRouteCallback(destinations[i].destination);
HwmpRtable::LookupResult result = m_requestRouteCallback(destinations[i].destination);
if(
(result.retransmitter != from)
||(result.seqnum >= destinations[i].seqnum)

View File

@@ -180,7 +180,7 @@ Hwmp::DoDispose()
* clear routing queue:
*/
for(
std::map<Mac48Address, std::queue<struct QueuedPacket> >::iterator i = m_rqueue.begin();
std::map<Mac48Address, std::queue<QueuedPacket> >::iterator i = m_rqueue.begin();
i != m_rqueue.end();
i++
)
@@ -211,7 +211,7 @@ Hwmp::RequestRoute(
L2RoutingProtocol::RouteReplyCallback routeReply
)
{
struct HwmpRtable::LookupResult result;
HwmpRtable::LookupResult result;
HwmpTag tag;
if(sourceIface == m_interface)
{
@@ -269,14 +269,14 @@ Hwmp::RequestRoute(
{
//Start path error procedure:
NS_LOG_DEBUG("Must Send PERR");
std::vector<struct HwmpRtable::FailedDestination> destinations;
struct HwmpRtable::FailedDestination dst;
std::vector<HwmpRtable::FailedDestination> destinations;
HwmpRtable::FailedDestination dst;
dst.seqnum = m_rtable->RequestSeqnum(destination);
dst.destination = destination;
destinations.push_back(dst);
StartPathErrorProcedure(destinations, result.ifIndex);
}
struct L2RoutingProtocol::QueuedPacket pkt;
L2RoutingProtocol::QueuedPacket pkt;
packet->RemoveAllTags();
packet->AddTag(tag);
pkt.pkt = packet;
@@ -527,12 +527,12 @@ Hwmp::ObtainRoutingInformation(
*/
{
NS_LOG_DEBUG("Failed peer"<<info.destination);
std::vector<struct HwmpRtable::FailedDestination> failedDestinations =
std::vector<HwmpRtable::FailedDestination> failedDestinations =
m_rtable->GetUnreachableDestinations(info.destination, info.outPort);
/**
* Entry about peer does not contain seqnum
*/
struct HwmpRtable::FailedDestination peer;
HwmpRtable::FailedDestination peer;
peer.destination = info.destination;
peer.seqnum = 0;
failedDestinations.push_back(peer);
@@ -544,20 +544,20 @@ Hwmp::ObtainRoutingInformation(
}
}
struct HwmpRtable::LookupResult
HwmpRtable::LookupResult
Hwmp::RequestRouteForAddress(const Mac48Address& dst)
{
return m_rtable->LookupReactive(dst);
}
struct HwmpRtable::LookupResult
HwmpRtable::LookupResult
Hwmp::RequestRootPathForPort(uint32_t port)
{
return m_rtable->LookupProactive(port);
}
void
Hwmp::StartPathErrorProcedure(std::vector<struct HwmpRtable::FailedDestination> destinations, uint32_t port)
Hwmp::StartPathErrorProcedure(std::vector<HwmpRtable::FailedDestination> destinations, uint32_t port)
{
NS_LOG_DEBUG("START PERR");
for(unsigned int i = 0; i < m_hwmpStates.size(); i++)
@@ -565,7 +565,7 @@ Hwmp::StartPathErrorProcedure(std::vector<struct HwmpRtable::FailedDestination>
m_pathErrorCallback[i](destinations);
}
std::vector<Mac48Address>
Hwmp::GetRetransmittersForFailedDestinations(std::vector<struct HwmpRtable::FailedDestination> failedDest, uint32_t port)
Hwmp::GetRetransmittersForFailedDestinations(std::vector<HwmpRtable::FailedDestination> failedDest, uint32_t port)
{
std::vector<Mac48Address> retransmitters;
if(m_broadcastPerr)
@@ -597,7 +597,7 @@ Hwmp::SetMaxQueueSize(int maxPacketsPerDestination)
}
bool
Hwmp::QueuePacket(struct L2RoutingProtocol::QueuedPacket packet)
Hwmp::QueuePacket(L2RoutingProtocol::QueuedPacket packet)
{
if((int)m_rqueue[packet.dst].size() > m_maxQueueSize)
return false;
@@ -605,13 +605,13 @@ Hwmp::QueuePacket(struct L2RoutingProtocol::QueuedPacket packet)
return true;
}
struct L2RoutingProtocol::QueuedPacket
L2RoutingProtocol::QueuedPacket
Hwmp::DequeuePacket(Mac48Address dst)
{
struct L2RoutingProtocol::QueuedPacket retval;
L2RoutingProtocol::QueuedPacket retval;
retval.pkt = NULL;
//Ptr<Packet> in this structure is NULL when queue is empty
std::map<Mac48Address, std::queue<struct QueuedPacket>, addrcmp>:: iterator i = m_rqueue.find(dst);
std::map<Mac48Address, std::queue<QueuedPacket>, addrcmp>:: iterator i = m_rqueue.find(dst);
if(i == m_rqueue.end())
return retval;
if((int)m_rqueue[dst].size() == 0)
@@ -629,8 +629,8 @@ Hwmp::DequeuePacket(Mac48Address dst)
void
Hwmp::SendAllPossiblePackets(Mac48Address dst)
{
struct HwmpRtable::LookupResult result = m_rtable->LookupReactive(dst);
struct L2RoutingProtocol::QueuedPacket packet;
HwmpRtable::LookupResult result = m_rtable->LookupReactive(dst);
L2RoutingProtocol::QueuedPacket packet;
while(1)
{
@@ -664,7 +664,7 @@ Hwmp::ShouldSendPreq(Mac48Address dst)
void
Hwmp::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry)
{
struct HwmpRtable::LookupResult result = m_rtable->LookupReactive(dst);
HwmpRtable::LookupResult result = m_rtable->LookupReactive(dst);
if(result.retransmitter != Mac48Address::GetBroadcast())
{
std::map<Mac48Address, EventId, addrcmp>::iterator i = m_timeoutDatabase.find(dst);
@@ -675,7 +675,7 @@ Hwmp::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry)
numOfRetry++;
if(numOfRetry > dot11sParameters::dot11MeshHWMPmaxPREQretries)
{
struct L2RoutingProtocol::QueuedPacket packet;
L2RoutingProtocol::QueuedPacket packet;
//purge queue and delete entry from retryDatabase
while(1)
{

View File

@@ -967,7 +967,7 @@ WifiPeerManager::GetNextBeaconShift(
coefficientSign = 1;
UniformVariable randomShift(1, 15);
//So, the shift is a random integer variable uniformly distributed in [-15;-1] U [1;15]
int beaconShift = randomShift.GetInteger() * coefficientSign;
int beaconShift = randomShift.GetInteger(1,15) * coefficientSign;
NS_LOG_DEBUG("Shift value = " << beaconShift << " beacon TUs");
//We need the result not in Time Units, but in microseconds
return MicroSeconds(beaconShift * 1024);