[pox-dev] problem in discovery.py function

2019-07-07 Thread AASIF MNIT
I am working on a security project, and unable to get the function of the
following method which is in discovery.py

def __init__ (self, send_cycle_time, ttl = 120):

please help me in understanding this method


[pox-dev] problem in lldp.py

2019-07-07 Thread AASIF MNIT
The following is code from lldp.py, I am unable to get use of parameters
used in methods, please help me.


def __init__ (self, raw=None, prev=None, **kw):
packet_base.__init__(self)

self.prev = prev

self.next = None
self.tlvs = []

if raw is not None:
  self.parse(raw)

self._init(kw)


Re: [pox-dev] problem in lldp.py

2019-07-07 Thread Murphy McCauley
The constructor arguments are basically the same for all classes in the
packet library.

raw is used if you are parsing a raw packet that's held in a bytes/str
object.
prev is mostly used internally to build chains of packet headers.  That is,
since most packet headers are preceded by other packet headers, a packet's
.prev usually points to the preceding one.  But most of the time you don't
manually set it in the constructor; usually the right thing happens without
you having to worry about it.

If you're constructing a packet from scratch, you use keyword arguments.
This isn't that useful for LLDP packets.  It's more useful for things like
TCP packets.  It's more or less a shortcut so that you can do things like:
mypacket = foo(bar = 42)

Instead of:
mypacket = foo()
foo.bar = 42

LLDP packets don't really have many fields, though.  They're basically just
a list of TLVs.  So the more common way to use it is just to create an
empty LLDP header and append TLVs.  discovery does this, for example:
https://github.com/noxrepo/pox/blob/eel/pox/openflow/discovery.py#L189

-- Murphy

On Sun, Jul 7, 2019 at 6:01 AM AASIF MNIT  wrote:

> The following is code from lldp.py, I am unable to get use of parameters
> used in methods, please help me.
>
>
> def __init__ (self, raw=None, prev=None, **kw):
> packet_base.__init__(self)
>
> self.prev = prev
>
> self.next = None
> self.tlvs = []
>
> if raw is not None:
>   self.parse(raw)
>
> self._init(kw)
>


Re: [pox-dev] problem in discovery.py function

2019-07-07 Thread Murphy McCauley
So this is the constructor for LLDPSender.  The docstring explains what the
two parameters are.  ttl probably isn't that important.  send_cycle_time
has to do with how fast discovery is sending packets.

You don't usually construct LLDPSenders yourself, though.  Normally, the
discovery component (class Discovery) constructs them for you -- all you
need to do is put "openflow.discovery" on the POX commandline.

If you're trying to modify how discovery works or something, you might get
better help if you explained what you were actually trying to accomplish.

-- Murphy

On Sun, Jul 7, 2019 at 5:59 AM AASIF MNIT  wrote:

> I am working on a security project, and unable to get the function of the
> following method which is in discovery.py
>
> def __init__ (self, send_cycle_time, ttl = 120):
>
> please help me in understanding this method
>
>