Responses inline.

On Aug 19, 2011, at 4:13 PM, Chen Gao wrote:

> Dear All,
>  
> When I read component pyswitch.py,
>  
> 1.       there is code      if inst.st[dpid].has_key(srcaddr)               , 
> I understand that st is kind of a container who holds key dpid. And dpid 
> should correspond to an array who has elements such as source address and 
> destination address.
> My question is when did the container st has key dpid added, and where is the 
> file for defining dpid with its elements like srcaddr?


pyswitch needs to keep track of some state for every datapath (OpenFlow switch) 
that's connected.  That's what inst.st is used for.  inst.st is a plain Python 
dictionary (see line 156).  The keys in this are dpids (just numbers, really), 
and the values are the state that pyswitch needs to keep track of for the 
corresponding datapath.

So inst.sp[dpid] will get the data that pyswitch is keeping for a particular 
switch.

What is that data?  It turns out it's another plain Python dictionary (line 
138).

What's in that dictionary?  This is where pyswitch keeps the data it has 
"learned".  This is, most funamentally, a map of ethernet addresses to which 
port number they are out of.  However, pyswitch also keeps a timestamp and a 
reference to the packet that caused the entry to be inserted -- so it's 
actually a tuple (port, timestamp, packet). (line 71)

So inst.st[dpid][srcaddr][0] will give you the port number associated with 
srcaddr.  Of course, you might not have learned anything about srcaddr yet.  
You can check whether srcaddr is in the dictionary with 
inst.st[dpid].has_key(srcaddr).  This is kind of dated syntax.  The more modern 
way is to just say something like "if srcaddr in inst.st[dpid]".

So you're right that st is a kind of container (it's a dictionary).  But 
there's no array with elements such as source address and destination address, 
and there is no dpid class with elements like srcaddr.

What you have in short is:
inst.st: a dict that maps dpid->dict
inst.st[<a dpid>]: another dict that maps ethaddr->3-tuple
inst.st[<a dpid>][<an ethaddr>]: a 3-tuple of (port number, timestamp, packet)

 
> 2.       For the packet_in_callback, the handler of event packet_in_event, 
> there are six parameters dpid, inport, reason, len, bufid, packet.  For the 
> object packet, it has method parsed and member dst and so on.
> My question is where can I find the file for defining class like packet?

packet objects often contain other packet objects, and there are classes for a 
number of different protocols.  For example, you'll always be given an ethernet 
packet object, but it may often contain an ipv4 type packet, which will often 
contain a tcp type packet, etc.  This is all broken down for you.  All of these 
classes can be found in the src/nox/lib/packet directory.

> 3.       In pyswitch.py, in the method forward_l2_packet, there is a function 
> called extract_flow. Could someone tell me where does it defined?

src/nox/lib/util.py

> I already searched files core.py openflow.h       Ethernet.py        
> packet_utils.py                 packet_base.py                pyopenflow.py. 
> Unfortunately, I haven’t find related definition. Maybe I miss them.
>  
>  
> Thank you very much for pointing out files where these definition reside.
>  
> Best regards,
> Chen
> _______________________________________________
> nox-dev mailing list
> nox-dev@noxrepo.org
> http://noxrepo.org/mailman/listinfo/nox-dev

Hope that helps.

-- Murphy
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to