Programming Assignment Wang Zixiao School of Computing National


























- Slides: 26
Programming Assignment Wang Zixiao School of Computing National University of Singapore CS 4226: Internet Architecture
Variety of SDN Controllers • NOX/POX • Ryu • Floodlight • Open. Daylight • Pyretic • Frenetic • Procera • Route. Flow • Trema
POX: Overview • A platform for building network control applications using Python • Supports Open. Flow v. 1. 0 API • Advantages: o o Widely used, maintained, supported Relatively easy to read and write code • Disadvantages: Performance
Mininet Network Host Machine Virtual Machine s 1 h 2 POX s 4 Mininet Virtual Network s 2 h 3 h 4 s 3 h 5 h 6 h 7
Learn through an example • Implement a switch o o What is a switch? What is a hub?
Simple hub • Ethernet is a broadcast medium o Hub is a flooding device
Example: Simple Switch • Switch layer 2: o A multiple port bridge o learn about the MAC addresses on each ports o passes MAC frames destined to those ports.
Self-learning, forwarding: example Source: A Dest: A’ A Frame Destination: A’ Location: unknown A A’ A BA’ C’ ➔ flood 1 6 2 A A’ 4 5 Frame Destination: A A A’ Location: 1 ➔ selectively send MAC addr on just one link A A’ 3 B’ C A A' A' A A’ interface TTL 1 4 60 60 A A' switch table (initially empty)
Learning Switch Parse First No “Packet. In” Packet Compose Write Second Flow Action flow table packet flow sent packet table and match event table to arrives send and match controller arrives entry fired execute message at at switch control logic Listener Data Plane Entry 1 Open. Flow Switch 12 Messager POX Open. Flow Switch Control Plane Open. Flow Packet. In Control Logic Msg Open. Flow Switch Mininet
Open. Flow Entry A flow entry in the flow table looks like: Match Fields Ø Priority Counter Action Timeout Match field: packets are matched against: v Header fields and metadata v May be wildcarded (any) Ø Ø Priority: used for conflicts Action set: v Lists of actions to apply immediately v Sets of actions to add to the action set v Modify pipeline processing (go to another flow table) A “default” entry: table-miss entry
How it works? Event Listener Controller def launch (): • Step 1: Register event listeners to handle specific events (e. g. Connection. Up, Packet. In) 1 - core. openflow. add. Listener. By. Name("Packet. In", _handle_Packet. In) • Step 2: Parse packet and execute control logics 2 - core. register. New (Tutorial) • Class Step 3: Compose and send the Open. Flow Tutorial(Event. Mixin): //Event. Mixin is the class that raises events message to the switch def __init__(self): self. listen. To(core. openflow) core. openflow_discovery. add. Listeners(self) //then implement all handlers you need….
Events • Packet-in: For packets that do not have a matching flow entry • Flow-Removed: For flow entries whose timeout expires • Port-status: When port configuration state changes • Connection-up: Upon connection startup
How it works? Event Listener Controller Control Logic • _handle_Packet. In Step 1: Register def (self, event): listeners to handle packet = event. parsed specific events (e. g. Connection. Up, Packet. In) dst_port = table. get(packet. dst) Every switch connected to the controller has an id named dpid (data path id). def _handle_Connectio. Up (self, event) : • Step 2: Parse packet and execute control logics log. debug(“Switch %s has come up. ”, dpid_to_str(event. dpid)) • Step 3: Compose and send the Open. Flow message to the switch
How it works? Event Listener Control Logic Messager Msg msg = of. ofp_flow_mod() <- This instructs a switch to install a flow table entry • Step 1: Register event listeners to handle msg. match. dl_src = packet. src specific events (e. g. Connection. Up, Packet. In) msg. match. dl_dst = packet. dst msg. actions. append(of. ofp_action_output(port = dst_port)) event. connection. send(msg) • Step 2: Parse packet and execute control logics • Step 3: Compose and send the Open. Flow message to the switch
Match • in_port • dl_src, dl_dst • nw_src, nw_dst • nw_proto • tp_src, tp_dst
Match Manual Match msg = of. ofp_flow_mod() msg. match. dl_src = packet. src msg. match. dl_dst = packet. dst Packet Match msg. match = ofp_match. from_packet(packet, in_port)
Actions • ofp_action_output() • ofp_action_enqueue() • ofp_action_dl_addr() • ofp_action_nw_addr()
Example: Simple Switch def launch (): core. openflow. add. Listener. By. Name("Packet. In", _handle_Packet. In) Step 1: Register event listener def _handle_Packet. In (event): packet = event. parsed dst_port = table. get(packet. dst) msg = of. ofp_flow_mod() msg. match. dl_src = packet. src msg. match. dl_dst = packet. dst msg. actions. append(of. ofp_action_output(port = dst_port)) event. connection. send(msg)
Example: Simple Switch def launch (): core. openflow. add. Listener. By. Name("Packet. In", _handle_Packet. In) def _handle_Packet. In (event): packet = event. parsed dst_port = table. get(packet. dst) Step 2: Parse the packet and execute control logics msg = of. ofp_flow_mod() msg. match. dl_src = packet. src msg. match. dl_dst = packet. dst msg. actions. append(of. ofp_action_output(port = dst_port)) event. connection. send(msg)
Example: Simple Switch def launch (): core. openflow. add. Listener. By. Name("Packet. In", _handle_Packet. In) def _handle_Packet. In (event): packet = event. parsed dst_port = table. get(packet. dst) msg = of. ofp_flow_mod() msg. match. dl_src = packet. src msg. match. dl_dst = packet. dst msg. actions. append(of. ofp_action_output(port = dst_port)) event. connection. send(msg) Step 3: Compose and send Open. Flow message
Quality of Service • Divide the production network into logical slices o Each slice controls its own packet forwarding • Enforce strong isolation between slices o Actions in one slice do not affect another
Qo. S: Virtual Private Network (VPN) • Multiple queues for multiple classes • Guaranteed minimum bandwidth • Queue configuration is not part of the openflow • Configuration defines packet treatment • Openflow maps flows to queues Ref: http: //archive. openflow. org/wk/index. php/Slicing Controller OF DQ IF 2 IF 3 Open. Flow Switch IF 4 IF 1 Q 2 Q 3 Q 4 Q 5 IF 1
VPN • Create multiple queues for each interface (or port) • Provide each queue with different bandwidth • Separate traffics into two slices and assign to different interfaces • Try to keep it simple.
Tips: controller • net = Mininet(topo=topo, link = TCLink, controller=lambda name: Remote. Controller(name, ip='pox controller ip’), listen. Port=6633, auto. Set. Macs=True) • Fill in the field with the controller’s IP address
Tips: queues sudo ovs-vsctl – set Port eth 0 qos=@newqos -- --id=@newqos create Qo. S type=linux-htb otherconfig: max-rate=1000000 queues=0=@q 0, 1=@q 1 -- --id=@q 0 create Queue other-config: maxrate=600000 other-config: min-rate=600000 -- --id=@q 1 create Queue other-config: maxrate=400000 other-config: min-rate=200000 sudo ovs-vsctl --all destroy Qos sudo ovs-vsctl --all destroy Queue
Tips: priority • msg. priority • Give higher priorities to more important apps