def sendNixPacket(self, ofproto, parser, srcSwitch, sdnNix, msg, src_ip, dst_ip, po=True): actions = [] out_port = 0 first = 1 for curNix in sdnNix: if curNix[0].dp.id == srcSwitch.dp.id: # Save the output port from the source switch out_port = curNix[1] else: #self.logger.info ("Switch %s send out port %s", curNix[0].dp.id, curNix[1]) actions.append(parser.OFPActionPushMpls()) actions.append(parser.OFPActionSetField(mpls_ttl=64)) actions.append(parser.OFPActionSetField(mpls_label=curNix[1])) actions.append(parser.OFPActionOutput(out_port)) inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions)] match = parser.OFPMatch() match.append_field(ofproto.OXM_OF_ETH_TYPE, ether_types.ETH_TYPE_IP) # Hack for GENI since it gives the "wrong" MAC addresses... Will still work fine for ns-3 match.append_field(ofproto.OXM_OF_IPV4_SRC, ip.ipv4_to_int(src_ip), ip.text_to_int("255.255.0.0")) match.append_field(ofproto.OXM_OF_IPV4_DST, ip.ipv4_to_int(dst_ip), ip.text_to_int("255.255.0.0")) mod = parser.OFPFlowMod(datapath=srcSwitch.dp, priority=10, table_id=0, match=match, instructions=inst) srcSwitch.dp.send_msg(mod) if po == True: data = None if msg.buffer_id == ofproto.OFP_NO_BUFFER: data = msg.data out = parser.OFPPacketOut(datapath=srcSwitch.dp, buffer_id=msg.buffer_id, in_port=msg.match['in_port'], actions=actions, data=data) srcSwitch.dp.send_msg(out)
def test_text_to_int_from_ipv6_text(self): ipv6_str = '2013:da8:215:8f2:aa20:66ff:fe4c:9c3c' val = 0x20130da8021508f2aa2066fffe4c9c3c res = ip.text_to_int(ipv6_str) eq_(val, res)
def test_text_to_int_from_ipv4_text(self): ipv4_str = '10.28.197.1' # 0a.1c.c5.01 val = 0x0a1cc501 res = ip.text_to_int(ipv4_str) eq_(val, res)