#include <P2PPhyLayer.h>
Inherits ChannelAccess.
Inheritance diagram for P2PPhyLayer:
Public Member Functions | |
Module_Class_Members (P2PPhyLayer, ChannelAccess, 0) | |
virtual void | initialize (int) |
Initialization of the module and some variables. | |
virtual void | finish () |
void | handleMessage (cMessage *) |
Called every time a message arrives. | |
virtual void | receiveBBItem (int category, const BBItem *details, int scopeModuleId) |
Called by the Blackboard whenever a change occurs we're interested in. | |
Protected Types | |
enum | P2PPhyKinds { RECEPTION_COMPLETE = 1350101811 } |
The kind field of messages. More... | |
Protected Member Functions | |
virtual double | calcDuration (cMessage *) |
This function calculates the duration of the AirFrame. | |
Handle Messages | |
Functions to redefine by the programmer
These are the functions provided to add own functionality to your modules. These functions are called whenever a blackboard message, a self message or a data message from the upper or lower layer arrives respectively. | |
virtual void | handleSelfMsg (cMessage *msg) |
Handle self messages such as timer... | |
virtual void | handleUpperMsg (AirFrame *, int) |
Handle messages from upper layer. | |
virtual void | handleLowerMsg (AirFrame *) |
Handle messages from lower layer. | |
Convenience Functions | |
Functions for convenience - NOT to be modified
These are functions taking care of message encapsulation and message sending. Normally you should not need to alter these but should use them to handle message encasulation and sending. They will wirte all necessary information into packet headers and add or strip the appropriate headers for each layer. | |
AirFrame * | encapsMsg (cMessage *) |
Encapsulate the MacPkt into an AirFrame. | |
void | bufferMsg (AirFrame *) |
Buffer message upon reception. | |
AirFrame * | unbufferMsg (cMessage *) |
Unbuffer message after it is completely received. | |
void | sendP2P (AirFrame *, int) |
Sends a unicast message; waits delay seconds before sending. | |
void | sendDown (AirFrame *, int) |
Sends a message to the channel; waits delay seconds before sending. | |
void | sendUp (AirFrame *) |
Sends a message to the upper layer; waits delay seconds before sending. | |
void | sendDelayedP2P (AirFrame *, double, int) |
Sends a unicast message. | |
void | sendDelayedDown (AirFrame *, double, int) |
Sends a message to the channel. | |
void | sendDelayedUp (AirFrame *, double) |
Sends a message to the upper layer. | |
void | sendControlUp (cMessage *) |
Sends a control message to the upper layer. | |
Abstraction layer | |
Factory function to create AirFrame into which a MAC frame is encapsulated. SnrEval authors should be able to use their own SnrEval packets. The framework does not need to know about them, but must be able to produce new ones. Both goals can be reached by using a factory method.
Overwrite this function in derived classes to use your own AirFrames | |
virtual AirFrame * | createCapsulePkt () |
Create a new AirFrame. | |
Protected Attributes | |
double | bitrate |
bitrate read from omnetpp.ini | |
int | headerLength |
length of the AirFrame header | |
double | pBit |
bit error rate (including all other loss possibilities for message losses) | |
double | transmitterPower |
power used to transmit messages | |
cMessage * | txOverTimer |
Timer to indicate the end of a transmission to a higher layer. | |
ActiveChannel | channel |
Currently active channel, set using radio, updated via BB. | |
int | catActiveChannel |
category number given by bb for ActiveChannel | |
int | uppergateOut |
gate ids | |
int | uppergateIn |
gate ids | |
int | upperControlOut |
gate ids |
This is the simplest physical layer you can think of.
It decides upon one simple parameter pBit (bit error rate) about the correctness of a frame. Collisions, bit errors, interference and anything else you can think of are combined in this single parameter.
|
The kind field of messages. that are used internally by this class have one of these values |
|
Buffer message upon reception. The packet is put in a buffer for the time the transmission would last in reality. A timer indicates when the transmission is complete. So, look at unbufferMsg to see what happens when the transmission is complete.. |
|
This function calculates the duration of the AirFrame. Usually the duration is just the frame length divided by the bitrate. However there may be cases (like 802.11) where the header has a different modulation (and thus a different bitrate) than the rest of the message. Just redefine this function in such a case! |
|
Encapsulate the MacPkt into an AirFrame. Encapsulate the received MacPkt into an AirFrame and set all needed header fields.
|
|
Handle messages from lower layer. Redefine this function if you want to process messages from the channel before they are forwarded to upper layers This basic implementation just checks whether a received packet had errors. Decision depends only on pBit (defined in omnetppp.ini) and the message length. The length field is assumed to be in bits. If you want to forward the message to upper layers please use sendUp which will decapsulate the MacPkt before sending |
|
Called every time a message arrives. The basic handle message function. Depending on the gate a message arrives handleMessage just calls different handle*Msg functions to further process the message. Messages from the channel are also buffered here in order to simulate a transmission delay You should not make any changes in this function but implement all your functionality into the handle*Msg functions called from here.
|
|
Handle self messages such as timer... Define this function if you want to timer or other kinds of self messages |
|
Handle messages from upper layer. Redefine this function if you want to process messages from upper layers before they are send to the channel. The MacPkt is already encapsulated in an AirFrame and all standard header fields are set. To forward the message to lower layers after processing it please use sendDown. It will take care of decapsulation and anything else needed
|
|
Initialization of the module and some variables. First we have to initialize the module from which we derived ours, in this case ChannelAccess. Then we have to intialize the gates and - if necessary - some own variables. Reimplemented from ChannelAccess. |
|
Sends a control message to the upper layer. send a control message to the upper layer |
|
Sends a message to the channel. For this special case the sending of the message as broadcast and unicast messages are handled differently. This function is only for convenience so that the programmer does not have to take care about the details of message sending
|
|
Sends a unicast message. Finds the destination gate of the recipient and sends the message only via the link which is connected to that gate.. This function is only used for the point-to-point sending and thus the specialily of the P2P network. Although the wireless channel is a broadcast channel and all hosts within interference distance should receive all messages sendP2P sends a message directly via unicast to the desired destination. This is only possible because we do not assume lost messages due to interference or collitions. All possible message losses are summed up in one parameter pBit.
|
|
Sends a message to the upper layer. decapsulate message and send it to the upper layer. to be called within handleLowerMsg. |
|
Sends a message to the channel; waits delay seconds before sending. Convenience function which calls sendDelayedDown with delay set to 0.0.
|
|
Sends a unicast message; waits delay seconds before sending. Convenience function which calls sendDelayedP2P with delay set to 0.0.
|
|
Sends a message to the upper layer; waits delay seconds before sending. Convenience function which calls sendDelayedUp with delay set to 0.0.
|
|
Unbuffer message after it is completely received. Get the context pointer to the now completely received AirFrame and delete the self message |
|
length of the AirFrame header
|