Hi, Aaron, I have another question regarding the pyswitch.py about this line
if ord(srcaddr[0]) & 1 #To avoid multicast Asuuming the srcaddr is a multicast mac. For a multicast MAC it starts with 01:00:5e. What ord(srcaddr[0]) represents? is srcaddr[0] equal to char '0'? Then what does "ord(0)=48 & 1" mean? Thanks very much Weiyang 2012/4/12 Weiyang Mo <[email protected]> > Understood. > > Thanks a lot. > > Weiyang > > 2012/4/12 Aaron Rosen <[email protected]> > >> 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 >> >> >> >
