39#ifndef MMAC_UW_DACAP_H
40#define MMAC_UW_DACAP_H
50#define HDR_DACAP(P) (hdr_dacap::access(P))
52#define DACAP_DROP_REASON_WRONG_STATE \
55#define DACAP_DROP_REASON_WRONG_RECEIVER \
57#define DACAP_DROP_REASON_UNKNOWN_TYPE \
59#define DACAP_DROP_REASON_BUFFER_FULL \
122 virtual void expire(Event *e);
147 virtual void expire(Event *e);
179 virtual int command(
int argc,
const char *
const *argv);
245 virtual void initPkt(Packet *p,
int pkt_type);
259 virtual void txAck();
269 virtual void txRts();
273 virtual void txCts();
277 virtual void txWrn();
538 Packet::free(
Q.front());
555 return up_data_pkts_rx;
624 return MMac::resetStats();
633 return (up_data_pkts_rx -
Q.size());
717 backoffSumDuration(duration);
746 std::queue<Packet *>
Q;
Class that represents the backoff timer in DACAP.
DACAPBTimer(MMacDACAP *m)
Costructor of the class DACAPBTimer.
virtual void expire(Event *e)
Method called when the timer expire.
MMacDACAP *int wait_reason
< Pointer to an object of MMacDACAP class
Class that represents the timers in DACAP.
virtual void expire(Event *e)
Method call when the timer expire.
DACAPTimer(MMacDACAP *m)
Costructor of the class DACAPTimer.
MMacDACAP *int wait_reason
< Pointer to an object of MMacDACAP class
Class that represents a DACAP node.
double wait_costant
Additive factor in the calculation of ACK timer.
ofstream fout
Object that handle the file where the state transitions is written (if the print_transitions option i...
DACAPBTimer backoff_timer
backoff timer
int op_mode
Indicates if the ACK_mode or no_ACK_mode is activated.
virtual int getWrnPktsRx()
virtual void stateWaitXCts()
The protocol is in WaitXCts state.
virtual void waitForUser()
Used for debug purposes.
virtual double getMeanDeferTime()
bool warning_sent
true if a WRN packet has been just sent
MMacDACAP()
Costructor of the MMacDACAP class.
virtual int getTotalDeferTimes()
int ACK_size
Size (in bytes) of the ACK packet.
bool print_transitions
true if the state-transitions of the protocol is printed on a file
virtual int getRtsPktsTx()
virtual void txRts()
Pass a RTS packet to transmit to the PHY layer.
virtual void incrWrnPktsRx()
Increases the counter of WRN packets received.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
Packet * curr_data_pkt
Pointer to the current data packet.
virtual void stateDeferData()
The protocol is in the DeferData state.
int last_reason
last reason for the change of state
bool backoff_freeze_mode
true if the backoff-timer is freezed
int u_data_id
simulation-unique DATA packet ID
bool has_buffer_queue
true if the node has a buffer queue to store data packets
int WRN_size
Size (in bytes) of the WRN packet.
double alpha_
smoothing factor used for statistics using first order IIR filter
double max_tx_tries
Maximum transmission tries for one packet before discarding the packet.
virtual int getCtsPktsRx()
double max_prop_delay
One way maximum propagation delay (in seconds) in the network.
double session_distance
Distance between sender and receiver in the current session.
double sumrtt2
sum of (RTT^2)
int last_data_id_tx
Unique ID of the last data packet transmitted.
int CTS_size
Size (in bytes) of the CTS packet.
static int u_pkt_id
simulation-unique packet ID
int txsn
serial number of the DATA packet transmitted
virtual int getQueueSize()
double backoff_remaining
Backoff time remaining (if the timer is freezed)
virtual void stateSendWarning()
The protocol is in the SendWarning state.
int rts_pkts_tx
Counter of RTS packets TX.
virtual void stateWaitXAck()
The protocol is in WaitXAck state.
int curr_dest_addr
MAC address of the current node involved in this session.
virtual void rxStateIdle(Packet *p)
The case of reception while the protocol is in IDLE state is handled.
virtual void incrRtsPktsTx()
Increases the counter of RTS packets transmitted.
double sum_defer_time
Sum of the defer timers.
int buffer_pkts
Dimension (in packets) of the buffer queue.
double defer_times_no
Counter of defer times.
virtual double computeTxTime(int type)
Computes the time that is needed to transmit a packet, implementing a CrLayMessage for asking the PHY...
virtual void backoffStartTime()
Sets the start time of the backoff timer to NOW.
int prev_state
Previous state of the protocol.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
virtual void rxStateWaitXData(Packet *p)
The case of reception while the protocol is in WaitXData state is handled.
virtual void rxStateWaitXCts(Packet *p)
The case of reception while the protocol is in WaitXCts state is handled.
std::queue< Packet * > Q
MAC queue used for packet scheduling.
virtual void resetStats()
Resets all the stats counters.
int max_payload
Dimension of the maximum allowed data paylaod in bytes.
virtual void rxStateWaitWarning(Packet *p)
The case of reception while the protocol is in WaitWarning state is handled.
int sleep_node_2
MAC address of sleep_node 2.
double start_tx_time
Timestamp at which a packet is transmitted.
double delta_D
Value (in m) that indicates how far we want the CTS propagates over the sender before initiate the da...
int RTS_size
Size (in bytes) of the RTS packet.
bool TxActive
true if a transmission process is occuring
virtual void rxStateWaitXAck(Packet *p)
The case of reception while the protocol is in WaitXAck state is handled.
bool backoff_pending
true if the backoff-timer is active (i.e.
bool multihop_mode
true if the multihop mode is active to simulate a multihop scenario with routing
double backoff_start_time
Backoff starting time.
virtual void txAck()
Pass an ACK packet to transmit to the PHY layer.
virtual void deferEndTime(double duration)
Sets the end time of the defer summing the duration to the actual duration of defer.
virtual void refreshState(int state)
Refresh the state of the protocol.
virtual void setBackoffNodes(double node, double node_b)
Saves the MAC address of another couple of nodes that is the handshake procedure in order to access t...
int HDR_size
Size (in bytes) of the header added by DACAP.
virtual void rxStateSendWarning(Packet *p)
The case of reception while the protocol is in SendWarning state is handled.
double max_backoff_counter
Number of times a backoff is calculated.
virtual void queuePop(bool flag=true)
Pop the first element of the queue.
virtual void stateDataReceived(Packet *data_pkt)
The protocol is in the DataReceived state.
virtual void rxStateWaitData(Packet *p)
The case of reception while the protocol is in WaitDATA state is handled.
virtual double getRecontendTime()
Used in multihop mode.
int last_data_id_rx
Unique ID of the last data packet received.
int wrn_pkts_rx
Counter of WRN packets RX.
virtual void rxStateBackoff(Packet *p)
The case of reception while the protocol is in BACKOFF state is handled.
virtual void initPkt(Packet *p, int pkt_type)
Initializes the packet with the correct MAC source address and destination address,...
bool RxActive
true if a reception process is occuring
virtual double getBackoffTime()
Calculate the backoff time if the node didn't received the ACK.
int rttsamples
num of RTT samples
virtual int getWrnPktsTx()
int cts_pkts_tx
Counter of CTS packets TX.
virtual int getRemainingPkts()
virtual void recvFromUpperLayers(Packet *p)
Receive the packet from the upper layer (e.g.
virtual void incrCtsPktsRx()
Increases the counter of CTS packets received.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual void stateSendAck()
The protocol is in SendAck state.
bool session_active
true if a session is active (i.e.
virtual void rxStateWaitXWarning(Packet *p)
The case of reception while the protocol is in WaitXWarning state is handled.
virtual void stateWaitWarning()
The protocol is in WaitWarning state.
int rts_pkts_rx
Counter of RTS packets RX.
virtual void stateWaitXWarning()
The protocol is in WaitXWarning state.
virtual void incrWrnPktsTx()
Increases the counter of WRN packets transmitted.
virtual void stateCTSReceived()
The protocol is in the CTSReceived state.
int sleep_node_1
MAC address of sleep_node 1.
virtual void stateWaitData()
The protocol is in the WaitData state.
virtual void stateSendData()
The protocol is in the SendData state.
virtual void rxStateRecontendWindow(Packet *p)
The case of reception while the protocol is in RecontendWindow state is handled.
virtual void incrTotalDeferTimes()
Increases the number of times a transmission is deferred.
virtual void initInfo()
Initializes the protocol at the beginning of the simulation.
virtual void stateBackoff()
The protocol is in Backoff state.
virtual void rxStateWaitACK(Packet *p)
The case of reception while the protocol is in WaitACK state is handled.
double t_min
Minimum time needed to do an hand-shaking.
int curr_state
Current state of the protocol.
virtual void incrCtsPktsTx()
Increases the counter of CTS packets transmitted.
virtual void stateWaitCTS()
The protocol is in the WaitCTS state.
double backoff_duration
Backoff duration.
virtual void txWrn()
Pass a WRN packet to transmit to the PHY layer.
virtual int getCtsPktsTx()
virtual void freezeBackoff()
Freezes the Backoff timer.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
double T_W_min
Minimum Warning Time in sencods.
virtual void rxStateWaitCTS(Packet *p)
The case of reception while the protocol is in WaitCTS state is handled.
DACAPTimer timer
ACK timer.
double sumrtt
sum of RTT samples
int getUpLayersDataPktsRx()
int cts_pkts_rx
Counter of CTS packets RX.
double RTS_sent_time
Timestamp at which the RTS packet is sent.
double delta_data
Dimension difference (in bytes) among data packets ( 0 if the packets have always the same dimension...
virtual void stateRecontendWindow()
The protocol is in RecontendWindow state.
virtual void incrRtsPktsRx()
Increases the counter of RTS packets received.
virtual void exitSleep()
This method erase the MAC address of the two nodes that have intiated a handshake procedure if this h...
virtual void exitBackoff()
The backoff timer is stopped.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void txCts()
Pass a CTS packet to transmit to the PHY layer.
int backoff_counter
Number of times a backoff timer is set up.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
virtual int getRtsPktsRx()
bool defer_data
true if a node has to defer the transmission of a data packet
virtual ~MMacDACAP()
Destructor of the MMacDACAP class.
virtual void printStateInfo(double delay=0)
Prints a file with every state change for debug purposes.
int wrn_pkts_tx
Counter of WRN packets TX.
static map< int, string > info
Relationship between the state and its textual description.
virtual double computeWaitTime(int mode, double distance)
Computes the T_w parameter, that is the minimum time that the sender has to wait between the receptio...
virtual void backoffEndTime()
calculates the End Time of the backoff timer
virtual void stateIdle()
The protocol is in the IDLE state.
virtual void txData()
Pass a DATA packet to transmit to the PHYl layer.
double backoff_tuner
Multiplicative factor in the calculation of backoff.
double backoff_first_start
Timestamp at which the backoff timer is started for the first time (if the timer has been freezed man...
virtual void stateWaitACK()
The protocol is in the WaitACK state.
virtual void stateSendRTS()
The protocol is in SendRTS state.
virtual void stateWaitXData()
The protocol is in WaitXData state.
virtual void stateSendCTS()
The protocol is in SendCTS state.
Definition of the header of DACAP packets.
int sn
sequence number of this packet
static int offset_
Required by the PacketHeaderManager.
static int & offset()
Reference to the offset variable.
int dacap_type
sequence number of this packet
int tx_tries
Number of transmission tries of the packet.
int data_sn
Sequence number of the packet.
static struct hdr_dacap * access(const Packet *p)
Access to this header in the Packet.
double ts
packet timestamp, i.e., its generation time)
packet_t orig_type
Original type of the packet.