A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ppp-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef PPP_HEADER_H
19#define PPP_HEADER_H
20
21#include "ns3/header.h"
22
23namespace ns3
24{
25
26/**
27 * \ingroup point-to-point
28 * \brief Packet header for PPP
29 *
30 * This class can be used to add a header to PPP packet. Currently we do not
31 * implement any of the state machine in \RFC{1661}, we just encapsulate the
32 * inbound packet send it on. The goal here is not really to implement the
33 * point-to-point protocol, but to encapsulate our packets in a known protocol
34 * so packet sniffers can parse them.
35 *
36 * if PPP is transmitted over a serial link, it will typically be framed in
37 * some way derivative of IBM SDLC (HDLC) with all that that entails.
38 * Thankfully, we don't have to deal with all of that -- we can use our own
39 * protocol for getting bits across the serial link which we call an ns3
40 * Packet. What we do have to worry about is being able to capture PPP frames
41 * which are understandable by Wireshark. All this means is that we need to
42 * teach the PcapWriter about the appropriate data link type (DLT_PPP = 9),
43 * and we need to add a PPP header to each packet. Since we are not using
44 * framed PPP, this just means prepending the sixteen bit PPP protocol number
45 * to the packet. The ns-3 way to do this is via a class that inherits from
46 * class Header.
47 */
48class PppHeader : public Header
49{
50 public:
51 /**
52 * \brief Construct a PPP header.
53 */
54 PppHeader();
55
56 /**
57 * \brief Destroy a PPP header.
58 */
59 ~PppHeader() override;
60
61 /**
62 * \brief Get the TypeId
63 *
64 * \return The TypeId for this class
65 */
66 static TypeId GetTypeId();
67
68 /**
69 * \brief Get the TypeId of the instance
70 *
71 * \return The TypeId for this instance
72 */
73 TypeId GetInstanceTypeId() const override;
74
75 void Print(std::ostream& os) const override;
76 void Serialize(Buffer::Iterator start) const override;
78 uint32_t GetSerializedSize() const override;
79
80 /**
81 * \brief Set the protocol type carried by this PPP packet
82 *
83 * The type numbers to be used are defined in \RFC{3818}
84 *
85 * \param protocol the protocol type being carried
86 */
87 void SetProtocol(uint16_t protocol);
88
89 /**
90 * \brief Get the protocol type carried by this PPP packet
91 *
92 * The type numbers to be used are defined in \RFC{3818}
93 *
94 * \return the protocol type being carried
95 */
96 uint16_t GetProtocol() const;
97
98 private:
99 /**
100 * \brief The PPP protocol type of the payload packet
101 */
102 uint16_t m_protocol;
103};
104
105} // namespace ns3
106
107#endif /* PPP_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
Packet header for PPP.
Definition: ppp-header.h:49
uint16_t m_protocol
The PPP protocol type of the payload packet.
Definition: ppp-header.h:102
void SetProtocol(uint16_t protocol)
Set the protocol type carried by this PPP packet.
Definition: ppp-header.cc:97
uint32_t Deserialize(Buffer::Iterator start) override
Definition: ppp-header.cc:90
TypeId GetInstanceTypeId() const override
Get the TypeId of the instance.
Definition: ppp-header.cc:53
static TypeId GetTypeId()
Get the TypeId.
Definition: ppp-header.cc:43
~PppHeader() override
Destroy a PPP header.
Definition: ppp-header.cc:38
uint32_t GetSerializedSize() const override
Definition: ppp-header.cc:78
void Serialize(Buffer::Iterator start) const override
Definition: ppp-header.cc:84
uint16_t GetProtocol() const
Get the protocol type carried by this PPP packet.
Definition: ppp-header.cc:103
PppHeader()
Construct a PPP header.
Definition: ppp-header.cc:34
void Print(std::ostream &os) const override
Definition: ppp-header.cc:59
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.