#ifndef TSN_NET_DEVICE_H #define TSN_NET_DEVICE_H #include "ns3/ethernet-net-device.h" #include "ns3/packet.h" #include "ns3/queue.h" #include "ns3/tsn-node.h" #include "ns3/tsn-transmission-selection-algo.h" #include "ns3/tas.h" // Add a doxygen group for this module. // If you have more than one file, this should be in only one of them. /** * \defgroup tsn Description of the tsn */ namespace ns3 { class Tas; class TsnNode; class TsnNetDevice : public EthernetNetDevice { public: /** * \brief Get the TypeId * * \return The TypeId for this class */ static TypeId GetTypeId(); /** * \brief Create a TsnNetDevice */ TsnNetDevice(); /** * Destroy a TsnNetDevice * * This is the destructor for the TsnNetDevice. */ ~TsnNetDevice(); /** * Attach a queue to the TsnNetDevice. * * The TsnNetDevice "owns" a queue that implements a queueing * method such as DropTailQueue * * \param queue Ptr to the new queue. */ void SetQueue(Ptr> queue); /** * Attach a queue and a Transmission Selection Algo to the TsnNetDevice. * * \param queue Ptr to the new queue. * \param tsa Ptr to the new Transmission Selection Algo. */ void SetQueue(Ptr> q, Ptr tsa); /** * Update existing queue with a queue and a Transmission Selection Algo. * * \param queue_id of the queue to update * \param queue Ptr to the new queue. * \param tsa Ptr to the new Transmission Selection Algo. */ void UpdateQueue(uint32_t queue_id, Ptr> q, Ptr tsa); bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t ethertype) override; /** * This function is use to put GPTP frame in a specific FIFO without using QTAG */ bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t ethertype, uint8_t pcp); /** * This function is use to put GPTP frame in a specific FIFO without using QTAG */ bool SendWithSpecificFIFO(Ptr packet, const Address& dest, uint16_t ethertype, uint8_t pcp); /** * Receive a packet from a connected TsnNetDevice. * * The TsnNetDevice 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 p) override; typedef Callback, Ptr, uint16_t, const Address&, Time> ReceiveCallbackWithTimestamp; void SetReceiveCallbackWithTimestamp(ReceiveCallbackWithTimestamp cb); typedef Callback, Time> TransmitCallbackWithTimestamp; void SetTransmitCallbackWithTimestamp(TransmitCallbackWithTimestamp cb); void SetNode(Ptr node); void AddGclEntry(Time duration, uint8_t states); void StartTas(); void StartTas(Time startTime); Ptr GetTas(); void CheckForReadyPacket() override; Ptr GetNode(); protected : /** * 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 * \param queue_id queue id of the packet to send * \returns true if success, false on failure */ bool TransmitStart(Ptr 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(int queue_id); /** * * */ int TransmitSelection() override; /** * The trace source fired when packets are drop by FRER recovery function */ TracedCallback> m_frerDropTrace; /** * The trace source fired when packets are drop by the MaxSDUSizeFilter (PSFP) */ TracedCallback> m_maxSDUSizeFilterDropTrace; /** * The trace source fired when packets are drop by the Flow Meter (PSFP) */ TracedCallback> m_REDFrameDropTrace; ReceiveCallbackWithTimestamp m_rxCallbackWithTimestamp; TransmitCallbackWithTimestamp m_txCallbackWithTimestamp; //FRER /** * The TransmissionSelectionAlgos which this TsnNetDevice uses */ std::vector> m_transmissionSelectionAlgos; Ptr m_node; //!< TSN Node owning this NetDevice bool m_txHardwareLatencyExperienced = false; private: /** * Find the nextEligible Queue for transimission * * \returns Int id to the queue. */ Ptr m_tas; EventId m_NextGatesUpdate; }; } #endif /* TSN_NET_DEVICE_H */