23 #include "peer-management-protocol-mac.h"
24 #include "ns3/peer-link.h"
26 #include "ns3/simulator.h"
27 #include "ns3/traced-value.h"
34 NS_OBJECT_ENSURE_REGISTERED ( PeerLink);
41 .AddConstructor<PeerLink> ()
42 .AddAttribute (
"RetryTimeout",
46 &PeerLink::m_dot11MeshRetryTimeout),
49 .AddAttribute (
"HoldingTimeout",
53 &PeerLink::m_dot11MeshHoldingTimeout),
56 .AddAttribute (
"ConfirmTimeout",
60 &PeerLink::m_dot11MeshConfirmTimeout),
63 .AddAttribute (
"MaxRetries",
64 "Maximum number of retries",
66 MakeUintegerAccessor (
67 &PeerLink::m_dot11MeshMaxRetries),
68 MakeUintegerChecker<uint16_t> ()
70 .AddAttribute (
"MaxBeaconLoss",
71 "Maximum number of lost beacons before link will be closed",
73 MakeUintegerAccessor (
74 &PeerLink::m_maxBeaconLoss),
75 MakeUintegerChecker<uint16_t> (1)
77 .AddAttribute (
"MaxPacketFailure",
78 "Maximum number of failed packets before link will be closed",
80 MakeUintegerAccessor (
81 &PeerLink::m_maxPacketFail),
82 MakeUintegerChecker<uint16_t> (1)
100 m_beaconInterval (
Seconds (0)),
107 PeerLink::~PeerLink ()
116 m_beaconLossTimer.
Cancel ();
125 PeerLink::SetPeerMeshPointAddress (
Mac48Address macaddr)
130 PeerLink::SetInterface (uint32_t interface)
135 PeerLink::SetLocalLinkId (uint16_t
id)
140 PeerLink::SetLocalAid (uint16_t aid)
149 m_beaconLossTimer.
Cancel ();
170 PeerLink::TransmissionFailure ()
181 PeerLink::SetBeaconTimingElement (IeBeaconTiming beaconTiming)
186 PeerLink::GetPeerAddress ()
const
191 PeerLink::GetLocalAid ()
const
196 PeerLink::GetPeerAid ()
const
202 PeerLink::GetLastBeacon ()
const
207 PeerLink::GetBeaconInterval ()
const
212 PeerLink::GetBeaconTimingElement ()
const
374 SendPeerLinkClose (reasoncode);
385 SendPeerLinkConfirm ();
412 SendPeerLinkConfirm ();
418 SendPeerLinkClose (REASON11S_MESH_CLOSE_RCVD);
426 SendPeerLinkClose (reasoncode);
433 SendPeerLinkClose (REASON11S_MESH_MAX_RETRIES);
440 SendPeerLinkClose (REASON11S_PEERING_CANCELLED);
457 ClearConfirmTimer ();
458 SendPeerLinkConfirm ();
464 ClearConfirmTimer ();
465 SendPeerLinkClose (REASON11S_MESH_CLOSE_RCVD);
472 ClearConfirmTimer ();
473 SendPeerLinkClose (reasoncode);
479 ClearConfirmTimer ();
480 SendPeerLinkClose (REASON11S_PEERING_CANCELLED);
486 SendPeerLinkClose (REASON11S_MESH_CONFIRM_TIMEOUT);
513 SendPeerLinkClose (REASON11S_MESH_CLOSE_RCVD);
521 SendPeerLinkClose (reasoncode);
528 SendPeerLinkClose (REASON11S_MESH_MAX_RETRIES);
535 SendPeerLinkClose (REASON11S_PEERING_CANCELLED);
548 SendPeerLinkConfirm ();
553 SendPeerLinkClose (REASON11S_MESH_CLOSE_RCVD);
561 SendPeerLinkClose (reasoncode);
567 SendPeerLinkClose (REASON11S_PEERING_CANCELLED);
580 ClearHoldingTimer ();
590 SendPeerLinkClose (REASON11S_PEERING_CANCELLED);
596 SendPeerLinkClose (reasoncode);
607 PeerLink::ClearRetryTimer ()
612 PeerLink::ClearConfirmTimer ()
617 PeerLink::ClearHoldingTimer ()
624 IePeerManagement peerElement;
630 PeerLink::SendPeerLinkOpen ()
632 IePeerManagement peerElement;
639 PeerLink::SendPeerLinkConfirm ()
641 IePeerManagement peerElement;
647 PeerLink::SetHoldingTimer ()
650 m_holdingTimer =
Simulator::Schedule (m_dot11MeshHoldingTimeout, &PeerLink::HoldingTimeout,
this);
653 PeerLink::HoldingTimeout ()
658 PeerLink::SetRetryTimer ()
661 m_retryTimer =
Simulator::Schedule (m_dot11MeshRetryTimeout, &PeerLink::RetryTimeout,
this);
664 PeerLink::RetryTimeout ()
666 if (m_retryCounter < m_dot11MeshMaxRetries)
676 PeerLink::SetConfirmTimer ()
679 m_confirmTimer =
Simulator::Schedule (m_dot11MeshConfirmTimeout, &PeerLink::ConfirmTimeout,
this);
682 PeerLink::ConfirmTimeout ()
693 os <<
"<PeerLink" << std::endl <<
695 "peerInterfaceAddress=\"" <<
m_peerAddress <<
"\"" << std::endl <<
701 "assocId=\"" <<
m_assocId <<
"\"" << std::endl <<
void TransmissionSuccess()
Reports about transmission success/failure.
Mac48Address m_peerMeshPointAddress
void MLMECancelPeerLink(PmpReasonCode reason)
MLME-CancelPeerLink.request.
void Report(std::ostream &os) const
Statistics.
SignalStatusCallback m_linkStatusCallback
How to report my status change.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
IeConfiguration m_configuration
Mesh interface configuration.
void StateMachine(PeerEvent event, PmpReasonCode=REASON11S_RESERVED)
State transition.
bool LinkIsIdle() const
True if link is idle. Link can be deleted in this state.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
IeBeaconTiming m_beaconTiming
Beacon timing element received from the peer. Needed by BCA.
Ptr< PeerManagementProtocolMac > m_macPlugin
pointer to MAC plugin, which is responsible for peer management
void OpenAccept(uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp)
Accept open link.
double GetSeconds(void) const
uint16_t m_peerLinkId
Peer ID of this link.
void BeaconLoss()
Several successive beacons were lost, close link.
uint16_t m_packetFail
How many successive packets were failed to transmit.
int64_t GetMicroSeconds(void) const
hold objects of type ns3::Time
Hold an unsigned integer type.
PeerLink()
C-tor create empty link.
also timeout of retry timer
uint16_t m_assocId
My association ID.
static Mac48Address GetBroadcast(void)
void SetMacPlugin(Ptr< PeerManagementProtocolMac > plugin)
void Close(uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason)
Close link.
void MLMEActivePeerLinkOpen()
MLME-ActivePeerLinkOpen.request.
PeerState m_state
Current state.
Mac48Address m_peerAddress
Peer address.
PeerLinkOpenReject by internal reason.
Mac48Address GetAddress() const
debug only, used to print established links
void MLMESetSignalStatusCallback(SignalStatusCallback)
Set callback.
void SetBeaconInformation(Time lastBeacon, Time BeaconInterval)
Process beacon received from peer.
Timeout of confirm timer.
uint16_t m_peerAssocId
Assoc Id assigned to me by peer.
bool LinkIsEstab() const
True if link is established.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
PeerEvent
Peer link events, see 802.11s draft 11B.3.3.2.
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
Time m_beaconInterval
Current beacon interval on corresponding interface.
uint16_t m_localLinkId
My ID of this link.
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
Time m_lastBeacon
When last beacon was received.
static TypeId GetTypeId()
Support object system.
a base class which provides memory management and object aggregation
uint32_t m_interface
The number of interface I am associated with.
Timeout of holding (graceful closing) timer.
void ConfirmReject(uint16_t localLinkId, uint16_t peerLinkId, IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
Confirm reject.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Time MicroSeconds(uint64_t us)
create ns3::Time instances in units of microseconds.
void ConfirmAccept(uint16_t localLinkId, uint16_t peerLinkId, uint16_t peerAid, IeConfiguration conf, Mac48Address peerMp)
Confirm accept.
void MLMEPeeringRequestReject()
MLME-PeeringRequestReject.
void OpenReject(uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
Reject open link.