Hi,

Inline
On Thu, Apr 12, 2012 at 11:29 PM, Weiyang Mo <[email protected]>wrote:

> Hi,all,
>
> I am studying the example pyswitch.py.I am a new learner and  I understand
> most of them, but few lines are not clear to me.
>
> The following lines:
>
> dst = inst.st[dpid][srcaddr]
>  if dst[0] != inport:
>  log.msg('MAC has moved from '+str(dst)+'to'+str(inport),
> system='pyswitch')
>
> I am confused that why using str(dst) not str(dst[0]), does dst[0]
> represent an old inport?
>

I think you are right. It will print out the full tuple stored  instead of
just the old port.

>
>


> Does dst[0] ,dst[1], dst[2] represent the inport, time and packet?
>
Yes via
    inst.st[dpid][srcaddr] = (inport, time(), packet)

Additionally,should I assign the new inport to the inst.st[dpid][srcaddr]?
> Just use inst.st[dpid][srcaddr][0]=inport ?
>
>
No you can not update it that way since it uses a tuple. You could change
it to a list or you would have to do:

inst.st[dpid][scraddr] = (new_port,  inst.st[dpid][scraddr][1],
inst.st[dpid][scraddr][2])
# assuming we wanted the old time and packet.

Thanks very much
>
> Weiyang
>

Aaron

-- 
Aaron O. Rosen
Masters Student - Network Communication
306B Fluor Daniel

Reply via email to