com.github.sdnwiselab.sdnwise.controller.ControllerRing1 Maven / Gradle / Ivy
/*
* Copyright (C) 2015 Seb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.github.sdnwiselab.sdnwise.controller;
import com.github.sdnwiselab.sdnwise.adapter.Adapter;
import com.github.sdnwiselab.sdnwise.util.NodeAddress;
import java.util.LinkedList;
/**
*
* @author Seb
*/
public class ControllerRing1 extends ControllerStatic{
public ControllerRing1(ControllerId id, Adapter lower, NetworkGraph networkGraph) {
super(id, lower, networkGraph);
computeRules();
}
//
// public void manageRoutingRequestA(NetworkPacket data) {
// if (data.getDst().intValue() == 0){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(255);
//
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UP)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueHigh(0)
// .setValueLow(0);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
// } else if (data.getDst().intValue() > 0){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(255);
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UNICAST)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueLow(data.getDst().getLow()-1);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
//
//
// }
// data.unsetRequestFlag();
// this.sendMessage(data);
//
// }
//
//
//
//
//
//
//
//
//
//
// public void manageRoutingRequest(NetworkPacket data) {
// if (data.getSrc().intValue() < 3){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(127);
//
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UNICAST)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueLow(data.getSrc().getLow()+1);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
// } else if (data.getSrc().intValue() == 3){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(127);
//
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UNICAST)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueHigh(0)
// .setValueLow(0);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
//
//
// }
// data.unsetRequestFlag();
// this.sendMessage(data);
//
// }
//
//
//
// public void manageRoutingRequestB(NetworkPacket data) {
// int tmp;
//
// if (data.getSrc().intValue() < 3){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(127);
//
// tmp = data.getSrc().getLow()-1;
// if (tmp<0)
// tmp = 3;
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UNICAST)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueLow(tmp);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
// } else if (data.getSrc().intValue() == 3){
// FlowTableEntry rule = new FlowTableEntry();
//
// rule.getWindow()[0]
// .setOperator(FlowTableWindow.SDN_WISE_EQUAL_OR_LESS)
// .setSize(FlowTableWindow.SDN_WISE_SIZE_1)
// .setLocation(FlowTableWindow.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_TYPE)
// .setValueLow(127);
//
//
// rule.getAction()
// .setType(FlowTableAction.SDN_WISE_FORWARD_UNICAST)
// .setLocation(FlowTableAction.SDN_WISE_PACKET)
// .setPos(NetworkPacket.SDN_WISE_NXHOP_H)
// .setValueHigh(0)
// .setValueLow(0);
//
// ResponsePacket rp = new ResponsePacket(data.getNetId(),data.getSrc(),rule);
// this.sendMessage(rp);
//
//
// }
// data.unsetRequestFlag();
// this.sendMessage(data);
//
// }
//
//}
@Override
public final void computeRules(){
boolean clockwise = false;
if (clockwise){
LinkedList path = new LinkedList<>();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.1"));
path.add(new NodeAddress("0.2"));
path.add(new NodeAddress("0.3"));
results.put(new NodeAddress("0.3"), path);
path.clear();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.1"));
path.add(new NodeAddress("0.2"));
results.put(new NodeAddress("0.2"), path);
path.clear();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.1"));
results.put(new NodeAddress("0.1"), path);
} else {
LinkedList path = new LinkedList<>();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.3"));
results.put(new NodeAddress("0.3"), path);
path = new LinkedList<>();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.3"));
path.add(new NodeAddress("0.2"));
results.put(new NodeAddress("0.2"), path);
path = new LinkedList<>();
path.add(new NodeAddress("0.0"));
path.add(new NodeAddress("0.3"));
path.add(new NodeAddress("0.2"));
path.add(new NodeAddress("0.1"));
results.put(new NodeAddress("0.1"), path);
}
}
}