Last active
December 7, 2015 05:41
-
-
Save yasuhito/1aff112df120a5c72e19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# L2 routing path manager | |
class PathManager < Trema::Controller | |
def packet_in(_dpid, message) | |
path = maybe_create_shortest_path(message) | |
ports = path ? [path.out_port] : @graph.external_ports | |
ports.each do |each| | |
send_packet_out(each.dpid, | |
raw_data: message.raw_data, | |
actions: SendOutPort.new(each.number)) | |
end | |
end | |
# ... | |
end | |
# L2 routing switch with virtual slicing. | |
class SliceableSwitch < PathManager | |
def packet_in(_dpid, packet_in) | |
slice = find_slice(packet_in.slice_source, | |
packet_in.slice_destination(@graph)) | |
if slice | |
path = maybe_create_shortest_path_in_slice(slice.name, packet_in) | |
packet_out_to_destination(packet_in, path.out_port) if path | |
else | |
flood_to_external_ports(packet_in) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment