Added closing link due to transmission failure.
This commit is contained in:
@@ -73,6 +73,13 @@ PeerLink::GetTypeId ()
|
||||
&PeerLink::m_maxBeaconLoss),
|
||||
MakeUintegerChecker<uint16_t> (1)
|
||||
)
|
||||
.AddAttribute ( "MaxPacketFailure",
|
||||
"Maximum number of failed packets before link will be closed",
|
||||
UintegerValue (2),
|
||||
MakeUintegerAccessor (
|
||||
&PeerLink::m_maxPacketFail),
|
||||
MakeUintegerChecker<uint16_t> (1)
|
||||
)
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -83,7 +90,7 @@ PeerLink::GetTypeId ()
|
||||
//-----------------------------------------------------------------------------
|
||||
PeerLink::PeerLink () :
|
||||
m_peerAddress (Mac48Address::GetBroadcast ()), m_peerMeshPointAddress (Mac48Address::GetBroadcast ()),
|
||||
m_localLinkId (0), m_peerLinkId (0), m_state (IDLE), m_retryCounter (0)
|
||||
m_localLinkId (0), m_peerLinkId (0), m_packetFail (0), m_state (IDLE), m_retryCounter (0), m_maxPacketFail (3)
|
||||
{
|
||||
}
|
||||
PeerLink::~PeerLink ()
|
||||
@@ -143,6 +150,24 @@ PeerLink::BeaconLoss ()
|
||||
{
|
||||
StateMachine (CNCL);
|
||||
}
|
||||
void
|
||||
PeerLink::TransmissionSuccess ()
|
||||
{
|
||||
std::cerr << "TX OK!\n";
|
||||
m_packetFail = 0;
|
||||
}
|
||||
void
|
||||
PeerLink::TransmissionFailure ()
|
||||
{
|
||||
m_packetFail ++;
|
||||
std::cerr << "TX FAIL!\n";
|
||||
if (m_packetFail == m_maxPacketFail)
|
||||
{
|
||||
StateMachine (CNCL);
|
||||
m_packetFail = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PeerLink::SetBeaconTimingElement (IeBeaconTiming beaconTiming)
|
||||
{
|
||||
|
||||
@@ -99,6 +99,9 @@ public:
|
||||
typedef Callback<void, uint32_t, Mac48Address, Mac48Address, PeerLink::PeerState, PeerLink::PeerState> SignalStatusCallback;
|
||||
/// Set callback
|
||||
void MLMESetSignalStatusCallback (SignalStatusCallback);
|
||||
/// Reports about transmission success/failure
|
||||
void TransmissionSuccess ();
|
||||
void TransmissionFailure ();
|
||||
//\}
|
||||
///\brief Statistics
|
||||
void Report (std::ostream & os) const;
|
||||
@@ -220,6 +223,8 @@ private:
|
||||
Time m_lastBeacon;
|
||||
/// Current beacon interval on corresponding interface
|
||||
Time m_beaconInterval;
|
||||
/// How many successive packets were failed to transmit
|
||||
uint16_t m_packetFail;
|
||||
|
||||
/// Current state
|
||||
PeerState m_state;
|
||||
@@ -244,7 +249,8 @@ private:
|
||||
EventId m_confirmTimer;
|
||||
uint16_t m_retryCounter;
|
||||
EventId m_beaconLossTimer;
|
||||
uint16_t m_maxBeaconLoss;
|
||||
uint16_t m_maxBeaconLoss;
|
||||
uint16_t m_maxPacketFail;
|
||||
//\}
|
||||
|
||||
/// Several successive beacons were lost, close link
|
||||
|
||||
@@ -46,8 +46,19 @@ void
|
||||
PeerManagementProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
m_parent->TraceConnectWithoutContext ("TxErrHeader", MakeCallback (&PeerManagementProtocolMac::TxError, this));
|
||||
m_parent->TraceConnectWithoutContext ("TxOkHeader", MakeCallback (&PeerManagementProtocolMac::TxOk, this));
|
||||
}
|
||||
void
|
||||
PeerManagementProtocolMac::TxError (WifiMacHeader const &hdr)
|
||||
{
|
||||
m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 ());
|
||||
}
|
||||
void
|
||||
PeerManagementProtocolMac::TxOk (WifiMacHeader const &hdr)
|
||||
{
|
||||
m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 ());
|
||||
}
|
||||
|
||||
bool
|
||||
PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,9 @@ private:
|
||||
/// WifiInformationElements exist
|
||||
PlinkFrameStart ParsePlinkFrame (Ptr<const Packet> packet);
|
||||
///\}
|
||||
///// Closes link when a proper number of successive transmissions have failed
|
||||
void TxError (WifiMacHeader const &hdr);
|
||||
void TxOk (WifiMacHeader const &hdr);
|
||||
//Keeps statistics
|
||||
struct Statistics {
|
||||
uint16_t txOpen;
|
||||
|
||||
@@ -284,7 +284,26 @@ PeerManagementProtocol::ConfigurationMismatch (uint32_t interface, Mac48Address
|
||||
peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PeerManagementProtocol::TransmissionFailure (uint32_t interface, Mac48Address peerAddress)
|
||||
{
|
||||
NS_LOG_DEBUG("transmission failed between "<<GetAddress () << " and " << peerAddress << " failed, link will be colsed");
|
||||
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
|
||||
if(peerLink != 0)
|
||||
{
|
||||
peerLink->TransmissionFailure ();
|
||||
}
|
||||
}
|
||||
void
|
||||
PeerManagementProtocol::TransmissionSuccess (uint32_t interface, Mac48Address peerAddress)
|
||||
{
|
||||
NS_LOG_DEBUG("transmission success "<<GetAddress () << " and " << peerAddress << " failed, link will be colsed");
|
||||
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
|
||||
if(peerLink != 0)
|
||||
{
|
||||
peerLink->TransmissionSuccess ();
|
||||
}
|
||||
}
|
||||
Ptr<PeerLink>
|
||||
PeerManagementProtocol::InitiateLink (uint32_t interface, Mac48Address peerAddress,
|
||||
Mac48Address peerMeshPointAddress, Time lastBeacon, Time beaconInterval)
|
||||
|
||||
@@ -124,6 +124,11 @@ public:
|
||||
* rates)
|
||||
*/
|
||||
void ConfigurationMismatch (uint32_t interface, Mac48Address peerAddress);
|
||||
/**
|
||||
* Cancel peer link due to successive transmission failures
|
||||
*/
|
||||
void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress);
|
||||
void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress);
|
||||
/**
|
||||
* Checks if there is established link
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/yans-wifi-phy.h"
|
||||
#include "ns3/pointer.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/qos-tag.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("MeshWifiInterfaceMac");
|
||||
@@ -66,7 +67,18 @@ MeshWifiInterfaceMac::GetTypeId ()
|
||||
MakeBooleanAccessor (
|
||||
&MeshWifiInterfaceMac::SetBeaconGeneration, &MeshWifiInterfaceMac::GetBeaconGeneration),
|
||||
MakeBooleanChecker ()
|
||||
);
|
||||
)
|
||||
.AddTraceSource ( "TxOkHeader",
|
||||
"The header of successfully transmitted packet",
|
||||
MakeTraceSourceAccessor (
|
||||
&MeshWifiInterfaceMac::m_txOkCallback)
|
||||
)
|
||||
.AddTraceSource ( "TxErrHeader",
|
||||
"The header of unsuccessfully transmitted packet",
|
||||
MakeTraceSourceAccessor (
|
||||
&MeshWifiInterfaceMac::m_txErrCallback)
|
||||
)
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
MeshWifiInterfaceMac::MeshWifiInterfaceMac ()
|
||||
@@ -681,11 +693,22 @@ MeshWifiInterfaceMac::SetQueue (AccessClass ac)
|
||||
Ptr<DcaTxop> queue = Create<DcaTxop> ();
|
||||
queue->SetLow (m_low);
|
||||
queue->SetManager (m_dcfManager);
|
||||
//queue->SetTxOkCallback (MakeCallback (&MeshWifiInterfaceMac::TxOk, this));
|
||||
//queue->SetTxFailedCallback (MakeCallback (&MeshWifiInterfaceMac::TxFailed, this));
|
||||
queue->SetTxOkCallback (MakeCallback (&MeshWifiInterfaceMac::TxOk, this));
|
||||
queue->SetTxFailedCallback (MakeCallback (&MeshWifiInterfaceMac::TxFailed, this));
|
||||
|
||||
m_queues.insert (std::make_pair (ac, queue));
|
||||
}
|
||||
void
|
||||
MeshWifiInterfaceMac::TxOk (WifiMacHeader const &hdr)
|
||||
{
|
||||
m_txOkCallback (hdr);
|
||||
}
|
||||
void
|
||||
MeshWifiInterfaceMac::TxFailed (WifiMacHeader const &hdr)
|
||||
{
|
||||
m_txErrCallback (hdr);
|
||||
}
|
||||
|
||||
void
|
||||
MeshWifiInterfaceMac::FinishConfigureStandard (enum WifiPhyStandard standard)
|
||||
{
|
||||
|
||||
@@ -167,6 +167,9 @@ private:
|
||||
virtual void ForwardUp (Ptr<Packet> packet, Mac48Address src, Mac48Address dst);
|
||||
/// Send frame. Frame is supposed to be tagged by routing information. TODO: clarify this point
|
||||
void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
// Notify about tx OK/Error frames:
|
||||
void TxOk (WifiMacHeader const &hdr);
|
||||
void TxFailed (WifiMacHeader const &hdr);
|
||||
/// Send beacon
|
||||
void SendBeacon ();
|
||||
/// Schedule next beacon
|
||||
@@ -242,6 +245,8 @@ private:
|
||||
};
|
||||
Statistics m_stats;
|
||||
///\}
|
||||
TracedCallback<WifiMacHeader const &> m_txOkCallback;
|
||||
TracedCallback<WifiMacHeader const &> m_txErrCallback;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user