Drop CSMA packets with CRC errors, rescan, dox tweaks
This commit is contained in:
@@ -41,7 +41,7 @@ EthernetTrailer::EnableFcs (bool enable)
|
||||
}
|
||||
|
||||
bool
|
||||
EthernetTrailer::CheckFcs (Ptr<Packet> p) const
|
||||
EthernetTrailer::CheckFcs (Ptr<const Packet> p) const
|
||||
{
|
||||
int len = p->GetSize ();
|
||||
uint8_t *buffer;
|
||||
@@ -60,7 +60,7 @@ EthernetTrailer::CheckFcs (Ptr<Packet> p) const
|
||||
}
|
||||
|
||||
void
|
||||
EthernetTrailer::CalcFcs (Ptr<Packet> p)
|
||||
EthernetTrailer::CalcFcs (Ptr<const Packet> p)
|
||||
{
|
||||
int len = p->GetSize ();
|
||||
uint8_t *buffer;
|
||||
@@ -142,7 +142,7 @@ EthernetTrailer::Deserialize (Buffer::Iterator end)
|
||||
// This code is copied from /lib/crc32.c in the linux kernel.
|
||||
// It assumes little endian ordering.
|
||||
uint32_t
|
||||
EthernetTrailer::DoCalcFcs (uint8_t *buffer, size_t len) const
|
||||
EthernetTrailer::DoCalcFcs (uint8_t const *buffer, size_t len) const
|
||||
{
|
||||
uint32_t crc = 0xffffffff;
|
||||
int i;
|
||||
|
||||
@@ -34,8 +34,7 @@ namespace ns3 {
|
||||
* \brief Packet trailer for Ethernet
|
||||
*
|
||||
* This class can be used to add and verify the FCS at the end of an
|
||||
* ethernet packet. The actual FCS functionality is not yet coded and
|
||||
* so this acts more as a placeholder.
|
||||
* Ethernet packet.
|
||||
*/
|
||||
class EthernetTrailer : public Trailer
|
||||
{
|
||||
@@ -50,32 +49,41 @@ public:
|
||||
* \param enable If true, enables FCS calculations.
|
||||
*/
|
||||
void EnableFcs (bool enable);
|
||||
|
||||
/**
|
||||
* \brief Updates the Fcs Field to the correct FCS
|
||||
* \param p Reference to a packet on which the FCS should be
|
||||
* calculated. The packet should not currently contain an FCS
|
||||
* trailer.
|
||||
* calculated. The packet should not currently contain an
|
||||
* EthernetTrailer.
|
||||
*/
|
||||
void CalcFcs (Ptr<Packet> p);
|
||||
void CalcFcs (Ptr<const Packet> p);
|
||||
|
||||
/**
|
||||
* \brief Sets the FCS to a new value
|
||||
* \param fcs New FCS value
|
||||
*/
|
||||
void SetFcs (uint32_t fcs);
|
||||
|
||||
/**
|
||||
* \return the FCS contained in this trailer
|
||||
*/
|
||||
uint32_t GetFcs ();
|
||||
|
||||
/**
|
||||
* \param p Reference to the packet on which the FCS should be
|
||||
* calculated. The packet should not contain an FCS trailer.
|
||||
* \return Returns true if the packet fcs is correct, false otherwise.
|
||||
* Calculate an FCS on the provided packet and check this value against
|
||||
* the FCS found when the trailer was deserialized (the one in the transmitted
|
||||
* packet).
|
||||
*
|
||||
* If FCS checking is disabled, this method will always
|
||||
* return true.
|
||||
*
|
||||
* \param p Reference to the packet on which the FCS should be
|
||||
* calculated. The packet should not contain an EthernetTrailer.
|
||||
*
|
||||
* \return Returns true if the Packet FCS matches the FCS in the trailer,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool CheckFcs (Ptr<Packet> p) const;
|
||||
bool CheckFcs (Ptr<const Packet> p) const;
|
||||
|
||||
/**
|
||||
*\return Returns the size of the trailer
|
||||
@@ -90,17 +98,16 @@ public:
|
||||
virtual uint32_t Deserialize (Buffer::Iterator end);
|
||||
private:
|
||||
/**
|
||||
* Enabled FCS calculations. If false, fcs is set to 0 and checkFCS
|
||||
* Enabled FCS calculations. If false, m_fcs is set to 0 and CheckFcs
|
||||
* returns true.
|
||||
*/
|
||||
bool m_calcFcs;
|
||||
uint32_t m_fcs; /// Value of the fcs contained in the trailer
|
||||
|
||||
uint32_t DoCalcFcs (uint8_t *buffer, size_t len) const;
|
||||
uint32_t DoCalcFcs (uint8_t const *buffer, size_t len) const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
#endif /* ETHERNET_TRAILER_H */
|
||||
|
||||
Reference in New Issue
Block a user