i To you All,
I am trying to implement LCP in c++. I am using the below article
The actual article "Efficiently Coding Communications Protocols in C+
is given at-
I am facing some problems in understanding the article .
Can any one help me ...
I am marking in red the places I got stuck....
Implementing the Point-to-Point Protocol
Now we will look at a specific protocol, the Point-to-Point Protocol
(PPP) as defined in RFC-
1661. The Point-to-Point protocol is actually a family of protocols
sharing the same
encapsulation. A PPP implementation must include the Link Control
Protocol (LCP) and one or
more Network Control Protocols, one for each network protocol
supported. The most common
Network Control Protocol is the IP Control Protocol or IPCP. A PPP
implementation may also
include one or more authorization protocols. So the actual structure
of the PPP layer is a bit
more complex than the idealized structure shown above. The figure
below shows the structure
for the PPP protocol. It include of a single receiver and transmitter
that implement the message
encapsulation and message semantics. The LCP, each NCP and each
include a context and their own state.
The State Pattern
The table shows the complexity of the protocol's behavior and coding
this state machine as C
case statements or if-else statements is a daunting task. However, the
protocol state is easily
implemented as a number of simple C++ classes using the State Pattern
described in Design
Patterns by Gamma, et al. shown below.
The LcpContext and LcpState Base Class
The class declaration for the LcpContext is show below. Note that we
have declared methods for
every event and action defined by the protocol. The LcpState class is
declared as a friend class so
that it has access to the private methods for executing actions and to
change the LcpContext's
LcpContext(LcpState* initialState, PppTransmitter* transmitter);
friend class LcpState;
void changeLcpState(LcpState* state);
The implementation of the event methods is simple. The event
processing is simply deferred to
the State object pointed to by _state.
_state->up(this); // why is this needed I donot understand...
The action methods are also simple, deferring the processing to a
transmitter or timer object.
This decouples the State objects from the PppTransmitter, PppReceiver,
and LcpTimer classes so
that the state classes can be easily used for a number of PPP
applications such as PPP over