Update README and add contrib dir
This commit is contained in:
228
contrib/tsn/model/tsn-multidrop-net-device.h
Normal file
228
contrib/tsn/model/tsn-multidrop-net-device.h
Normal file
@@ -0,0 +1,228 @@
|
||||
#ifndef TSN_MULTIDROP_NET_DEVICE_H
|
||||
#define TSN_MULTIDROP_NET_DEVICE_H
|
||||
|
||||
#include "ns3/tsn-net-device.h"
|
||||
#include "ns3/tsn-multidrop-channel.h"
|
||||
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
/**
|
||||
* \ingroup tsn
|
||||
* \class TsnMultidropNetDevice
|
||||
* \brief A Device for 10Base-T1S half duplex Link with PLCA.
|
||||
*
|
||||
* This TsnMultidropNetDevice class specializes the TsnNetDevice
|
||||
* class to simulate 10Base-T1S NIC with PLCA
|
||||
*
|
||||
*/
|
||||
|
||||
class TsnMultidropNetDevice : public TsnNetDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Get the TypeId
|
||||
*
|
||||
* \return The TypeId for this class
|
||||
*/
|
||||
static TypeId GetTypeId();
|
||||
|
||||
/**
|
||||
* Construct a TsnMultidropNetDevice
|
||||
*
|
||||
* This is the constructor for the TsnMultidropNetDevice. It takes as a
|
||||
* parameter a pointer to the Node to which this device is connected,
|
||||
* as well as an optional DataRate object.
|
||||
*/
|
||||
TsnMultidropNetDevice();
|
||||
|
||||
/**
|
||||
* Destroy a TsnMultidropNetDevice
|
||||
*
|
||||
* This is the destructor for the TsnMultidropNetDevice.
|
||||
*/
|
||||
~TsnMultidropNetDevice();
|
||||
|
||||
// Delete copy constructor and assignment operator to avoid misuse
|
||||
TsnMultidropNetDevice& operator=(const TsnMultidropNetDevice&) = delete;
|
||||
TsnMultidropNetDevice(const TsnMultidropNetDevice&) = delete;
|
||||
|
||||
/**
|
||||
* Attach the device to a channel.
|
||||
*
|
||||
* \param ch Ptr to the channel to which this object is being attached.
|
||||
* \return true if the operation was successful (always true actually)
|
||||
*/
|
||||
bool Attach(Ptr<TsnMultidropChannel> ch);
|
||||
|
||||
bool IsPointToPoint() const override;
|
||||
|
||||
|
||||
/**
|
||||
* Receive a packet from a connected EthernetMultidropNetDevice.
|
||||
*
|
||||
* The EthernetMultidropNetDevice receives packets from its connected channel
|
||||
* and forwards them up the protocol stack. This is the public method
|
||||
* used by the channel to indicate that the last bit of a packet has
|
||||
* arrived at the device.
|
||||
*
|
||||
* \param p Ptr to the received packet.
|
||||
*/
|
||||
void Receive(Ptr<Packet> p) override;
|
||||
|
||||
|
||||
bool SendFrom(Ptr<Packet> packet,
|
||||
const Address& source,
|
||||
const Address& dest,
|
||||
uint16_t ethertype) override;
|
||||
|
||||
void Send1Packet();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void StartBeaconReception();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void StopBeaconReception();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void StartReception();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
void EndReception();
|
||||
|
||||
enum PLCAState
|
||||
{
|
||||
/** Disable state */
|
||||
DISABLE,
|
||||
/** Recover state */
|
||||
RECOVER,
|
||||
/** Resync state */
|
||||
RESYNC,
|
||||
/** Send beacon state*/
|
||||
SEND_BEACON,
|
||||
/** Syncing state*/
|
||||
SYNCING,
|
||||
/** Wait transmit opportunity state*/
|
||||
WAIT_TO,
|
||||
/** Commit state*/
|
||||
COMMIT,
|
||||
/** Transmit state*/
|
||||
TRANSMIT,
|
||||
/** Burst state*/
|
||||
BURST,
|
||||
/** Receive state*/
|
||||
RECEIVE,
|
||||
/** Yield state*/
|
||||
YIELD,
|
||||
/** Abort state*/
|
||||
ABORT,
|
||||
/** Next tx opportunity state*/
|
||||
NEXT_TX_OPPORTUNITY,
|
||||
/** Early receive state*/
|
||||
EARLY_RECEIVE,
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* \brief Dispose of the object
|
||||
*/
|
||||
void DoDispose();
|
||||
|
||||
|
||||
/**
|
||||
* Start Sending a Packet Down the Wire.
|
||||
*
|
||||
* The TransmitStart method is the method that is used internally in the
|
||||
* EthernetNetDevice to begin the process of sending a packet out on
|
||||
* the channel. The corresponding method is called on the channel to let
|
||||
* it know that the physical device this class represents has virtually
|
||||
* started sending signals. An event is scheduled for the time at which
|
||||
* the bits have been completely transmitted.
|
||||
*
|
||||
* \see EthernetChannel::TransmitStart ()
|
||||
* \see TransmitComplete()
|
||||
* \param p a reference to the packet to send
|
||||
* \returns true if success, false on failure
|
||||
*/
|
||||
bool TransmitStart(Ptr<Packet> p, int queue_id);
|
||||
|
||||
/**
|
||||
* Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
|
||||
*
|
||||
* The TransmitComplete method is used internally to finish the process
|
||||
* of sending a packet out on the channel.
|
||||
*/
|
||||
void TransmitComplete();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
bool isPacketPending();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void PLCA();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void ToTimerDone();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void BeaconTimerDone();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void BeaconDetTimerDone();
|
||||
|
||||
/**
|
||||
* The TsnMultidropChannel to which this TsnMultidropNetDevice has
|
||||
* been attached.
|
||||
*/
|
||||
Ptr<TsnMultidropChannel> m_channel;
|
||||
|
||||
uint8_t m_PLCALocalNodeId;
|
||||
uint8_t m_PLCACurID = 0;
|
||||
uint8_t m_PLCANodeCount;
|
||||
uint8_t m_PLCATransmitOpportunityTimer;
|
||||
uint8_t m_PLCABurstCount = 0;
|
||||
uint8_t m_PLCAMaxBurstCount;
|
||||
uint8_t m_PLCABurstTimer;
|
||||
uint8_t m_PLCABeaconTimer = 20;
|
||||
uint8_t m_PLCABeaconDetTimer = 22;
|
||||
|
||||
bool m_PLCAactive = false;
|
||||
|
||||
|
||||
|
||||
PLCAState m_PLCAState = DISABLE;
|
||||
TracedCallback<PLCAState> m_PLCAStateTrace;
|
||||
|
||||
|
||||
EventId m_PLCAToTimerEvent;
|
||||
EventId m_PLCABeaconDetTimerEvent;
|
||||
|
||||
DataRate m_bps = DataRate("10Mb/s");
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* TSN_MULTIDROP_NET_DEVICE_H */
|
||||
Reference in New Issue
Block a user