Hi all:
I am using the simple_switch_13.py to run my experiment, then I want to use
the src to ensure that the mac address which I want, so what should I make
use of the src?
THX!
The code is like this: P.S. ...But I don' know why it can't jump into if
Sentence
def _packet_in_handler(self, ev):
>
> msg = ev.msg
>
> datapath = msg.datapath
>
> ofproto = datapath.ofproto
>
> parser = datapath.ofproto_parser
>
> in_port = msg.match['in_port']
>
> ###############################################
> eth_src = msg.match['eth_src']
>
> ###############################################
> pkt = packet.Packet(msg.data)
>
> eth = pkt.get_protocols(ethernet.ethernet)[0]
>
>
>> dst = eth.dst
>
> src = eth.src
>
> dpid = datapath.id
>
> self.mac_to_port.setdefault(dpid, {})
>
>
>> #self.logger.info("packet in %s %s %s %s", dpid, src, dst,
>> in_port)
>
>
>> # learn a mac address to avoid FLOOD next time.
>
> self.mac_to_port[dpid][src] = in_port
>
>
>> if dst in self.mac_to_port[dpid]:
>
> out_port = self.mac_to_port[dpid][dst]
>
> else:
>
> out_port = ofproto.OFPP_FLOOD
>
>
>> actions = [parser.OFPActionOutput(out_port)]
>
> ##################################################################
>
> if eth_dst == '74:d0:2b:11:XX:XX':
>
> match = parser.OFPMatch(eth_dst = '74:d0:2b:11:XX:XX')
>
> if eth_dst in match:
>
> print('ip = 192.168.20.11')
>
> # Do something action
>
>
>> #################################################################
>
> # install a flow to avoid packet_in next time
>
> if out_port != ofproto.OFPP_FLOOD:
>
> match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
>
> self.add_flow(datapath, 1, match, actions)
>
>
>> data = None
>
> if msg.buffer_id == ofproto.OFP_NO_BUFFER:
>
> data = msg.data
>
>
>> out = parser.OFPPacketOut(datapath=datapath,
>> buffer_id=msg.buffer_id,
>
> in_port=in_port, actions=actions,
>> data=data)
>
> datapath.send_msg(out)
>
>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel