Skip to content

Commit

Permalink
Merged Qasim's old tree (Fall 2010) with the newer ns3 code base.
Browse files Browse the repository at this point in the history
Commits 6668 to 6681.
  • Loading branch information
joelagnel committed Apr 9, 2011
1 parent c8504f9 commit d5d09d3
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/mesh/model/dot11s/airtime-metric.cc
Expand Up @@ -95,6 +95,8 @@ AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, Ptr<Mesh
mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs
mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), mode, WIFI_PREAMBLE_LONG)
).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));

//metric = (uint32_t) mac->GetStationManager ()->GetInfo (peerAddress).GetPacketTimeAvg ();
return metric;
}
} //namespace dot11s
Expand Down
3 changes: 3 additions & 0 deletions src/mesh/model/dot11s/hwmp-protocol.cc
Expand Up @@ -364,6 +364,9 @@ HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source,
result = m_rtable->LookupReactiveExpired (destination);
if (ShouldSendPreq (destination))
{
NS_LOG_ERROR("Source " << source << " sending preq for destination " << destination << "\n");
// Accepted preq from address" << from << ", preq:" << preq);

uint32_t originator_seqno = GetNextHwmpSeqno ();
uint32_t dst_seqno = 0;
if (result.retransmitter != Mac48Address::GetBroadcast ())
Expand Down
18 changes: 15 additions & 3 deletions src/mesh/model/dot11s/peer-link.cc
Expand Up @@ -101,7 +101,11 @@ PeerLink::PeerLink () :
m_packetFail (0),
m_state (IDLE),
m_retryCounter (0),
m_maxPacketFail (3)
m_maxPacketFail (3),
m_packetSuccessCount (0),
m_packetSuccessBytes (0),
m_packetFailCount (0),
m_packetFailBytes (0)
{
}
PeerLink::~PeerLink ()
Expand Down Expand Up @@ -162,14 +166,18 @@ PeerLink::BeaconLoss ()
StateMachine (CNCL);
}
void
PeerLink::TransmissionSuccess ()
PeerLink::TransmissionSuccess (uint32_t size)
{
m_packetFail = 0;
m_packetSuccessCount ++;
m_packetSuccessBytes += size;
}
void
PeerLink::TransmissionFailure ()
PeerLink::TransmissionFailure (uint32_t size)
{
m_packetFail ++;
m_packetFailCount ++;
m_packetFailBytes += size;
if (m_packetFail == m_maxPacketFail)
{
StateMachine (CNCL);
Expand Down Expand Up @@ -699,6 +707,10 @@ PeerLink::Report (std::ostream & os) const
"localLinkId=\"" << m_localLinkId << "\"" << std::endl <<
"peerLinkId=\"" << m_peerLinkId << "\"" << std::endl <<
"assocId=\"" << m_assocId << "\"" << std::endl <<
"FrameSuccessCount=\"" << m_packetSuccessCount << "\"" << std::endl <<
"FrameSuccessBytes=\"" << m_packetSuccessBytes << "\"" << std::endl <<
"FrameFailCount=\"" << m_packetFailCount << "\"" << std::endl <<
"FrameFailBytes=\"" << m_packetFailBytes << "\"" << std::endl <<
"/>" << std::endl;
}
} // namespace dot11s
Expand Down
9 changes: 7 additions & 2 deletions src/mesh/model/dot11s/peer-link.h
Expand Up @@ -100,8 +100,8 @@ class PeerLink : public Object
/// Set callback
void MLMESetSignalStatusCallback (SignalStatusCallback);
/// Reports about transmission success/failure
void TransmissionSuccess ();
void TransmissionFailure ();
void TransmissionSuccess (uint32_t size);
void TransmissionFailure (uint32_t size);
//\}
///\brief Statistics
void Report (std::ostream & os) const;
Expand Down Expand Up @@ -254,6 +254,11 @@ class PeerLink : public Object
//\}
/// How to report my status change
SignalStatusCallback m_linkStatusCallback;

uint32_t m_packetSuccessCount;
uint32_t m_packetSuccessBytes;
uint32_t m_packetFailCount;
uint32_t m_packetFailBytes;
};

} // namespace dot11s
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/model/dot11s/peer-management-protocol-mac.cc
Expand Up @@ -52,12 +52,12 @@ PeerManagementProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
void
PeerManagementProtocolMac::TxError (WifiMacHeader const &hdr)
{
m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 ());
m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 (), hdr.GetSize ());
}
void
PeerManagementProtocolMac::TxOk (WifiMacHeader const &hdr)
{
m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 ());
m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 (), hdr.GetSize ());
}
bool
PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)
Expand Down
8 changes: 4 additions & 4 deletions src/mesh/model/dot11s/peer-management-protocol.cc
Expand Up @@ -237,23 +237,23 @@ PeerManagementProtocol::ConfigurationMismatch (uint32_t interface, Mac48Address
}
}
void
PeerManagementProtocol::TransmissionFailure (uint32_t interface, Mac48Address peerAddress)
PeerManagementProtocol::TransmissionFailure (uint32_t interface, Mac48Address peerAddress, uint32_t size)
{
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 ();
peerLink->TransmissionFailure (size);
}
}
void
PeerManagementProtocol::TransmissionSuccess (uint32_t interface, Mac48Address peerAddress)
PeerManagementProtocol::TransmissionSuccess (uint32_t interface, Mac48Address peerAddress, uint32_t size)
{
NS_LOG_DEBUG("transmission success "<<GetAddress () << " and " << peerAddress << " failed, link will be colsed");
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
if (peerLink != 0)
{
peerLink->TransmissionSuccess ();
peerLink->TransmissionSuccess (size);
}
}
Ptr<PeerLink>
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/model/dot11s/peer-management-protocol.h
Expand Up @@ -116,11 +116,11 @@ class PeerManagementProtocol : public Object
/**
* \brief Cancels peer link due to successive transmission failures
*/
void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress);
void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress, uint32_t size);
/**
* \brief resets transmission failure statistics
*/
void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress);
void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress, uint32_t size);
/**
* \brief Checks if there is established link
*/
Expand Down
4 changes: 4 additions & 0 deletions src/visualizer/model/pyviz.cc
Expand Up @@ -598,6 +598,8 @@ PyViz::TraceNetDevTxWifi (std::string context, Ptr<const Packet> packet)
{
destinationAddress = hdr.GetAddr3 ();
}

NS_LOG_FUNCTION(context<<"Addr1: " << hdr.GetAddr1()<<"Addr2: " << hdr.GetAddr2()<<"Addr3: " << hdr.GetAddr3()<<"Addr4: " << hdr.GetAddr4()<<"\n\n");
TraceNetDevTxCommon (context, packet, destinationAddress);
}

Expand Down Expand Up @@ -769,6 +771,8 @@ PyViz::TraceNetDevRxWifi (std::string context, Ptr<const Packet> packet)
sourceAddress = hdr.GetAddr4 ();
}

NS_LOG_FUNCTION(context<<"Addr1: " << hdr.GetAddr1()<<"Addr2: " << hdr.GetAddr2()<<"Addr3: " << hdr.GetAddr3()<<"Addr4: " << hdr.GetAddr4()<<"\n\n");

TraceNetDevRxCommon (context, packet, sourceAddress);
}

Expand Down
1 change: 1 addition & 0 deletions src/visualizer/visualizer/core.py
Expand Up @@ -917,6 +917,7 @@ def _update_transmissions_view(self):
rx_bytes += transmission.bytes
count += 1
transmissions_average[key] = rx_bytes, count
# print "[Joel] Transmitter: ", transmission.transmitter.GetId(), ", Receiver: ", transmission.receiver.GetId(), "Bytes: ", transmission.bytes, "\n"

old_arrows = self._transmission_arrows
for arrow, label in old_arrows:
Expand Down
17 changes: 16 additions & 1 deletion src/wifi/model/dca-txop.cc
Expand Up @@ -33,6 +33,7 @@
#include "wifi-mac-trailer.h"
#include "wifi-mac.h"
#include "random-stream.h"
#include "tsf-tag.h"

NS_LOG_COMPONENT_DEFINE ("DcaTxop");

Expand Down Expand Up @@ -225,7 +226,21 @@ DcaTxop::Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr)
uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr,
packet, fullPacketSize);
m_queue->Enqueue (packet, hdr);

Ptr <Packet> p = packet->Copy ();
if (hdr.IsData () && !hdr.GetAddr1 ().IsBroadcast () && !hdr.IsAck ())
{
TsfTag tag;
p->RemovePacketTag (tag);

tag.SetQueueTime (Simulator::Now ());
tag.SetAckTime (Seconds (0.0));
p->AddPacketTag (tag);

NS_LOG_DEBUG ("==> Packet Queue Time : " << tag.GetQueueTime ().GetMicroSeconds ());
}

m_queue->Enqueue (p, hdr);
StartAccessIfNeeded ();
}

Expand Down
30 changes: 26 additions & 4 deletions src/wifi/model/mac-low.cc
Expand Up @@ -33,6 +33,7 @@
#include "wifi-mac-trailer.h"
#include "qos-utils.h"
#include "edca-txop-n.h"
#include "tsf-tag.h"

NS_LOG_COMPONENT_DEFINE ("MacLow");

Expand Down Expand Up @@ -714,10 +715,15 @@ MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb
NS_LOG_DEBUG ("receive ack from="<<m_currentHdr.GetAddr1 ());
SnrTag tag;
packet->RemovePacketTag (tag);

TsfTag t;
if (packet->RemovePacketTag (t))
NS_LOG_DEBUG ("*** TSF diff: " << (t.GetAckTime () - t.GetQueueTime ()).GetMicroSeconds ());

m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode);
m_stationManager->ReportDataOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode, tag.Get ());
rxSnr, txMode, tag.Get (), t.Get ());
bool gotAck = false;
if (m_txParams.MustWaitNormalAck () &&
m_normalAckTimeoutEvent.IsRunning ())
Expand Down Expand Up @@ -824,7 +830,8 @@ MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb
hdr.GetAddr2 (),
hdr.GetDuration (),
txMode,
rxSnr);
rxSnr,
packet);
}
else if (hdr.IsQosBlockAck ())
{
Expand Down Expand Up @@ -856,12 +863,14 @@ MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb
{
NS_LOG_DEBUG ("rx unicast/sendAck from=" << hdr.GetAddr2 ());
NS_ASSERT (m_sendAckEvent.IsExpired ());

m_sendAckEvent = Simulator::Schedule (GetSifs (),
&MacLow::SendAckAfterData, this,
hdr.GetAddr2 (),
hdr.GetDuration (),
txMode,
rxSnr);
rxSnr,
packet);
}
goto rxPacket;
}
Expand Down Expand Up @@ -1471,7 +1480,7 @@ MacLow::FastAckFailedTimeout (void)
}

void
MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr, Ptr<Packet> p)
{
NS_LOG_FUNCTION (this);
/* send an ACK when you receive
Expand Down Expand Up @@ -1499,6 +1508,19 @@ MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMod
tag.Set (dataSnr);
packet->AddPacketTag (tag);

TsfTag t;
bool succ = p->RemovePacketTag (t);

if (succ)
{
t.SetAckTime (Simulator::Now ());
NS_LOG_DEBUG ("==> Setting ACK time to " << t.GetAckTime ());
packet->AddPacketTag (t);

//packet->PrintPacketTags (std::cout);
}


ForwardDown (packet, &ack, ackTxMode);
}

Expand Down
2 changes: 1 addition & 1 deletion src/wifi/model/mac-low.h
Expand Up @@ -526,7 +526,7 @@ class MacLow : public Object {
void BlockAckTimeout (void);
void CtsTimeout (void);
void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr);
void SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr);
void SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr, Ptr<Packet> p);
void SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode);
void WaitSifsAfterEndTx (void);

Expand Down
24 changes: 18 additions & 6 deletions src/wifi/model/wifi-remote-station-manager.cc
Expand Up @@ -408,17 +408,17 @@ WifiRemoteStationManager::ReportRtsOk (Mac48Address address, const WifiMacHeader
{
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxSuccess (station->m_ssrc);
station->m_state->m_info.NotifyTxSuccess (station->m_ssrc, 0);
station->m_ssrc = 0;
DoReportRtsOk (station, ctsSnr, ctsMode, rtsSnr);
}
void
WifiRemoteStationManager::ReportDataOk (Mac48Address address, const WifiMacHeader *header,
double ackSnr, WifiMode ackMode, double dataSnr)
double ackSnr, WifiMode ackMode, double dataSnr, double packetTime)
{
NS_ASSERT (!address.IsGroup ());
WifiRemoteStation *station = Lookup (address, header);
station->m_state->m_info.NotifyTxSuccess (station->m_slrc);
station->m_state->m_info.NotifyTxSuccess (station->m_slrc, packetTime);
station->m_slrc = 0;
DoReportDataOk (station, ackSnr, ackMode, dataSnr);
}
Expand Down Expand Up @@ -813,7 +813,8 @@ WifiRemoteStationManager::GetNSupported (const WifiRemoteStation *station) const
WifiRemoteStationInfo::WifiRemoteStationInfo () :
m_memoryTime (Seconds (1.0)),
m_lastUpdate (Seconds (0.0)),
m_failAvg (0.0)
m_failAvg (0.0),
m_packetTimeAvg (0.0)
{}

double
Expand All @@ -827,22 +828,33 @@ WifiRemoteStationInfo::CalculateAveragingCoefficient ()
}

void
WifiRemoteStationInfo::NotifyTxSuccess (uint32_t retryCounter)
WifiRemoteStationInfo::NotifyTxSuccess (uint32_t retryCounter, double packetTime)
{
double coefficient = CalculateAveragingCoefficient ();
m_failAvg = (double)retryCounter / (1 + (double) retryCounter) * (1.0 - coefficient) + coefficient * m_failAvg;
if (packetTime > 0)
m_packetTimeAvg = packetTime * (1.0 - coefficient) + coefficient * m_packetTimeAvg;
NS_LOG_DEBUG (retryCounter);
}

void
WifiRemoteStationInfo::NotifyTxFailed ()
WifiRemoteStationInfo::NotifyTxFailed (/*double packetTime*/)
{
double coefficient = CalculateAveragingCoefficient ();
m_failAvg = (1.0 - coefficient) + coefficient * m_failAvg;
//if (packetTime > 0)
//m_packetTimeAvg = coefficient * m_packetTimeAvg;
}

double
WifiRemoteStationInfo::GetFrameErrorRate () const
{
return m_failAvg;
}

double
WifiRemoteStationInfo::GetPacketTimeAvg () const
{
return m_packetTimeAvg;
}
} // namespace ns3
9 changes: 7 additions & 2 deletions src/wifi/model/wifi-remote-station-manager.h
Expand Up @@ -52,11 +52,12 @@ class WifiRemoteStationInfo
* \param retryCounter is slrc or ssrc value at the moment of
* success transmission.
*/
void NotifyTxSuccess (uint32_t retryCounter);
void NotifyTxSuccess (uint32_t retryCounter, double packetTime);
/// Updates average frame error rate when final data or RTS has failed.
void NotifyTxFailed ();
/// Returns frame error rate (probability that frame is corrupted due to transmission error).
double GetFrameErrorRate () const;
double GetPacketTimeAvg () const;
private:
/**
* \brief Calculate averaging coefficient for frame error rate. Depends on time of the last update.
Expand All @@ -70,6 +71,9 @@ class WifiRemoteStationInfo
Time m_lastUpdate;
/// moving percentage of failed frames
double m_failAvg;

/// moving average of packet queue time + backoff time + transmission time + ack delay
double m_packetTimeAvg;
};

/**
Expand Down Expand Up @@ -187,7 +191,7 @@ class WifiRemoteStationManager : public Object
* we just sent.
*/
void ReportDataOk (Mac48Address address, const WifiMacHeader *header,
double ackSnr, WifiMode ackMode, double dataSnr);
double ackSnr, WifiMode ackMode, double dataSnr, double packetTime);
/**
* Should be invoked after calling ReportRtsFailed if
* NeedRtsRetransmission returns false
Expand Down Expand Up @@ -394,6 +398,7 @@ class WifiRemoteStationManager : public Object
WifiMode GetControlAnswerMode (Mac48Address address, WifiMode reqMode);
uint32_t GetNFragments (Ptr<const Packet> packet);


typedef std::vector <WifiRemoteStation *> Stations;
typedef std::vector <WifiRemoteStationState *> StationStates;

Expand Down

0 comments on commit d5d09d3

Please sign in to comment.