Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • camara-integration
  • cnit-optical-band-expansion
  • cnit_related_activity_premerge
  • cnit_tapi
  • cnit_transponders
  • develop
  • feat/108-extend-sbi-with-auto-discovery-of-endpoints-and-channels
  • feat/110-cttc-incorrect-endpoint-lookup-in-nbi-etsi-bwm-plugin
  • feat/113-cttc-implement-nbi-connector-to-manage-network-access-control-lists-acls
  • feat/116-ubi-updates-in-telemetry-backend-to-support-p4-in-band-network-telemetry
  • feat/116-ubi-updates-in-telemetry-backend-to-support-p4-in-band-network-telemetry-2
  • feat/128-cttc-add-ids-support
  • feat/138-ubi-error-handling-in-ztp-component
  • feat/138-ubi-error-handling-in-ztp-component-2
  • feat/139-ubi-p4-driver-does-not-correctly-retrieve-resources
  • feat/161-tid-creation-of-ip-link-with-supporting-coherent-pluggable-to-pluggable-connection
  • feat/163-implement-camara-based-nbi-connector-old-to-be-removed
  • feat/167-ansible-for-configuring-a-tfs-compatible-microk8s-cluster
  • feat/169-cttc-implement-vnt-manager-component
  • feat/183-create-qosprofile-component
  • feat/190-cttc-generalize-service-database-management
  • feat/192-cttc-implement-telemetry-backend-collector-gnmi-openconfig
  • feat/236-integration-with-multiband-amplifier-with-ocm
  • feat/253-tid-tapi-support
  • feat/264-tid-nbi-fot-sap-topology
  • feat/265-tid-new-service-type-for-pon-controller
  • feat/270-job-failed-131879
  • feat/278-cnit-basic-flexgrid-lightpath-deployment
  • feat/280-cttc-enhance-bgp-support-in-netconf-openconfig-sbi-driver
  • feat/281-optical-bandwidth-expansion
  • feat/292-cttc-implement-integration-test-for-ryu-openflow
  • feat/294-cttc-correct-ci-cd-descriptors
  • feat/296-cttc-camara-end-to-end-ci-cd-tests-fail
  • feat/301-cttc-dscm-pluggables
  • feat/303-add-test-to-feature-develop-during-234-related-to-osm-integration-2
  • feat/303-add-test-to-feature-develop-during-234-related-to-osm-integration-3
  • feat/304-cttc-netconf-based-openconfig-telemetry-collector
  • feat/305-cttc-enhanced-netconf-openconfig-sbi-driver-for-dscm-pluggables
  • feat/306-cttc-enhanced-restconf-based-openconfig-nbi-for-dscm-pluggables
  • feat/307-update-python-version
  • feat/308-code-formatting
  • feat/310-cttc-implement-nbi-connector-to-interface-with-osm-client
  • feat/312-tid-new-service-to-configure-interfaces-via-openconfig
  • feat/313-tid-new-tapi-service-for-lsp-configuration
  • feat/313-tid-new-tapi-service-for-lsp-configuration-2
  • feat/314-tid-new-service-for-ipowdm-configuration-fron-orchestrator-to-ipowdm-controller
  • feat/316-cnit-basic-point-multiploint-optical-connections
  • feat/320-cttc-ietf-simap-basic-support-with-kafka-yang-push
  • feat/321-add-support-for-gnmi-configuration-via-proto
  • feat/322-add-read-support-for-ipinfusion-devices-via-netconf
  • feat/323-add-support-for-restconf-protocol-in-devices
  • feat/46-cttc-rename-sbi-component
  • feat/62-tid-add-support-to-nbi-to-export-the-device-inventory-items-2
  • feat/92-cttc-implement-sbi-driver-for-nokia-sr-linux-l2-vpns-through-gnmi
  • feat/94-cttc-nbi-unitary-tests-not-running-and-or-not-working
  • feat/automation-revisited
  • feat/automation-workflow-plugin
  • feat/cttc-nbi-post-service
  • feat/cttc-service-concurrent-task-executor
  • feat/energy-monitoring
  • feat/hackfest
  • feat/hackfest-r2
  • feat/hackfest-r2.1
  • feat/hackfest3
  • feat/hackfest4
  • feat/hackfest5
  • feat/policy-refactor
  • feat/refactor-upgrade-policy
  • feat/siae-mw-driver-enhancement
  • feat/telemetry-collector-int
  • feat/telemetry-int-collector-support-p4
  • feat/tid-bgp
  • feat/tid-logical-resources-component
  • feat/tid-new-pcep-component
  • feat/tid-newer-pcep-component
  • feat/tid-openconfig-refactoring
  • feat/tid-p4
  • feat/tid-pcep
  • feat/tid-pcep-component
  • feat/tid-sap-topology
  • feat/ztp-error-handling
  • fix/58-adapt-interdomain-and-dlt-components-for-release-3-0-to-automate-nfv-sdn-22-experiment
  • fix/remove_automation_subscribe
  • master
  • openroadm-flex-grid
  • release/1.0.0
  • release/2.0.0
  • release/2.0.1
  • release/2.1.0
  • release/3.0.0
  • release/3.0.1
  • release/4.0.0
  • release/5.0.0
  • temp-pr-p4-int
  • test/formatting
  • test/version
  • tmp-integration
  • demo-dpiab-eucnc2024
  • v1.0.0
  • v2.0.0
  • v2.1.0
  • v3.0.0
  • v4.0.0
  • v5.0.0
104 results

Target

Select target project
  • tfs/controller
1 result
Select Git revision
  • camara-integration
  • cnit-optical-band-expansion
  • cnit_related_activity_premerge
  • cnit_tapi
  • cnit_transponders
  • develop
  • feat/108-extend-sbi-with-auto-discovery-of-endpoints-and-channels
  • feat/110-cttc-incorrect-endpoint-lookup-in-nbi-etsi-bwm-plugin
  • feat/113-cttc-implement-nbi-connector-to-manage-network-access-control-lists-acls
  • feat/116-ubi-updates-in-telemetry-backend-to-support-p4-in-band-network-telemetry
  • feat/116-ubi-updates-in-telemetry-backend-to-support-p4-in-band-network-telemetry-2
  • feat/128-cttc-add-ids-support
  • feat/138-ubi-error-handling-in-ztp-component
  • feat/138-ubi-error-handling-in-ztp-component-2
  • feat/139-ubi-p4-driver-does-not-correctly-retrieve-resources
  • feat/161-tid-creation-of-ip-link-with-supporting-coherent-pluggable-to-pluggable-connection
  • feat/163-implement-camara-based-nbi-connector-old-to-be-removed
  • feat/167-ansible-for-configuring-a-tfs-compatible-microk8s-cluster
  • feat/169-cttc-implement-vnt-manager-component
  • feat/183-create-qosprofile-component
  • feat/190-cttc-generalize-service-database-management
  • feat/192-cttc-implement-telemetry-backend-collector-gnmi-openconfig
  • feat/236-integration-with-multiband-amplifier-with-ocm
  • feat/253-tid-tapi-support
  • feat/264-tid-nbi-fot-sap-topology
  • feat/265-tid-new-service-type-for-pon-controller
  • feat/270-job-failed-131879
  • feat/278-cnit-basic-flexgrid-lightpath-deployment
  • feat/280-cttc-enhance-bgp-support-in-netconf-openconfig-sbi-driver
  • feat/281-optical-bandwidth-expansion
  • feat/292-cttc-implement-integration-test-for-ryu-openflow
  • feat/294-cttc-correct-ci-cd-descriptors
  • feat/296-cttc-camara-end-to-end-ci-cd-tests-fail
  • feat/301-cttc-dscm-pluggables
  • feat/303-add-test-to-feature-develop-during-234-related-to-osm-integration-2
  • feat/303-add-test-to-feature-develop-during-234-related-to-osm-integration-3
  • feat/304-cttc-netconf-based-openconfig-telemetry-collector
  • feat/305-cttc-enhanced-netconf-openconfig-sbi-driver-for-dscm-pluggables
  • feat/306-cttc-enhanced-restconf-based-openconfig-nbi-for-dscm-pluggables
  • feat/307-update-python-version
  • feat/308-code-formatting
  • feat/310-cttc-implement-nbi-connector-to-interface-with-osm-client
  • feat/312-tid-new-service-to-configure-interfaces-via-openconfig
  • feat/313-tid-new-tapi-service-for-lsp-configuration
  • feat/313-tid-new-tapi-service-for-lsp-configuration-2
  • feat/314-tid-new-service-for-ipowdm-configuration-fron-orchestrator-to-ipowdm-controller
  • feat/316-cnit-basic-point-multiploint-optical-connections
  • feat/320-cttc-ietf-simap-basic-support-with-kafka-yang-push
  • feat/321-add-support-for-gnmi-configuration-via-proto
  • feat/322-add-read-support-for-ipinfusion-devices-via-netconf
  • feat/323-add-support-for-restconf-protocol-in-devices
  • feat/46-cttc-rename-sbi-component
  • feat/62-tid-add-support-to-nbi-to-export-the-device-inventory-items-2
  • feat/92-cttc-implement-sbi-driver-for-nokia-sr-linux-l2-vpns-through-gnmi
  • feat/94-cttc-nbi-unitary-tests-not-running-and-or-not-working
  • feat/automation-revisited
  • feat/automation-workflow-plugin
  • feat/cttc-nbi-post-service
  • feat/cttc-service-concurrent-task-executor
  • feat/energy-monitoring
  • feat/hackfest
  • feat/hackfest-r2
  • feat/hackfest-r2.1
  • feat/hackfest3
  • feat/hackfest4
  • feat/hackfest5
  • feat/policy-refactor
  • feat/refactor-upgrade-policy
  • feat/siae-mw-driver-enhancement
  • feat/telemetry-collector-int
  • feat/telemetry-int-collector-support-p4
  • feat/tid-bgp
  • feat/tid-logical-resources-component
  • feat/tid-new-pcep-component
  • feat/tid-newer-pcep-component
  • feat/tid-openconfig-refactoring
  • feat/tid-p4
  • feat/tid-pcep
  • feat/tid-pcep-component
  • feat/tid-sap-topology
  • feat/ztp-error-handling
  • fix/58-adapt-interdomain-and-dlt-components-for-release-3-0-to-automate-nfv-sdn-22-experiment
  • fix/remove_automation_subscribe
  • master
  • openroadm-flex-grid
  • release/1.0.0
  • release/2.0.0
  • release/2.0.1
  • release/2.1.0
  • release/3.0.0
  • release/3.0.1
  • release/4.0.0
  • release/5.0.0
  • temp-pr-p4-int
  • test/formatting
  • test/version
  • tmp-integration
  • demo-dpiab-eucnc2024
  • v1.0.0
  • v2.0.0
  • v2.1.0
  • v3.0.0
  • v4.0.0
  • v5.0.0
104 results
Show changes
Showing
with 4439 additions and 0 deletions
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
public class Layer {
/**
* True if it is a GMPLS layer
* False if it is an IP/MPLS layer (by default, false)
*/
public boolean gmpls=false;
/**
*
*/
public int encodingType;
/**
*
*/
public int switchingType;
public static final int SWITCHING_TYPE_WSON=150;
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import org.jgrapht.graph.DirectedWeightedMultigraph;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.Inet4Address;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
/**
* Base de datos de ingenieria de trafico
* CLASE DE PRUEBA REESTRUCTURAR DESPUES!!!!!!!!!!
* @author ogondio
*
*/
public class MDTEDB implements MultiDomainTEDB {
private long graphId;
private DirectedWeightedMultigraph<Object,InterDomainEdge> networkDomainGraph;
public SimpleDirectedWeightedGraph<Object,IntraDomainEdge> networkGraph;
//private LinkedList<InterDomainEdge> interDomainLinks;
public SimpleTEDB simple_ted;
private Logger log;
private boolean addBidirectional;
/**
* Table with IP address/prefix --> domain
*/
LinkedList<ReachabilityEntry> reachability;
public MDTEDB(){
log=LoggerFactory.getLogger("BGP4Peer");
networkDomainGraph=new DirectedWeightedMultigraph<Object,InterDomainEdge> (InterDomainEdge.class);
addBidirectional=true;//FIXME: ESTO ES UN APA�O TEMPORAL
reachability=new LinkedList<ReachabilityEntry>();
//interDomainLinks = new LinkedList<InterDomainEdge>();
}
public DirectedWeightedMultigraph<Object,InterDomainEdge> getDuplicatedMDNetworkGraph(){
DirectedWeightedMultigraph<Object,InterDomainEdge> graphCopy= (DirectedWeightedMultigraph<Object, InterDomainEdge>) networkDomainGraph.clone();
return graphCopy;
}
public DirectedWeightedMultigraph<Object, InterDomainEdge> getNetworkDomainGraph() {
return networkDomainGraph;
}
public void setNetworkDomainGraph(
DirectedWeightedMultigraph<Object, InterDomainEdge> networkDomainGraph) {
this.networkDomainGraph = networkDomainGraph;
}
public void initializeFromFile(String file){
networkDomainGraph=FileTEDBUpdater.readMDNetwork(file);
}
public void initializeFromFile(String file, String learntFrom){
networkDomainGraph=FileTEDBUpdater.readMDNetwork(file, learntFrom);
}
public void initializeFromFileInterDomainLinks(String file){
}
public void initializeFullTEDFromFile(String file){
networkGraph=FileTEDBUpdater.readNetwork(file);
}
public long getGraphId() {
return graphId;
}
public void setGraphId(long graphId) {
this.graphId = graphId;
}
public SimpleDirectedWeightedGraph<Object, IntraDomainEdge> getDuplicatedNetworkGraph() {
return networkGraph;
}
public synchronized void addInterdomainLink( Object localDomainID, Object localRouterASBR, long localRouterASBRIf, Object remoteDomainID, Object remoteRouterASBR, long remoteRouterASBRIf, TE_Information te_info){
if (!networkDomainGraph.containsVertex(localDomainID)){
networkDomainGraph.addVertex(localDomainID);
log.debug("Vertex (domain) "+localDomainID+" added");
}
if (!networkDomainGraph.containsVertex(remoteDomainID)){
networkDomainGraph.addVertex(remoteDomainID);
log.debug("Vertex (domain) "+remoteDomainID+" added");
}
log.debug("Looking to add "+localRouterASBR+":"+localRouterASBRIf+" ("+localDomainID+") -->"+remoteRouterASBR+":"+remoteRouterASBRIf+" ("+remoteDomainID+")");
Set<InterDomainEdge> edgeset= networkDomainGraph.edgesOf(localDomainID);
Iterator <InterDomainEdge> iterador=edgeset.iterator();
boolean edgeFound=false;
InterDomainEdge interDomainEdgeFound=null;
if (edgeset.size() == 0)
log.debug("Edge set size = 0");
while (iterador.hasNext()){
InterDomainEdge interDomainEdge=iterador.next();
log.debug("existing edge: "+interDomainEdge.toString());
if (interDomainEdge.getSrc_router_id().equals(localRouterASBR)){
log.debug("Local router is the same!!!");
if (interDomainEdge.getDst_router_id().equals(remoteRouterASBR)){
log.debug("Destination router is the same!!!");
edgeFound=true;
interDomainEdgeFound=interDomainEdge;
}
else {
log.debug("Destination router is NOT the same!!!");
}
}else {
log.debug("Local router is NOT the same!!!");
}
}
if (edgeFound==false) {
InterDomainEdge newInterDomainEdge =new InterDomainEdge();
newInterDomainEdge.setSrc_router_id(localRouterASBR);
newInterDomainEdge.setDst_router_id(remoteRouterASBR);
newInterDomainEdge.setSrc_if_id(localRouterASBRIf);
newInterDomainEdge.setDst_if_id(remoteRouterASBRIf);
newInterDomainEdge.setDomain_dst_router(remoteDomainID);
newInterDomainEdge.setDomain_src_router(localDomainID);
if (te_info != null)
newInterDomainEdge.setTE_info(te_info);
networkDomainGraph.addEdge(localDomainID, remoteDomainID, newInterDomainEdge);
log.info("New interdomain edge between "+localDomainID+" and "+remoteDomainID+" received");
}else {
if (te_info != null){
//FIXME: Update of TE info to be optimized
log.debug("TE_info updated");
interDomainEdgeFound.setTE_info(te_info);
}
}
}
public void addReachabilityIPv4(Inet4Address domainId,Inet4Address aggregatedIPRange,int prefix){
ReachabilityEntry ra=new ReachabilityEntry();
ra.setAggregatedIPRange(aggregatedIPRange);
long resta=((long)0x1<<prefix)-1;
long maskLong=resta<<(32-prefix);
byte[] mask=new byte[4];
mask[0]=(byte)(maskLong>>>24 & 0xFF);
mask[1]=(byte)(maskLong>>>16 & 0xFF);
mask[2]=(byte)(maskLong>>>8 & 0xFF);
mask[3]=(byte)(maskLong& 0xFF);
ra.setMask(mask);
ra.setDomainId(domainId);
ra.setPrefix(prefix);
if (!(reachability.contains(ra))){
reachability.add(ra);
}
return;
}
public String printMDTopology(){
String topoString;
Set<Object> vetexSet= networkDomainGraph.vertexSet();
Iterator <Object> vertexIterator=vetexSet.iterator();
topoString="Domains: \r\n";
while (vertexIterator.hasNext()){
Object vertex= vertexIterator.next();
topoString=topoString+"\t"+vertex.toString()+"\r\n";
}
topoString=topoString+"Interdomain list: \r\n";
Set<InterDomainEdge> edgeSet= networkDomainGraph.edgeSet();
Iterator <InterDomainEdge> edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
InterDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
return topoString;
}
// public String printMD2Topology(){
// String topoString;
// Set<Object> vetexSet= networkDomainGraph.vertexSet();
// Iterator <Object> vertexIterator=vetexSet.iterator();
// topoString="Domains: \r\n";
// while (vertexIterator.hasNext()){
// Object vertex= vertexIterator.next();
// topoString=topoString+"\t"+vertex.toString()+"\r\n";
// }
// topoString=topoString+"Interdomain list: \r\n";
// Iterator <InterDomainEdge> edgeIterator=interDomainLinks.iterator();
// while (edgeIterator.hasNext()){
// InterDomainEdge edge= edgeIterator.next();
// topoString=topoString+"\t"+edge.toString()+"\r\n";
// }
//
// return topoString;
// }
//Check resources SSON and WSON
public boolean CheckLocalResources(long ifID, Object ip){
Iterator<InterDomainEdge> iteredges = networkDomainGraph.edgeSet().iterator();
InterDomainEdge link;
while (iteredges.hasNext())
{
link = iteredges.next();
if ((link.getSrc_if_id()==(ifID)))
{
log.info("InterDomain Link Found to "+link.getDst_router_id().toString());
return true;
}
}
return false;
}
@Override
public String printTopology() {
// TODO Auto-generated method stub
return printMDTopology();
}
public LinkedList<InterDomainEdge> getInterDomainLinks() {
return new LinkedList<InterDomainEdge>(networkDomainGraph.edgeSet());
}
@Override
public boolean isITtedb() {
// TODO Auto-generated method stub
return false;
}
public SimpleTEDB getSimple_ted() {
return simple_ted;
}
public void setSimple_ted(SimpleTEDB simple_ted) {
this.simple_ted = simple_ted;
}
public LinkedList<ReachabilityEntry> getReachability() {
return reachability;
}
public void setReachability(LinkedList<ReachabilityEntry> reachability) {
this.reachability = reachability;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.net.Inet4Address;
public interface MultiDomainTEDB extends TEDB {
public void addInterdomainLink( Object localDomainID, Object localRouterASBR, long localRouterASBRIf, Object remoteDomainID, Object remoteRouterASBR, long remoteRouterASBRIf, TE_Information te_info );
public void addReachabilityIPv4(Inet4Address domainId,Inet4Address aggregatedIPRange,int prefix);
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.complexFields.BitmapLabelSet;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import java.net.Inet4Address;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class MultiLayerTEDB implements DomainTEDB {
private ArrayList<TEDListener> registeredAlgorithms;
/**
* Graph of the Upper Layer Network
*/
/**
*
*/
private SimpleDirectedWeightedGraph<Object,IntraDomainEdge> upperLayerGraph;
/**
* Graph of the Upper Layer Network
*/
private SimpleDirectedWeightedGraph<Object,IntraDomainEdge> lowerLayerGraph;
/**
* InterLayer Graph
*/
private SimpleDirectedWeightedGraph<Object,IntraDomainEdge> interLayerGraph;
/**
* Reachability information
*/
private ReachabilityEntry reachabilityEntry;
/**
* WSON Information of the lower Layer
*/
private WSONInformation WSONinfo=null;
private Lock TEDBlock;
/**
* List of interdomain Links
*/
private LinkedList<InterDomainEdge> interDomainLinks;
private Hashtable<Object,Object> RelationNodesInterlayer;
public MultiLayerTEDB(){
registeredAlgorithms= new ArrayList<TEDListener>();
TEDBlock=new ReentrantLock();
}
public SimpleDirectedWeightedGraph<Object, IntraDomainEdge> getUpperLayerGraph() {
return upperLayerGraph;
}
public void setUpperLayerGraph(
SimpleDirectedWeightedGraph<Object, IntraDomainEdge> upperLayerGraph) {
this.upperLayerGraph = upperLayerGraph;
}
public SimpleDirectedWeightedGraph<Object, IntraDomainEdge> getLowerLayerGraph() {
return lowerLayerGraph;
}
public void setLowerLayerGraph(
SimpleDirectedWeightedGraph<Object, IntraDomainEdge> lowerLayerGraph) {
this.lowerLayerGraph = lowerLayerGraph;
}
public SimpleDirectedWeightedGraph<Object, IntraDomainEdge> getInterLayerGraph() {
return interLayerGraph;
}
public void setInterLayerGraph(
SimpleDirectedWeightedGraph<Object, IntraDomainEdge> interLayerGraph) {
this.interLayerGraph = interLayerGraph;
}
public SimpleDirectedWeightedGraph<Object,IntraDomainEdge> getDuplicatedUpperLayerkGraph(){
SimpleDirectedWeightedGraph<Object,IntraDomainEdge> graphCopy;
TEDBlock.lock();
try{
graphCopy= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) upperLayerGraph.clone();
} finally{
TEDBlock.unlock();
}
return graphCopy;
}
public Hashtable<Object, Object> getRelationNodesInterlayer() {
return RelationNodesInterlayer;
}
public SimpleDirectedWeightedGraph<Object,IntraDomainEdge> getDuplicatedLowerLayerkGraph(){
SimpleDirectedWeightedGraph<Object,IntraDomainEdge> graphCopy;
TEDBlock.lock();
try{
graphCopy= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) lowerLayerGraph.clone();
} finally{
TEDBlock.unlock();
}
return graphCopy;
}
public SimpleDirectedWeightedGraph<Object,IntraDomainEdge> getDuplicatedInterLayerGraph(){
SimpleDirectedWeightedGraph<Object,IntraDomainEdge> graphCopy;
TEDBlock.lock();
try{
graphCopy= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) interLayerGraph.clone();
} finally{
TEDBlock.unlock();
}
return graphCopy;
}
public void initializeFromFile(String file) {
upperLayerGraph=FileTEDBUpdater.readNetwork(file, "mpls");
lowerLayerGraph=FileTEDBUpdater.readNetwork(file, "wson");
interLayerGraph=FileTEDBUpdater.readNetwork(file, "interlayer");
WSONinfo = FileTEDBUpdater.getWSONInformation(file, "wson");
interDomainLinks = FileTEDBUpdater.readInterDomainLinks(file);
reachabilityEntry = new ReachabilityEntry();
//domainReachabilityIPv4Prefix=new byte[4];
FileTEDBUpdater.getDomainReachabilityFromFile(file,reachabilityEntry,"mpls");
}
@Override
public void initializeFromFile(String file, String learnFrom) {
}
@Override
public boolean isITtedb() {
// TODO Auto-generated method stub
return false;
}
@Override
public String printTopology() {
String topoString;
Set<Object> vetexSet= upperLayerGraph.vertexSet();
Iterator <Object> vertexIterator=vetexSet.iterator();
topoString="MPLS Nodes: \r\n";
while (vertexIterator.hasNext()){
Object vertex= vertexIterator.next();
topoString=topoString+"\t"+vertex.toString()+"\r\n";
}
topoString=topoString+"MPLS Link list: \r\n";
Set<IntraDomainEdge> edgeSet= upperLayerGraph.edgeSet();
Iterator <IntraDomainEdge> edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
vetexSet= lowerLayerGraph.vertexSet();
vertexIterator=vetexSet.iterator();
topoString="GMPLS Nodes: \r\n";
while (vertexIterator.hasNext()){
Object vertex= vertexIterator.next();
topoString=topoString+"\t"+vertex.toString()+"\r\n";
}
topoString=topoString+"gmpls Link list: \r\n";
edgeSet= lowerLayerGraph.edgeSet();
edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
topoString=topoString+"InterLayer list: \r\n";
edgeSet= interLayerGraph.edgeSet();
edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
topoString=topoString+printInterDomainLinks();
return topoString;
}
@Override
public boolean belongsToDomain(Object addr) {
int i;
byte[] addrbytes= ((Inet4Address)addr).getAddress();
for (i=0;i<4;++i){
addrbytes[i]=(byte) (addrbytes[i]&(reachabilityEntry.getMask())[i]);
}
return Arrays.equals(addrbytes,reachabilityEntry.getAggregatedIPRange().getAddress());
}
public ReachabilityEntry getReachabilityEntry() {
return reachabilityEntry;
}
public LinkedList<InterDomainEdge> getInterDomainLinks() {
return interDomainLinks;
}
@Override
public String printInterDomainLinks(){
String topoString="";
int size = interDomainLinks.size();
topoString="Interdomain Link list: \r\n";
for (int i=0;i<size;i++){
//por pantalla
InterDomainEdge edge = interDomainLinks.get(i);
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
return topoString;
}
public boolean containsVertex(Object vertex) {
return upperLayerGraph.containsVertex(vertex);
}
public WSONInformation getWSONinfo() {
return WSONinfo;
}
@Override
public void notifyWavelengthReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional){
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
IntraDomainEdge edge=lowerLayerGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wavelength);
if (bidirectional == true){
edge=lowerLayerGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wavelength);
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wavelength);
if (bidirectional == true){
registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wavelength);
}
}
}
@Override
public void notifyWavelengthEndReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional){
// TODO Auto-generated method stub
//Delete the resource reservation
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
// SimpleDirectedWeightedGraph<Object,FiberLinkEdge> graph= ted.getNetworkGraph();
IntraDomainEdge edge=lowerLayerGraph.getEdge(sourceVertexList.get(i),targetVertexList.get(i) );
edge.getTE_info().setWavelengthUnReserved(wavelength);
if (bidirectional == true)
{
edge=lowerLayerGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthUnReserved(wavelength);
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthEndReservation(sourceVertexList, targetVertexList, wavelength);
if (bidirectional == true)
{
registeredAlgorithms.get(i).notifyWavelengthEndReservation(targetVertexList, sourceVertexList, wavelength);
}
}
//FIXME:TEMPORAL!!!!!!
//requestDispatcher.moveRetryQueueToComputingRequestQueue();
//Call request dispatcher to pass requests to queue?
}
@Override
public void notifyWavelengthChange(Object localInterfaceIPAddress, Object remoteInterfaceIPAddress, BitmapLabelSet previousBitmapLabelSet, BitmapLabelSet newBitmapLabelSet) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthStatusChange(localInterfaceIPAddress, remoteInterfaceIPAddress, previousBitmapLabelSet, newBitmapLabelSet);
}
}
@Override
public void register(TEDListener compAlgPreComp) {
registeredAlgorithms.add(compAlgPreComp);
}
@Override
public void notifyNewVertex(Object vertex) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyNewVertex(vertex);
}
}
@Override
public void notifyNewEdge(Object source, Object destination) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyNewEdge(source,destination);
}
}
@Override
public void clearAllReservations() {
if (WSONinfo!=null){
TEDBlock.lock();
try{
Set<IntraDomainEdge> edgeSet= lowerLayerGraph.edgeSet();
Iterator <IntraDomainEdge> edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
edge.TE_info.setAllWavelengtshUnReserved();
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyTEDBFullUpdate();
}
}
}
@Override
public void notifyNewEdgeIP(Object source, Object destination, TE_Information informationTEDB) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyNewEdgeIP(source,destination, informationTEDB);
}
}
public void notificationEdgeIP_AuxGraph(Object src, Object dst, TE_Information informationTEDB) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notificationEdgeIP_AuxGraph(src,dst, informationTEDB);
}
}
public void notificationEdgeOPTICAL_AuxGraph(Object src, Object dst, int lambda) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notificationEdgeOPTICAL_AuxGraph(src, dst, lambda);
}
}
@Override
public void notifyWavelengthEndReservationSSON(
LinkedList<Object> sourceVertexList,
LinkedList<Object> targetVertexList, int wavelength,
boolean bidirectional, int m) {
// TODO Auto-generated method stub
}
@Override
public void notifyWavelengthReservationSSON(
LinkedList<Object> sourceVertexList,
LinkedList<Object> targetVertexList, int wavelength,
boolean bidirectional, int m) {
// TODO Auto-generated method stub
}
@Override
public SSONInformation getSSONinfo() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<IntraDomainEdge> getIntraDomainLinks() {
// TODO Auto-generated method stub
return null;
}
@Override
public void notifyWavelengthReservationWLAN(
LinkedList<Object> sourceVertexList,
LinkedList<Object> targetVertexList,
LinkedList<Integer> wlans, boolean bidirectional) {
// TODO Auto-generated method stub
}
@Override
public void registerSSON(SSONListener compAlgPreComp) {
// TODO Auto-generated method stub
}
@Override
public Inet4Address getDomainID() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setWSONinfo(WSONInformation wSONinfo) {
// TODO Auto-generated method stub
}
@Override
public void setSSONinfo(SSONInformation sSONinfo) {
// TODO Auto-generated method stub
}
@Override
public void createGraph() {
// TODO Auto-generated method stub
}
@Override
public Set<Object> getIntraDomainLinksvertexSet() {
// TODO Auto-generated method stub
return null;
}
@Override
public Hashtable<Object, Node_Info> getNodeTable() {
// TODO Auto-generated method stub
return null;
}
@Override
public IT_Resources getItResources() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setItResources(IT_Resources itResources) {
// TODO Auto-generated method stub
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.net.Inet4Address;
import java.util.LinkedList;
import es.tid.of.DataPathID;
public class Node_Info {
//we specify we we learn the topology from
private String learntFrom = null;
// for the moment only ospf-non pseudo supported
private Inet4Address igp_ident = null;
//caracterizacion
private Inet4Address as_number, area_id, bgpls_ident, ipv4AddressLocalNode= null;
private DataPathID dataPathIDLocalNode;
private boolean overload_bit = false;
private boolean attached_bit = false;
private boolean external_bit = false;
private boolean abr_bit = false;
private byte[] name;
private LinkedList <Inet4Address> ipv4areaIDs = new LinkedList <Inet4Address>();
private int sid;
public Node_Info() {
// TODO Auto-generated constructor stub
}
public Node_Info(Inet4Address ipv4Address_ospf, Inet4Address as_number,
boolean overload_bit, boolean attached_bit, boolean external_bit,
boolean abr_bit, byte[] name, LinkedList<Inet4Address> ipv4areaIDs, Inet4Address ipv4AdddressLN) {
super();
this.igp_ident = ipv4Address_ospf;
this.as_number = as_number;
this.overload_bit = overload_bit;
this.attached_bit = attached_bit;
this.external_bit = external_bit;
this.abr_bit = abr_bit;
this.name = name;
this.ipv4areaIDs = ipv4areaIDs;
this.ipv4AddressLocalNode = ipv4AdddressLN;
}
public LinkedList<Inet4Address> getIpv4areaIDs() {
return ipv4areaIDs;
}
public void setIpv4areaIDs(LinkedList<Inet4Address> ipv4areaIDs) {
this.ipv4areaIDs = ipv4areaIDs;
}
public byte[] getName() {
return name;
}
public void setName(byte[] name) {
this.name = name;
}
public boolean isOverload_bit() {
return overload_bit;
}
public void setOverload_bit(boolean overload_bit) {
this.overload_bit = overload_bit;
}
public boolean isAttached_bit() {
return attached_bit;
}
public void setAttached_bit(boolean attached_bit) {
this.attached_bit = attached_bit;
}
public boolean isExternal_bit() {
return external_bit;
}
public void setExternal_bit(boolean external_bit) {
this.external_bit = external_bit;
}
public Inet4Address getArea_id() {
return area_id;
}
public void setArea_id(Inet4Address area_id) {
this.area_id = area_id;
}
public boolean isAbr_bit() {
return abr_bit;
}
public void setAbr_bit(boolean abr_bit) {
this.abr_bit = abr_bit;
}
public Inet4Address getIpv4Address() {
return igp_ident;
}
public void setIpv4Address(Inet4Address ipv4Address_ospf) {
this.igp_ident = ipv4Address_ospf;
}
public Inet4Address getIpv4AddressLocalNode() {
return ipv4AddressLocalNode;
}
public void setIpv4AddressLocalNode(Inet4Address ipv4AddressLocalNode) {
this.ipv4AddressLocalNode = ipv4AddressLocalNode;
}
public DataPathID getDataPathLocalNode() {
return dataPathIDLocalNode;
}
public void setDataPathLocalNode(DataPathID dataPathLocalNode) {
this.dataPathIDLocalNode = dataPathLocalNode;
}
public Inet4Address getAs_number() {
return as_number;
}
public void setAs_number(Inet4Address as_number) {
this.as_number = as_number;
}
public Inet4Address getBgpls_ident() {
return bgpls_ident;
}
public void setBgpls_ident(Inet4Address bgpls_ident) {
this.bgpls_ident = bgpls_ident;
}
public String getLearntFrom() {
return learntFrom;
}
public void setLearntFrom(String learntFrom) {
this.learntFrom = learntFrom;
}
public void setSID(int sid) {
this.sid = sid;
}
public int getSid(){
return sid;
}
public String toString(){
String ret = "";
if(igp_ident!=null)
ret = ret + "IGP-ID:" + this.getIpv4Address() +"\t";
if(as_number!=null)
ret = ret + "as_num:" + this.getAs_number() +"\t";
if(bgpls_ident != null)
ret = ret + "BGPLS-ident:" + this.getBgpls_ident() +"\t";
if(name != null)
ret = ret + "Name :" + this.getName() +"\t";
if(ipv4AddressLocalNode!=null)
ret = ret +"Local Node IP Address: " + this.getIpv4AddressLocalNode() + "\t";
if(sid!=0)
ret = ret + "SID:" + this.getSid() +"\t";
return ret;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.net.Inet4Address;
public class ReachabilityEntry {
public Inet4Address domainId;
public byte[] mask;
public int prefix;
//public byte[] aggregatedIPRange;
public Inet4Address aggregatedIPRange;
public ReachabilityEntry(){
mask = new byte[4];
}
public ReachabilityEntry(Inet4Address domainId){
mask = new byte[4];
}
public int getPrefix() {
return prefix;
}
public Inet4Address getAggregatedIPRange() {
return aggregatedIPRange;
}
public void setAggregatedIPRange(Inet4Address aggregatedIPRange) {
this.aggregatedIPRange = aggregatedIPRange;
}
public byte[] getMask() {
return mask;
}
public Inet4Address getDomainId() {
return domainId;
}
public void setDomainId(Inet4Address domainId) {
this.domainId = domainId;
}
public void setMask(byte[] mask) {
this.mask = mask;
}
public void setPrefix(int prefix) {
this.prefix = prefix;
}
public String toString(){
String ret=aggregatedIPRange.toString()+"\\"+prefix+" ("+domainId.toString()+")";
return ret;
}
@Override
public boolean equals(Object reachabilityObject) {
if ((domainId.equals(((ReachabilityEntry)reachabilityObject).getDomainId()))&&
(aggregatedIPRange.equals(((ReachabilityEntry)reachabilityObject).getAggregatedIPRange()))&&
(prefix == ((ReachabilityEntry)reachabilityObject).getPrefix())){
return true;
}
return false;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.net.Inet4Address;
import java.util.Iterator;
import java.util.LinkedList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.tid.rsvp.objects.subobjects.EROSubobject;
import es.tid.rsvp.objects.subobjects.IPv4prefixEROSubobject;
import es.tid.rsvp.objects.subobjects.SubObjectValues;
/**
* Class that maintains a table with Reachability entries.
* It has a method to add a reachability entry
* It has a method to query the domain of an IPv4 endpoint
* It has a method to query if an address begins to a given IP range
* KNOWN BUGS:
* * When a reachability entry is added, it is not checked if
* it is already there or not.
* * Reachability entries cannot be removed
*
* @author ogondio
*
*/
public class ReachabilityManager {
/**
* Table with IP address/prefix --> domain
*/
LinkedList<ReachabilityEntry> reachability;
/**
* The logger
*/
private Logger log;
/**
* ReachabilityManager constructor
*/
public ReachabilityManager(){
log=LoggerFactory.getLogger("PCEServer");
reachability=new LinkedList<ReachabilityEntry>();
}
/**
* gets the domain of an IPv4 EndpointAddress
* @param endpointAddress the address to query
* @return The domain id if the endpointAddress belongs to a domain, null otherwise.
*/
public Inet4Address getDomain(Inet4Address endpointAddress) {
//String domain="0.0.0.1";
Iterator<ReachabilityEntry> it=reachability.iterator();
while (it.hasNext()){
ReachabilityEntry ra=it.next();
//log.info("reachability entry "+ra.aggregatedIPRange+" mask "+(ra.mask[0]&0xFF)+"."+(ra.mask[1]&0xFF)+"."+(ra.mask[2]&0xFF)+"."+(ra.mask[3]&0xFF));
if (belongsToDomain(endpointAddress, ra.mask, ra.aggregatedIPRange)){
return ra.domainId;
}
}
return null;
}
/**
* Method to determine if the address 'nodeAdrress' belongs to the aggregated IP address range given by the mask and the addresss 'aggregatedIPRange'
* @param nodeAddress The address to query
* @param mask The 32 bit network mask
* @param aggregatedIPRange The aggregated IP address
* @return true if it belongs to the range, false if it does not belong to the range
*/
public boolean belongsToDomain(Inet4Address nodeAddress, byte []mask, Inet4Address aggregatedIPRange){
int i;
//byte [] networkAddress=new byte[4];
byte [] bytesAggregatedIPRange=aggregatedIPRange.getAddress();
byte [] bytesNodeAddress=nodeAddress.getAddress();
boolean found=true;
for (i=0;i<4;++i){
//networkAddress[i]= (byte) ((bytesNodeAddress[i]&mask[i])&0xFF) ;
//log.info("network Node Address[i]: "+(networkAddress[i]&0xFF));
//log.info("bytesAggregatedIPRange["+i+"]: "+((bytesAggregatedIPRange[i]&mask[i])&0xFF));
//log.info("bytesNodeAddress["+i+"]: "+((bytesNodeAddress[i]&mask[i])&0xFF));
if ((byte)((bytesAggregatedIPRange[i]&mask[i])&0xFF)!=(byte)((bytesNodeAddress[i]&mask[i])&0xFF)){
found=false;
return found;
}
}
return found;
}
/**
* Adds a ERO Subobject associated with a given domainId to the reachability table
* @param domainId Domain ID
* @param eroso ERO Subobject
*/
public void addEROSubobject(Inet4Address domainId, EROSubobject eroso ){
if (eroso.getType()==SubObjectValues.ERO_SUBOBJECT_IPV4PREFIX){
log.info("Adding IPv4 ERO Subobject to the Reachability Database");
IPv4prefixEROSubobject ipv4eroso=(IPv4prefixEROSubobject)eroso;
//long mask=(long)0xFFFFFFFF-(long)Math.pow(2, 32-ipv4eroso.getPrefix())-1;
log.info("prefix "+ipv4eroso.getPrefix());
long resta=((long)0x1<<ipv4eroso.getPrefix())-1;
long maskLong=resta<<(32-ipv4eroso.getPrefix());
byte[] mask=new byte[4];
mask[0]=(byte)(maskLong>>>24 & 0xFF);
mask[1]=(byte)(maskLong>>>16 & 0xFF);
mask[2]=(byte)(maskLong>>>8 & 0xFF);
mask[3]=(byte)(maskLong& 0xFF);
log.info("mask: "+(mask[0]&0xFF)+"."+(mask[1]&0xFF)+"."+(mask[2]&0xFF)+"."+(mask[3]&0xFF));
log.info("Domain ID: "+domainId+" mask "+mask+" IPv4 Address: "+ipv4eroso.getIpv4address());//Pasar a FINE
addIPv4Entry(domainId,mask,ipv4eroso.getIpv4address(),ipv4eroso.getPrefix());
}
}
private void addIPv4Entry(Inet4Address domainId,byte [] mask,Inet4Address aggregatedIPRange,int prefix){
ReachabilityEntry ra=new ReachabilityEntry();
ra.aggregatedIPRange=aggregatedIPRange;
ra.mask=mask;
ra.domainId=domainId;
ra.prefix=prefix;
if (!(reachability.contains(ra))){
reachability.add(ra);
}
return;
}
/**
* Print the reachability table
* @return String with the reachability information
*/
public String printReachability(){
String reachabilityString;
Iterator <ReachabilityEntry> reachabIterator=reachability.iterator();
reachabilityString="Reachability entries: \r\n";
while (reachabIterator.hasNext()){
ReachabilityEntry entry= reachabIterator.next();
reachabilityString=reachabilityString+"\t"+entry.toString()+"\r\n";
}
return reachabilityString;
}
public LinkedList<ReachabilityEntry> getReachability() {
return reachability;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.AvailableLabels;
/**
* Label information in the special case of a Switched Spectrum Optical Network based on Flexgrid.
* @author amll
*
*/
public class SSONInformation {
/**
* In case the Network is SSON, this is the list of available Labels
*/
private AvailableLabels commonAvailableLabels;
/**
* In case the Network is SSON, this is the number of wavelengths. -1 means it is not WSON.
*/
private int numLambdas=-1;
/**
* Spectral Grid of the optical network.
*/
public int grid=0;
/**
* Channel Spacing
*/
public int cs=0;
/**
* Minimum central frequency available in the spectral grid available to be assigned to a LSP.
*/
public int nMin=0;
public int getGrid() {
return grid;
}
public void setGrid(int grid) {
this.grid = grid;
}
public int getCs() {
return cs;
}
public void setCs(int cs) {
this.cs = cs;
}
public int getnMin() {
return nMin;
}
public void setnMin(int nMin) {
this.nMin = nMin;
}
public AvailableLabels getCommonAvailableLabels() {
return commonAvailableLabels;
}
public void setCommonAvailableLabels(AvailableLabels commonAvailableLabels) {
this.commonAvailableLabels = commonAvailableLabels;
}
public int getNumLambdas() {
return numLambdas;
}
public void setNumLambdas(int numLambdas) {
this.numLambdas = numLambdas;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.util.LinkedList;
public interface SSONListener extends TEDListener{
public void notifyWavelengthReservationSSON(LinkedList<Object> sourceVertexList,
LinkedList<Object> targetVertexList, int wavelength, int m);
void notifyWavelengthEndReservationSSON(
LinkedList<Object> sourceVertexList,
LinkedList<Object> targetVertexList, int wavelength, int m);
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.net.Inet4Address;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import es.tid.of.DataPathID;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.complexFields.BitmapLabelSet;
/**
* Traffic Engineering Database of a Domain.
*
*
* @author ogondio, mcs, b.mvas
*
*/
public class SimpleTEDB implements DomainTEDB{
private Inet4Address domainID;
private IT_Resources itResources;
/**
* List of algorithms that will be notified when there are significant changes in the TED
*/
private ArrayList<TEDListener> registeredAlgorithms;
/**
* List of algorithms SSON that will be notified when there are significant changes in the TED
*/
private ArrayList<SSONListener> registeredAlgorithmssson;
/**
* Graph of the Network
*/
private SimpleDirectedWeightedGraph<Object,IntraDomainEdge> networkGraph;
/**
* List of interdomain Links
*/
private LinkedList<InterDomainEdge> interDomainLinks = new LinkedList<InterDomainEdge>();
/*
* List of Intradomain Edges
* Please, It's not the same as intraDomainLinks
* This has been created to support multiedges between two nodes
*/
private LinkedList<IntraDomainEdge> intraDomainEdges = new LinkedList<IntraDomainEdge>();
/**
* Reachability information
*/
private ReachabilityEntry reachabilityEntry;
/**
* Information about the labels in a WSON network.
*/
private WSONInformation WSONinfo=null;
/**
* Information about the labels in a SSON network.
*/
private SSONInformation SSONinfo=null;
private Lock TEDBlock;
private Hashtable<Object , Node_Info> NodeTable;
private boolean multidomain=false;//By default, the TED has only one domain
Logger log;
public SimpleTEDB(){
log=LoggerFactory.getLogger("TEDBParser");
registeredAlgorithms= new ArrayList<TEDListener>();
registeredAlgorithmssson= new ArrayList<SSONListener>();
TEDBlock=new ReentrantLock();
NodeTable = new Hashtable<Object, Node_Info>();
}
public SimpleDirectedWeightedGraph<Object,IntraDomainEdge> getDuplicatedNetworkGraph(){
SimpleDirectedWeightedGraph<Object,IntraDomainEdge> graphCopy;
TEDBlock.lock();
try{
graphCopy= (SimpleDirectedWeightedGraph<Object, IntraDomainEdge>) networkGraph.clone();
} finally{
TEDBlock.unlock();
}
return graphCopy;
}
public void createGraph(){
networkGraph = new SimpleDirectedWeightedGraph<Object, IntraDomainEdge>(IntraDomainEdge.class);
reachabilityEntry = new ReachabilityEntry();
}
public void initializeFromFile(String file){
initializeFromFile(file, null, false,0,Integer.MAX_VALUE, false,false);
}
public void initializeFromFile(String file, String layer){
initializeFromFile(file, layer, false,0,Integer.MAX_VALUE, false,false);
}
public void initializeFromFile(String file, String layer, boolean multidomain){
initializeFromFile(file, layer, multidomain,0,Integer.MAX_VALUE, false,false);
}
public void initializeFromFile(String file, String layer, boolean multidomain, boolean isSSON){
initializeFromFile(file, layer, multidomain,0,Integer.MAX_VALUE, isSSON,false);
}
public void initializeFromFile(String file, String layer, boolean multidomain,int lambdaIni, int lambdaEnd){
initializeFromFile(file, layer, multidomain,0,Integer.MAX_VALUE, false,false);
}
public void initializeFromFile(String file, String layer, boolean multidomain, int lambdaIni, int lambdaEnd, boolean isSSON,boolean readOnlyInterDomainLinks){
initializeFromFile( file, layer, multidomain, lambdaIni, lambdaEnd, isSSON, readOnlyInterDomainLinks, false);
}
public void initializeFromFile(String file, String layer, boolean multidomain, int lambdaIni, int lambdaEnd, boolean isSSON,boolean readOnlyInterDomainLinks, boolean isWLAN){
domainID=FileTEDBUpdater.getDomainIDfromSimpleDomain(file);
if (readOnlyInterDomainLinks){
log.info("Read Only Inter Domain Links");
networkGraph = new SimpleDirectedWeightedGraph<Object, IntraDomainEdge>(IntraDomainEdge.class);
if (!multidomain){
interDomainLinks = FileTEDBUpdater.readInterDomainLinks(file);
}
reachabilityEntry = new ReachabilityEntry();
if (!multidomain){
FileTEDBUpdater.getDomainReachabilityFromFile(file,reachabilityEntry);
}
if((isSSON==true)&(!isWLAN)){
SSONinfo = FileTEDBUpdater.getSSONInformation(file);
}else if (isWLAN)
{
}
else
{
WSONinfo = FileTEDBUpdater.getWSONInformation(file);
}
}else{
if((isSSON==true)&&(!isWLAN)){
networkGraph=FileTEDBUpdater.readNetwork(file,layer, multidomain,lambdaIni,lambdaEnd, isSSON);
SSONinfo = FileTEDBUpdater.getSSONInformation(file);
}
else if (isWLAN)
{
networkGraph=FileTEDBUpdater.readNetwork(file,layer, multidomain,lambdaIni,lambdaEnd, isSSON);
}
else{
networkGraph=FileTEDBUpdater.readNetwork(file,layer, multidomain,lambdaIni,lambdaEnd);
WSONinfo = FileTEDBUpdater.getWSONInformation(file);
}
// if (lambdaEnd!=Integer.MAX_VALUE){
// notifyAlgorithms( lambdaIni, lambdaEnd);
// }
Iterator<Object> itervertex=networkGraph.vertexSet().iterator();
/** Se podrian sacar a una funcion externa ambos 'while'
* Rellenar info table
* Rellenar info edge
* Preguntar a Oscar
*/
while (itervertex.hasNext()) {
Object address = itervertex.next();
Node_Info ni = new Node_Info();
if (address instanceof Inet4Address){
ni.setIpv4AddressLocalNode((Inet4Address)address);
ni.setIpv4Address((Inet4Address)address);//de momento asumimos que aprendemos ospf
} else if (address instanceof DataPathID) {
ni.setDataPathLocalNode((DataPathID)address);
}
ni.setLearntFrom("Fom XML");
ni.setAs_number(domainID);
NodeTable.put(address, ni);
}
Iterator<IntraDomainEdge> iteredge=networkGraph.edgeSet().iterator();
while (iteredge.hasNext()) {
IntraDomainEdge id = (IntraDomainEdge) iteredge.next();
try{
Inet4Address ipSource = (Inet4Address) (id.getSource());
Inet4Address ipDest = (Inet4Address) (id.getTarget());
id.setLearntFrom("From XML");
Node_Info origin = new Node_Info();
Node_Info destination = new Node_Info();
origin.setIpv4AddressLocalNode(ipSource);
origin.setAs_number(domainID);
origin.setLearntFrom("FromXML");
destination.setIpv4AddressLocalNode(ipDest);
destination.setAs_number(domainID);
destination.setLearntFrom("FromXML");
id.setLocal_Node_Info(origin);
id.setRemote_Node_Info(destination);
NodeTable.get(ipSource).setSID(id.getSrc_sid());
NodeTable.get(ipDest).setSID(id.getDst_sid());
}catch (Exception e1){
DataPathID dpSource = (DataPathID) (id.getSource());
DataPathID dpDest = (DataPathID) (id.getTarget());
id.setLearntFrom("From XML");
Node_Info origin = new Node_Info();
Node_Info destination = new Node_Info();
origin.setDataPathLocalNode(dpSource);
origin.setAs_number(domainID);
origin.setLearntFrom("FromXML");
destination.setDataPathLocalNode(dpDest);
destination.setAs_number(domainID);
destination.setLearntFrom("FromXML");
id.setLocal_Node_Info(origin);
id.setRemote_Node_Info(destination);
//NodeTableDataPath.get(dpSource).setSID(id.getSrc_sid());
//NodeTableDataPath.get(dpDest).setSID(id.getDst_sid());
}
}
}
if (!multidomain){
interDomainLinks = FileTEDBUpdater.readInterDomainLinks(file);
}
else {
interDomainLinks = new LinkedList<InterDomainEdge>();
}
reachabilityEntry = new ReachabilityEntry();
if (!multidomain){
FileTEDBUpdater.getDomainReachabilityFromFile(file,reachabilityEntry);
}
Iterator<InterDomainEdge> edgeIt = interDomainLinks.iterator();
while (edgeIt.hasNext()) {
InterDomainEdge id = (InterDomainEdge) edgeIt.next();
try {
Inet4Address ipSource = (Inet4Address) (id.src_router_id);
Inet4Address ipDest = (Inet4Address) (id.dst_router_id);
id.setLearntFrom("From XML");
Node_Info origin = new Node_Info();
Node_Info destination = new Node_Info();
origin.setIpv4AddressLocalNode(ipSource);
origin.setAs_number(domainID);
origin.setLearntFrom("FromXML");
destination.setIpv4AddressLocalNode(ipDest);
destination.setAs_number((Inet4Address) id.domain_dst_router);
destination.setLearntFrom("FromXML");
id.setLocal_Node_Info(origin);
id.setRemote_Node_Info(destination);
} catch (Exception e) {
DataPathID dpSource = (DataPathID) (id.src_router_id);
DataPathID dpDest = (DataPathID) (id.dst_router_id);
id.setLearntFrom("From XML");
Node_Info origin = new Node_Info();
Node_Info destination = new Node_Info();
origin.setDataPathLocalNode(dpSource);
origin.setAs_number(domainID);
origin.setLearntFrom("FromXML");
destination.setDataPathLocalNode(dpDest);
destination.setAs_number((Inet4Address) id.domain_dst_router);
destination.setLearntFrom("FromXML");
id.setLocal_Node_Info(origin);
id.setRemote_Node_Info(destination);
}
}
}
public void notifyAlgorithms( int lambdaIni,int lambdaEnd){
LinkedList<Object> ipListScr = new LinkedList<Object> ();
LinkedList<Object> ipListDst = new LinkedList<Object> ();
Set<IntraDomainEdge> it =this.networkGraph.edgeSet();
int numLabels=0;
for (IntraDomainEdge edge:it){
numLabels=edge.TE_info.getAvailableLabels().getLabelSet().getNumLabels();
for (int i=0;i<lambdaIni;i++){
ipListScr.add(edge.getSource());
ipListDst.add(edge.getTarget());
for (int j=0;j<registeredAlgorithms.size();++j){
registeredAlgorithms.get(j).notifyWavelengthReservation(ipListScr, ipListDst, i);
}
for (int j=0;j<registeredAlgorithmssson.size();++j){
registeredAlgorithmssson.get(j).notifyWavelengthReservation(ipListScr, ipListDst, i);
}
this.notifyWavelengthReservation(ipListScr,ipListDst,i,false);
ipListScr.remove();
ipListDst.remove();
}
for (int i=lambdaEnd;i<numLabels;i++){
ipListScr.add(edge.getSource());
ipListDst.add(edge.getTarget());
for (int j=0;j<registeredAlgorithms.size();++j){
registeredAlgorithms.get(j).notifyWavelengthReservation(ipListScr, ipListDst, i);
}
for (int j=0;j<registeredAlgorithmssson.size();++j){
registeredAlgorithmssson.get(j).notifyWavelengthReservation(ipListScr, ipListDst, i);
}
this.notifyWavelengthReservation(ipListScr,ipListDst,i,false);
ipListScr.remove();
ipListDst.remove();
}
}
}
public boolean belongsToDomain(Object addr){
int i;
byte[] addrbytes=((Inet4Address)addr).getAddress();
//log.info("Entramos en belong to domain: "+ reachabilityEntry.getMask());
//UtilsFunctions.printByte(reachabilityEntry.getMask(), "Entramos en belong to domain: ", log);
for (i=0;i<4;++i){
addrbytes[i]=(byte) (addrbytes[i]&(reachabilityEntry.getMask())[i]);
}
//UtilsFunctions.printByte(addrbytes, "addrbytes", log);
//UtilsFunctions.printByte(reachabilityEntry.getAggregatedIPRange().getAddress(), "reachabilityEntry.getAggregatedIPRange", log);
//log.info("addrbytes "+addrbytes+" reachabilityEntry.getAggregatedIPRange().getAddress()"+reachabilityEntry.getAggregatedIPRange().getAddress());
log.info("Belongs to domain retunrs: "+Arrays.equals(addrbytes,reachabilityEntry.getAggregatedIPRange().getAddress()));
return Arrays.equals(addrbytes,reachabilityEntry.getAggregatedIPRange().getAddress());
}
public LinkedList<IntraDomainEdge> getIntraDomainEdges() {
return intraDomainEdges;
}
public void setIntraDomainEdges(LinkedList<IntraDomainEdge> intraDomainEdges) {
this.intraDomainEdges = intraDomainEdges;
}
public ReachabilityEntry getReachabilityEntry() {
return reachabilityEntry;
}
public void setReachabilityEntry(ReachabilityEntry reachabilityEntry) {
this.reachabilityEntry = reachabilityEntry;
}
public SimpleDirectedWeightedGraph<Object, IntraDomainEdge> getNetworkGraph() {
return networkGraph;
}
public void setNetworkGraph(
SimpleDirectedWeightedGraph<Object, IntraDomainEdge> networkGraph) {
this.networkGraph = networkGraph;
}
public LinkedList<InterDomainEdge> getInterDomainLinks() {
return interDomainLinks;
}
public void setInterDomainLinks(LinkedList<InterDomainEdge> interDomainLinks) {
this.interDomainLinks = interDomainLinks;
}
/**
* Return true if scr and dst are linked by an InterDomainLink
* @param src Source
* @param dst Destination
* @return true if scr and dst are linked by an InterDomainLink
*/
public InterDomainEdge getInterdomainLink(Object src, Object dst){
int size = interDomainLinks.size();
InterDomainEdge edge= new InterDomainEdge(src,dst);
for (int i=0;i<size;i++){
//por pantalla
InterDomainEdge edge_i = interDomainLinks.get(i);
if (edge_i.equals(edge)){
return edge_i;
}
}
return null;
}
public String printTopology(){
String topoString;
Set<Object> vetexSet= networkGraph.vertexSet();
Iterator <Object> vertexIterator=vetexSet.iterator();
topoString="Nodes: \r\n";
while (vertexIterator.hasNext()){
Object vertex= vertexIterator.next();
topoString=topoString+"\t"+vertex.toString()+"\r\n";
}
topoString=topoString+"Node Information Table::: \r\n"+NodeTable.toString()+"\r\n";
Set<IntraDomainEdge> edgeSet= networkGraph.edgeSet();
if (edgeSet != null){
Iterator <IntraDomainEdge> edgeIterator=edgeSet.iterator();
topoString=topoString+"Intradomain Link list: \r\n";
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\n";
}
}
if (interDomainLinks != null)
topoString=topoString+printInterDomainLinks();
return topoString;
}
public String printInterDomainLinks(){
String topoString="";
int size = interDomainLinks.size();
log.info("Size of InterDomainLinks: "+size);
topoString="Interdomain Link list: \r\n";
for (int i=0;i<size;i++){
//por pantalla
InterDomainEdge edge = interDomainLinks.get(i);
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
return topoString;
}
@Override
public boolean isITtedb() {
// TODO Auto-generated method stub
return false;
}
@Override
public void notifyWavelengthReservationWLAN(LinkedList<Object> sourceVertexList,LinkedList<Object> targetVertexList,LinkedList<Integer> wlans, boolean bidirectional)
{
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wlans.get(i));
log.info("Reservo: "+sourceVertexList.get(i).toString() + "-"+ targetVertexList.get(i).toString() +" wavelength: "+wlans.get(i)+" bidirectional"+bidirectional);
if (bidirectional == true){
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wlans.get(i));
//log.info(""+edge.toString());
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wlans.get(i));
if (bidirectional == true){
registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wlans.get(i));
}
}
}
@Override
public void notifyWavelengthReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional){
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wavelength);
log.info("Reservo: "+sourceVertexList.get(i).toString() + "-"+ targetVertexList.get(i).toString() +" wavelength: "+wavelength+" bidirectional"+bidirectional);
if (bidirectional == true){
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wavelength);
//log.info(""+edge.toString());
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wavelength);
if (bidirectional == true){
registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wavelength);
}
}
}
public void notifyWavelengthReservationSSON(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional, int m){
TEDBlock.lock();
try {
for (int j=0;j<2*m;j++){
for (int i=0;i<sourceVertexList.size();++i){
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
//log.info("sourceVertexList.size()"+sourceVertexList.size());
edge.getTE_info().setWavelengthReserved(wavelength-m+j);
//log.info("Reserving in TEDB: "+edge.toString());
if (bidirectional == true){
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wavelength-m+j);
//log.info("Reserving in TEDB: "+edge.toString());
}
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithmssson.size();++i){
(registeredAlgorithmssson.get(i)).notifyWavelengthReservationSSON(sourceVertexList, targetVertexList, wavelength, m);
if (bidirectional == true){
(registeredAlgorithmssson.get(i)).notifyWavelengthReservationSSON(targetVertexList, sourceVertexList, wavelength, m);
}
}
}
@Override
public void notifyWavelengthEndReservationSSON(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional, int m){
// TODO Auto-generated method stub
//Delete the resource reservation
TEDBlock.lock();
try {
for (int j=0;j<2*m;j++){
for (int i=0;i<sourceVertexList.size();++i){
// SimpleDirectedWeightedGraph<Object,FiberLinkEdge> graph= ted.getNetworkGraph();
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i),targetVertexList.get(i) );
edge.getTE_info().setWavelengthUnReserved(wavelength-m+j);
//log.info("Derreserving in TEDB: "+edge.toString());
if (bidirectional == true)
{
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthUnReserved(wavelength-m+j);
//log.info("Derreserving in TEDB: "+edge.toString());
}
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithmssson.size();++i){
(registeredAlgorithmssson.get(i)).notifyWavelengthEndReservationSSON(sourceVertexList, targetVertexList, wavelength, m);
if (bidirectional == true){
(registeredAlgorithmssson.get(i)).notifyWavelengthEndReservationSSON(targetVertexList, sourceVertexList, wavelength, m);
}
}
//FIXME:TEMPORAL!!!!!!
//requestDispatcher.moveRetryQueueToComputingRequestQueue();
//Call request dispatcher to pass requests to queue?
}
@Override
public void notifyWavelengthEndReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength, boolean bidirectional){
// TODO Auto-generated method stub
//Delete the resource reservation
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
// SimpleDirectedWeightedGraph<Object,FiberLinkEdge> graph= ted.getNetworkGraph();
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i),targetVertexList.get(i) );
edge.getTE_info().setWavelengthUnReserved(wavelength);
//log.info(""+edge.toString());
if (bidirectional == true)
{
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthUnReserved(wavelength);
//log.info(""+edge.toString());
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthEndReservation(sourceVertexList, targetVertexList, wavelength);
if (bidirectional == true){
registeredAlgorithms.get(i).notifyWavelengthEndReservation(targetVertexList, sourceVertexList, wavelength);
}
}
//FIXME:TEMPORAL!!!!!!
//requestDispatcher.moveRetryQueueToComputingRequestQueue();
//Call request dispatcher to pass requests to queue?
}
@Override
public boolean containsVertex(Object vertex) {
return networkGraph.containsVertex(vertex);
}
public Hashtable<Object, Node_Info> getNodeTable() {
return NodeTable;
}
public void setNodeTable(Hashtable<Object, Node_Info> nodeTable) {
NodeTable = nodeTable;
}
public boolean isMultidomain() {
return multidomain;
}
public void setMultidomain(boolean multidomain) {
this.multidomain = multidomain;
}
public void registerSSON (SSONListener algo){
registeredAlgorithmssson.add(algo);
}
public void register (TEDListener algo){
registeredAlgorithms.add(algo);
}
@Override
public void notifyWavelengthChange(Object localInterfaceIPAddress, Object remoteInterfaceIPAddress, BitmapLabelSet previousBitmapLabelSet, BitmapLabelSet newBitmapLabelSet) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthStatusChange(localInterfaceIPAddress, remoteInterfaceIPAddress, previousBitmapLabelSet, newBitmapLabelSet);
}
if (registeredAlgorithms.isEmpty()){
for (int i=0;i<registeredAlgorithmssson.size();++i){
registeredAlgorithmssson.get(i).notifyWavelengthStatusChange(localInterfaceIPAddress, remoteInterfaceIPAddress, previousBitmapLabelSet, newBitmapLabelSet);
}
}
}
@Override
public void notifyNewVertex(Object vertex) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyNewVertex(vertex);
}
for (int i=0;i<registeredAlgorithmssson.size();++i){
registeredAlgorithmssson.get(i).notifyNewVertex(vertex);
}
}
@Override
public void notifyNewEdge(Object source, Object destination) {
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyNewEdge(source,destination);
}
for (int i=0;i<registeredAlgorithmssson.size();++i){
registeredAlgorithmssson.get(i).notifyNewEdge(source,destination);
}
}
@Override
public WSONInformation getWSONinfo() {
return WSONinfo;
}
@Override
public SSONInformation getSSONinfo() {
return SSONinfo;
}
@Override
public void clearAllReservations() {
if (WSONinfo!=null){
TEDBlock.lock();
try{
Set<IntraDomainEdge> edgeSet= networkGraph.edgeSet();
Iterator <IntraDomainEdge> edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
edge.TE_info.setAllWavelengtshUnReserved();
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyTEDBFullUpdate();
}
}
}
public Lock getTEDBlock() {
return TEDBlock;
}
public void setTEDBlock(Lock tEDBlock) {
TEDBlock = tEDBlock;
}
@Override
public void notifyNewEdgeIP(Object source, Object destination,
TE_Information informationTEDB) {
// TODO Auto-generated method stub
}
public void setWSONinfo(WSONInformation wSONinfo) {
WSONinfo = wSONinfo;
}
public void setSSONinfo(SSONInformation sSONinfo) {
SSONinfo = sSONinfo;
}
public String printBaseTopology(){
String topoString;
Set<Object> vetexSet= networkGraph.vertexSet();
Iterator <Object> vertexIterator=vetexSet.iterator();
topoString="NodesFEO: \r\n";
while (vertexIterator.hasNext()){
Object vertex= vertexIterator.next();
topoString=topoString+"\t"+vertex.toString()+"\r\n";
}
topoString=topoString+"Intradomain Link list: \r\n";
Set<IntraDomainEdge> edgeSet= networkGraph.edgeSet();
Iterator <IntraDomainEdge> edgeIterator=edgeSet.iterator();
while (edgeIterator.hasNext()){
IntraDomainEdge edge= edgeIterator.next();
topoString=topoString+"\t"+edge.toString()+"\r\n";
}
return topoString;
}
@Override
public Inet4Address getDomainID() {
// TODO Auto-generated method stub
return domainID;
}
public void setDomainID(Inet4Address domainID) {
this.domainID = domainID;
}
@Override
public Set<IntraDomainEdge> getIntraDomainLinks() {
return this.getNetworkGraph().edgeSet();
}
public Set<Object> getIntraDomainLinksvertexSet() {
return this.getNetworkGraph().vertexSet();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((domainID == null) ? 0 : domainID.hashCode());
result = prime * result + ((intraDomainEdges == null) ? 0 : intraDomainEdges.hashCode());
result = prime * result + ((networkGraph == null) ? 0 : networkGraph.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SimpleTEDB other = (SimpleTEDB) obj;
if (intraDomainEdges == null) {
if (other.intraDomainEdges != null)
return false;
} else if (!intraDomainEdges.equals(other.intraDomainEdges))
return false;
if (networkGraph == null) {
if (other.networkGraph != null)
return false;
}
for(Object v : networkGraph.vertexSet()){
if(!other.networkGraph.containsVertex(v))
return false;
}
for(IntraDomainEdge e :networkGraph.edgeSet()){
boolean flagEqual=false;
for(IntraDomainEdge otherE : other.networkGraph.edgeSet()){
if(e.toString().equals(otherE.toString()))flagEqual=true;
}
if(flagEqual==false)return false; //edge not present in other
}
for(IntraDomainEdge e :other.networkGraph.edgeSet()){
boolean flagEqual=false;
for(IntraDomainEdge otherE : networkGraph.edgeSet()){
if(e.toString().equals(otherE.toString()))flagEqual=true;
}
if(flagEqual==false)return false; //edge not present in other
}
return true;
}
public IT_Resources getItResources() {
return itResources;
}
public void setItResources(IT_Resources itResources) {
this.itResources = itResources;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.util.LinkedList;
/**
* Base Interface for a Generic Traffic Engineering Database
* @author ogondio
*
*/
public interface TEDB {
public void initializeFromFile(String file);
public void initializeFromFile(String file, String learnFrom);
public boolean isITtedb(); //FIXME: Remove!
public String printTopology();
public LinkedList<InterDomainEdge> getInterDomainLinks();
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
public class TEDBUpdater {
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import java.util.LinkedList;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.complexFields.BitmapLabelSet;
public interface TEDListener {
public void notifyNewVertex(Object vertex);
public void notifyNewEdge(Object source, Object destination);
public void notifyWavelengthStatusChange(Object source, Object destination, BitmapLabelSet previousBitmapLabelSet, BitmapLabelSet newBitmapLabelSet);
public void notifyWavelengthReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength);
public void notifyWavelengthEndReservation(LinkedList<Object> sourceVertexList, LinkedList<Object> targetVertexList, int wavelength);
public void notifyTEDBFullUpdate();
public void notifyNewEdgeIP(Object source, Object destination, TE_Information informationTEDB);
public void notificationEdgeIP_AuxGraph(Object src, Object dst, TE_Information informationTEDB);
public void notificationEdgeOPTICAL_AuxGraph(Object src, Object dst, int lambda);
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.DefaultTEMetricLinkAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.IPv4RouterIDLocalNodeLinkAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.IPv4RouterIDRemoteNodeLinkAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.LinkProtectionTypeLinkAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.MF_OTPAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.MetricLinkAttribTLV;
import es.tid.bgp.bgp4.update.tlv.linkstate_attribute_tlvs.TransceiverClassAndAppAttribTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.MinMaxUndirectionalLinkDelayDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalAvailableBandwidthDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalDelayVariationDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalLinkDelayDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalLinkLossDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalResidualBandwidthDescriptorSubTLV;
import es.tid.bgp.bgp4.update.tlv.node_link_prefix_descriptor_subTLVs.UndirectionalUtilizedBandwidthDescriptorSubTLV;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.AdministrativeGroup;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.AvailableLabels;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.IPv4RemoteASBRID;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.InterfaceSwitchingCapabilityDescriptor;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.LinkLocalRemoteIdentifiers;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.LinkProtectionType;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.MaximumBandwidth;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.MaximumReservableBandwidth;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.RemoteASNumber;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.SharedRiskLinkGroup;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.TrafficEngineeringMetric;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.UnreservedBandwidth;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.complexFields.BitmapLabelSet;
import es.tid.rsvp.constructs.gmpls.DWDMWavelengthLabel;
public class TE_Information {
private TrafficEngineeringMetric trafficEngineeringMetric;
private DefaultTEMetricLinkAttribTLV defaultTEMetric;
private MaximumBandwidth maximumBandwidth;
private MaximumReservableBandwidth maximumReservableBandwidth;
private UnreservedBandwidth unreservedBandwidth;
private AdministrativeGroup administrativeGroup;
private LinkLocalRemoteIdentifiers linkLocalRemoteIdentifiers;
private LinkProtectionType linkProtectionType;
private LinkProtectionTypeLinkAttribTLV linkProtectionBGPLS;
private InterfaceSwitchingCapabilityDescriptor interfaceSwitchingCapabilityDescriptor;
private SharedRiskLinkGroup sharedRiskLinkGroup;
private RemoteASNumber remoteASNumber;
private IPv4RemoteASBRID iPv4RemoteASBRID;
private IPv4RouterIDLocalNodeLinkAttribTLV iPv4LocalNode;
private IPv4RouterIDRemoteNodeLinkAttribTLV iPv4RemoteNode;
private UndirectionalLinkDelayDescriptorSubTLV undirLinkDelay;
private MinMaxUndirectionalLinkDelayDescriptorSubTLV minMaxUndirLinkDelay;
private UndirectionalDelayVariationDescriptorSubTLV undirDelayVar;
private UndirectionalLinkLossDescriptorSubTLV undirLinkLoss;
private UndirectionalResidualBandwidthDescriptorSubTLV undirResidualBw;
private UndirectionalAvailableBandwidthDescriptorSubTLV undirAvailableBw;
private UndirectionalUtilizedBandwidthDescriptorSubTLV undirUtilizedBw;
private MetricLinkAttribTLV metric;
private AvailableLabels availableLabels;
private MF_OTPAttribTLV mfOTF;
private TransceiverClassAndAppAttribTLV trans;
private int NumberWLANs = 15;
private boolean withWLANs = false;
private boolean[] occupiedWLANs;
private boolean[] reservedWLANs;
private boolean vlanLink = false;
private int vlan;
/**
* TEDB logger
*/
public TE_Information()
{
//initWLANs();
}
public AvailableLabels getAvailableLabels() {
return availableLabels;
}
public void setAvailableLabels(AvailableLabels availableLabels) {
this.availableLabels = availableLabels;
}
public TrafficEngineeringMetric getTrafficEngineeringMetric() {
return trafficEngineeringMetric;
}
public void setTrafficEngineeringMetric(
TrafficEngineeringMetric trafficEngineeringMetric) {
this.trafficEngineeringMetric = trafficEngineeringMetric;
}
public MaximumBandwidth getMaximumBandwidth() {
return maximumBandwidth;
}
public void setMaximumBandwidth(MaximumBandwidth maximumBandwidth) {
this.maximumBandwidth = maximumBandwidth;
}
public MaximumReservableBandwidth getMaximumReservableBandwidth() {
return maximumReservableBandwidth;
}
public IPv4RouterIDRemoteNodeLinkAttribTLV getiPv4RemoteNode() {
return iPv4RemoteNode;
}
public void setiPv4RemoteNode(IPv4RouterIDRemoteNodeLinkAttribTLV iPv4RemoteNode) {
this.iPv4RemoteNode = iPv4RemoteNode;
}
public void setMaximumReservableBandwidth(
MaximumReservableBandwidth maximumReservableBandwidth) {
this.maximumReservableBandwidth = maximumReservableBandwidth;
}
public UnreservedBandwidth getUnreservedBandwidth() {
return unreservedBandwidth;
}
public void setUnreservedBandwidth(UnreservedBandwidth unreservedBandwidth) {
this.unreservedBandwidth = unreservedBandwidth;
}
public UndirectionalLinkDelayDescriptorSubTLV getUndirLinkDelay() {
return undirLinkDelay;
}
public void setUndirLinkDelay(UndirectionalLinkDelayDescriptorSubTLV undirLinkDelay) {
this.undirLinkDelay = undirLinkDelay;
}
public MinMaxUndirectionalLinkDelayDescriptorSubTLV getMinMaxUndirLinkDelay() {
return minMaxUndirLinkDelay;
}
public void setMinMaxUndirLinkDelay(MinMaxUndirectionalLinkDelayDescriptorSubTLV minMaxUndirLinkDelay) {
this.minMaxUndirLinkDelay = minMaxUndirLinkDelay;
}
public UndirectionalDelayVariationDescriptorSubTLV getUndirDelayVar() {
return undirDelayVar;
}
public void setUndirDelayVar(UndirectionalDelayVariationDescriptorSubTLV undirDelayVar) {
this.undirDelayVar = undirDelayVar;
}
public UndirectionalLinkLossDescriptorSubTLV getUndirLinkLoss() {
return undirLinkLoss;
}
public void setUndirLinkLoss(UndirectionalLinkLossDescriptorSubTLV undirLinkLoss) {
this.undirLinkLoss = undirLinkLoss;
}
public UndirectionalResidualBandwidthDescriptorSubTLV getUndirResidualBw() {
return undirResidualBw;
}
public void setUndirResidualBw(UndirectionalResidualBandwidthDescriptorSubTLV undirResidualBw) {
this.undirResidualBw = undirResidualBw;
}
public UndirectionalAvailableBandwidthDescriptorSubTLV getUndirAvailableBw() {
return undirAvailableBw;
}
public void setUndirAvailableBw(UndirectionalAvailableBandwidthDescriptorSubTLV undirAvailableBw) {
this.undirAvailableBw = undirAvailableBw;
}
public UndirectionalUtilizedBandwidthDescriptorSubTLV getUndirUtilizedBw() {
return undirUtilizedBw;
}
public void setUndirUtilizedBw(UndirectionalUtilizedBandwidthDescriptorSubTLV undirUtilizedBw) {
this.undirUtilizedBw = undirUtilizedBw;
}
public AdministrativeGroup getAdministrativeGroup() {
return administrativeGroup;
}
public void setAdministrativeGroup(AdministrativeGroup administrativeGroup) {
this.administrativeGroup = administrativeGroup;
}
public LinkLocalRemoteIdentifiers getLinkLocalRemoteIdentifiers() {
return linkLocalRemoteIdentifiers;
}
public void setLinkLocalRemoteIdentifiers(
LinkLocalRemoteIdentifiers linkLocalRemoteIdentifiers) {
this.linkLocalRemoteIdentifiers = linkLocalRemoteIdentifiers;
}
public LinkProtectionType getLinkProtectionType() {
return linkProtectionType;
}
public void setLinkProtectionType(LinkProtectionType linkProtectionType) {
this.linkProtectionType = linkProtectionType;
}
public InterfaceSwitchingCapabilityDescriptor getInterfaceSwitchingCapabilityDescriptor() {
return interfaceSwitchingCapabilityDescriptor;
}
public void setInterfaceSwitchingCapabilityDescriptor(
InterfaceSwitchingCapabilityDescriptor interfaceSwitchingCapabilityDescriptor) {
this.interfaceSwitchingCapabilityDescriptor = interfaceSwitchingCapabilityDescriptor;
}
public SharedRiskLinkGroup getSharedRiskLinkGroup() {
return sharedRiskLinkGroup;
}
public void setSharedRiskLinkGroup(SharedRiskLinkGroup sharedRiskLinkGroup) {
this.sharedRiskLinkGroup = sharedRiskLinkGroup;
}
public RemoteASNumber getRemoteASNumber() {
return remoteASNumber;
}
public void setRemoteASNumber(RemoteASNumber remoteASNumber) {
this.remoteASNumber = remoteASNumber;
}
public IPv4RemoteASBRID getiPv4RemoteASBRID() {
return iPv4RemoteASBRID;
}
public void setiPv4RemoteASBRID(IPv4RemoteASBRID iPv4RemoteASBRID) {
this.iPv4RemoteASBRID = iPv4RemoteASBRID;
}
public int getNumberWLANs() {
return NumberWLANs;
}
public void setNumberWLANs(int numberWLANs) {
NumberWLANs = numberWLANs;
}
public boolean isWLANFree()
{
/*
for (int i = 0; i < reservedWLANs.length; i++)
{
if (reservedWLANs[i] == false)
{
return true;
}
}
return false;
*/
return true;
}
public Integer getFreeWLAN()
{
for (int i = 0; i < reservedWLANs.length; i++)
{
if (reservedWLANs[i] == false)
{
return i;
}
}
return null;
}
public void initWLANs()
{
withWLANs = true;
occupiedWLANs = new boolean[NumberWLANs];
reservedWLANs = new boolean[NumberWLANs];
for (int i = 0 ; i < NumberWLANs ; i++)
{
occupiedWLANs[i] = false;
reservedWLANs[i] = false;
}
}
public void createBitmapLabelSet(int numLabels,int grid, int cs,int n){
createBitmapLabelSet(numLabels,grid,cs,n,0,numLabels);
}
public void createBitmapLabelSet(int numLabels,int grid, int cs,int n,int lambdaIni, int lambdaEnd){
//FIXME: no hay problema de que se salga el ancho de banda
//log.info("Creamos bit map");
BitmapLabelSet bitmapLabelSet = new BitmapLabelSet();
DWDMWavelengthLabel dwdmWavelengthLabel = new DWDMWavelengthLabel();
dwdmWavelengthLabel.setGrid(grid);
dwdmWavelengthLabel.setChannelSpacing(cs);
dwdmWavelengthLabel.setN(n);
bitmapLabelSet.setDwdmWavelengthLabel(dwdmWavelengthLabel);
int numberBytes = getNumberBytes(numLabels);
byte[] bytesBitMap = new byte[numberBytes];
for (int i=0;i<numberBytes;i++)
bytesBitMap[i]=0x00;
bitmapLabelSet.setBytesBitmap(bytesBitMap);
byte[] bytesBitMapRes = new byte[numberBytes];
for (int i=0;i<numberBytes;i++)
bytesBitMapRes[i]=0x00;
/*----Opcion: LAMBDA SUBSET----*/
/*Ponemos a 1 los bytes del BitMap que no maneje el pce. Esto es como poner tiempo de reserva infinito*/
/*Traducir lambdaIni a numero de bytes*/
int numberBytesLambdaIni = getNumberBytes(lambdaIni);
/*Traducir lambdaEnd a numero bytes*/
int numberBytesLambdaEnd =getNumberBytes( lambdaEnd);
for (int i=0;i<numberBytesLambdaIni;i++){
bytesBitMapRes[i]= (byte) 0xff;
bytesBitMap[i]= (byte) 0xff;
}
for (int i=numberBytesLambdaEnd;i<numberBytes;i++){
bytesBitMapRes[i]= (byte) 0xff;
bytesBitMap[i]= (byte) 0xff;
}
System.out.println("Setting Bytes:\n\rBytes: "+numberBytes+"\n\rLambdaIni: "+numberBytesLambdaIni+"\n\rLambdaEnd: "+numberBytesLambdaEnd);
//FuncionesUtiles.printByte(bytesBitMap, "bytesBitMap",log);
bitmapLabelSet.setBytesBitmapReserved(bytesBitMapRes);
bitmapLabelSet.setNumLabels(numLabels);
availableLabels = new AvailableLabels();
availableLabels.setLabelSet(bitmapLabelSet);
}
/**
* Funcion que transforma una cantidad de bits en el numero de bytes que necesita
* @param numBit
*/
private int getNumberBytes(int numBits){
int numberBytes = numBits/8;
if ((numberBytes*8)<numBits){
numberBytes++;
}
return numberBytes;
}
public boolean[] getCopyUnreservedWLANs()
{
boolean[] ret = new boolean[NumberWLANs];
System.arraycopy( reservedWLANs, 0, ret, 0, ret.length );
return ret;
}
public void setFreeWLANS (boolean[] orig)
{
reservedWLANs = orig;
}
public void setWavelengthOccupied(int num_wavelength)
{
if (withWLANs)
{
occupiedWLANs[num_wavelength] = true;
}
else
{
int num_byte=num_wavelength/8;
((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitMap()[num_byte]=(byte)((((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitMap()[num_byte])|(0x80>>>(num_wavelength%8)));
}
}
public void setWavelengthFree(int num_wavelength)
{
if (withWLANs)
{
occupiedWLANs[num_wavelength] = false;
reservedWLANs[num_wavelength] = false;
}
else
{
int num_byte=num_wavelength/8;
((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitMap()[num_byte]=(byte)(((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitMap()[num_byte]&(0xFFFF7F>>>(num_wavelength%8)));
}
}
public void setWavelengthReserved(int num_wavelength){
if (withWLANs)
{
reservedWLANs[num_wavelength] = true;
}
else
{
int num_byte=num_wavelength/8;
// if ( this.getAvailableLabels()==null){
// PCEServer.log.info("AvailableLabels ES NULL");
//
// }
// if ( this.getAvailableLabels().getLabelSet()==null){
// PCEServer.log.info("AvailableLabels LABEL SET ES NULL");
//
// }
// if (((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()==null){
// PCEServer.log.info("BytesBitmapReserved ES NULL");
//
// }
((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[num_byte]=(byte)((((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[num_byte])|(0x80>>>(num_wavelength%8)));
}
}
public void setWavelengthUnReserved(int num_wavelength){
if (withWLANs)
{
reservedWLANs[num_wavelength] = false;
}
else
{
int num_byte=num_wavelength/8;
((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[num_byte]=(byte)(((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[num_byte]&(0xFFFF7F>>>(num_wavelength%8)));
}
}
public void setAllWavelengtshUnReserved(){
if (withWLANs)
{
for (int i = 0; i < reservedWLANs.length; i++)
{
reservedWLANs[i] = false;
}
}
else
{
int num_bytes=((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved().length;
for (int i=0;i<num_bytes;++i){
((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[i]=0x00;
}
}
}
public boolean isWavelengthFree(int num_wavelength){
if (withWLANs)
{
return (!occupiedWLANs[num_wavelength]);
}
else
{
int num_byte=num_wavelength/8;
return ((((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitMap()[num_byte]&(0x80>>>(num_wavelength%8)))==0);
}
}
public boolean isWavelengthUnreserved(int num_wavelength){//si es true esta unreserved
if (withWLANs)
{
return (!reservedWLANs[num_wavelength]);
}
else
{
int num_byte=num_wavelength/8;
if (((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()==null){
return false;
}
else{
return ((((BitmapLabelSet)this.getAvailableLabels().getLabelSet()).getBytesBitmapReserved()[num_byte]&(0x80>>>(num_wavelength%8)))==0);
}
}
}
public String toString(){
String ret="";
// if (linkType!=null){
// ret=ret+linkType.toString()+"\t";
// }
// if (linkID!=null){
// ret=ret+linkID.toString()+"\t";
// }
// if (localInterfaceIPAddress!=null){
// ret=ret+localInterfaceIPAddress.toString()+"\r\n";
// }
// if (remoteInterfaceIPAddress!=null){
// ret=ret+remoteInterfaceIPAddress.toString()+"\r\n";
// }
if (maximumBandwidth!=null){
ret=ret+maximumBandwidth.toStringShort()+"\t";
}
if (maximumReservableBandwidth!=null){
ret=ret+maximumReservableBandwidth.toString()+"\t";
}
if (unreservedBandwidth!=null){
ret=ret+unreservedBandwidth.toStringShort()+"\t";
}
if (administrativeGroup!=null){
ret=ret+administrativeGroup.toString()+"\t";
}
if (remoteASNumber!=null){
ret=ret+remoteASNumber.toString()+"\t";
}
if (iPv4RemoteASBRID!=null){
ret=ret+iPv4RemoteASBRID.toString()+"\t";
}
if (availableLabels!= null){
ret=ret+availableLabels.toString()+"\r\n";
}
if (iPv4LocalNode!=null){
ret=ret+iPv4LocalNode.toString()+"\r\n";
}
if (iPv4RemoteNode!=null){
ret=ret+iPv4RemoteNode.toString()+"\r\n";
}
if(linkProtectionBGPLS!=null){
ret=ret+linkProtectionBGPLS.toString()+"\r\n";
}
if(trafficEngineeringMetric!=null){
ret=ret+trafficEngineeringMetric.toString()+"\r\n";
}
if(metric!=null){
ret=ret+metric.toString()+"\r\n";
}
if(defaultTEMetric!=null){
ret=ret+defaultTEMetric.toString()+"\r\n";
}
if(this.mfOTF !=null){
ret=ret+mfOTF.toString()+"\r\n";
}
if(this.trans !=null){
ret=ret+trans.toString()+"\r\n";
}
if(undirLinkDelay!=null){
ret=ret+undirLinkDelay.toString()+"\r\n";
}
if(minMaxUndirLinkDelay!=null){
ret=ret+minMaxUndirLinkDelay.toString()+"\r\n";
}
if(undirDelayVar!=null){
ret=ret+undirDelayVar.toString()+"\r\n";
}
if(undirLinkLoss!=null){
ret=ret+undirLinkLoss.toString()+"\r\n";
}
if(undirResidualBw!=null){
ret=ret+undirResidualBw.toString()+"\r\n";
}
if(undirAvailableBw!=null){
ret=ret+undirAvailableBw.toString()+"\r\n";
}
if(undirUtilizedBw!=null){
ret=ret+undirUtilizedBw.toString()+"\r\n";
}
return ret;
}
public boolean isVlanLink() {
return vlanLink;
}
public void setVlanLink(boolean vlanLink) {
this.vlanLink = vlanLink;
}
public int getVlan() {
return vlan;
}
public void setVlan(int vlan) {
this.vlan = vlan;
}
public void setiPv4LocalNode(IPv4RouterIDLocalNodeLinkAttribTLV iPv4RouterIDLocalNode) {
this.iPv4LocalNode = iPv4RouterIDLocalNode;
}
public IPv4RouterIDLocalNodeLinkAttribTLV getiPv4LocalNode() {
return iPv4LocalNode;
}
public MetricLinkAttribTLV getMetric() {
return metric;
}
public void setMetric(MetricLinkAttribTLV metric) {
this.metric = metric;
}
public LinkProtectionTypeLinkAttribTLV getLinkProtectionBGPLS() {
return linkProtectionBGPLS;
}
public void setLinkProtectionBGPLS(LinkProtectionTypeLinkAttribTLV linkProtectionBGPLS) {
this.linkProtectionBGPLS = linkProtectionBGPLS;
}
public DefaultTEMetricLinkAttribTLV getDefaultTEMetric() {
return defaultTEMetric;
}
public void setDefaultTEMetric(DefaultTEMetricLinkAttribTLV defaultTEMetric) {
this.defaultTEMetric = defaultTEMetric;
}
public MF_OTPAttribTLV getMfOTF() {
return mfOTF;
}
public void setMfOTF(MF_OTPAttribTLV mfOTF) {
this.mfOTF = mfOTF;
}
public TransceiverClassAndAppAttribTLV getTrans() {
return trans;
}
public void setTrans(TransceiverClassAndAppAttribTLV trans) {
this.trans = trans;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
import es.tid.ospf.ospfv2.lsa.tlv.subtlv.AvailableLabels;
public class WSONInformation {
/**
* In case the Network is WSON, this is the list of available Labels
*/
private AvailableLabels commonAvailableLabels;
/**
* In case the Network is WSON, this is the number of wavelengths. -1 means it is not WSON.
*/
private int numLambdas=-1;
int grid=0;
int cs=0;
int nMin=0;
public int getGrid() {
return grid;
}
public void setGrid(int grid) {
this.grid = grid;
}
public int getCs() {
return cs;
}
public void setCs(int cs) {
this.cs = cs;
}
public int getnMin() {
return nMin;
}
public void setnMin(int nMin) {
this.nMin = nMin;
}
public AvailableLabels getCommonAvailableLabels() {
return commonAvailableLabels;
}
public void setCommonAvailableLabels(AvailableLabels commonAvailableLabels) {
this.commonAvailableLabels = commonAvailableLabels;
}
public int getNumLambdas() {
return numLambdas;
}
public void setNumLambdas(int numLambdas) {
this.numLambdas = numLambdas;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb;
public interface WSONListener {
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb.controllers;
import java.io.File;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import eu.teraflow.tid.tedb.DomainTEDB;
import eu.teraflow.tid.tedb.IntraDomainEdge;
import eu.teraflow.tid.tedb.SimpleTEDB;
import eu.teraflow.tid.tedb.TE_Information;
import eu.teraflow.tid.tedb.elements.RouterInfoPM;
/**
*
* @author jaume i la humiltat
*
*
* Class that receives a DomainTED and updates. Then it dies.
*/
public class TEDUpdaterController extends Thread
{
protected Hashtable<Integer,MyEdge> interDomainLinks = new Hashtable<Integer,MyEdge>();
protected ArrayList<String> ips = null;
protected ArrayList<String> ports = null;
protected String topologyPathNodes = "";
protected String topologyPathLinks = "";
protected SimpleTEDB TEDB;
protected Logger log;
protected Lock lock = null;
protected String interDomainFile = null;
public TEDUpdaterController(){};
public TEDUpdaterController(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
ips = new ArrayList<String>();
ports = new ArrayList<String>();
ips.add(ip);
ports.add(port);
this.topologyPathLinks = topologyPathLinks;
this.topologyPathNodes = topologyPathNodes;
this.TEDB = (SimpleTEDB)ted;
this.log = log;
}
public TEDUpdaterController(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log, Lock lock)
{
ips = new ArrayList<String>();
ports = new ArrayList<String>();
ips.add(ip);
ports.add(port);
this.topologyPathLinks = topologyPathLinks;
this.topologyPathNodes = topologyPathNodes;
this.TEDB = (SimpleTEDB)ted;
this.log = log;
this.lock = lock;
}
public TEDUpdaterController(ArrayList<String> ips, ArrayList<String>ports , String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
this.ips = ips;
this.ports = ports;
this.topologyPathLinks = topologyPathLinks;
this.topologyPathNodes = topologyPathNodes;
this.TEDB = (SimpleTEDB)ted;
this.log = log;
}
public static void parseRemainingLinksFromXML(DomainTEDB TEDB, String interDomainFile)
{
Hashtable<Integer,MyEdge> interDomainLinks = readInterDomainFile(interDomainFile);
Map<Integer, MyEdge> map = interDomainLinks;
Iterator<Map.Entry<Integer, MyEdge>> it = map.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<Integer, MyEdge> entry = it.next();
MyEdge edgeAux = entry.getValue();
IntraDomainEdge edge= new IntraDomainEdge();
edge.setSrc_if_id(new Long(edgeAux.source_port));
edge.setDst_if_id(new Long(edgeAux.dest_port));
TE_Information tE_info = new TE_Information();
tE_info.setNumberWLANs(15);
tE_info.initWLANs();
tE_info.setVlanLink(true);
tE_info.setVlan(edgeAux.vlan);
edge.setTE_info(tE_info);
System.out.println("Adding InterDomain Edge!!::Vlan::"+edgeAux.vlan);
SimpleDirectedWeightedGraph sdwg = ((SimpleTEDB)TEDB).getNetworkGraph();
if (!sdwg.containsVertex(new RouterInfoPM(edgeAux.source)))
{
sdwg.addVertex(new RouterInfoPM(edgeAux.source));
}
if (!sdwg.containsVertex(new RouterInfoPM(edgeAux.dest)))
{
sdwg.addVertex(new RouterInfoPM(edgeAux.dest));
}
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(new RouterInfoPM(edgeAux.source), new RouterInfoPM(edgeAux.dest), edge);
}
}
public static Hashtable<Integer, MyEdge> readInterDomainFile(String interDomainFile)
{
System.out.println("Parsing intradomain File");
Hashtable<Integer, MyEdge> interDomainLinks = new Hashtable<Integer,MyEdge>();
try
{
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
File confFile = new File(interDomainFile);
Document doc = builder.parse(confFile);
NodeList list_nodes_Edges = doc.getElementsByTagName("edge");
System.out.println("num edges: " + list_nodes_Edges.getLength());
for (int i = 0; i < list_nodes_Edges.getLength(); i++)
{
Element nodes_servers = (Element) list_nodes_Edges.item(i);
String source = getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("source").item(0));
String dest = getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("dest").item(0));
Integer vlan = Integer.parseInt(getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("vlan").item(0)));
String direction = getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("direction").item(0));
int source_port = Integer.parseInt(getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("source_port").item(0)));
int dest_port = Integer.parseInt(getCharacterDataFromElement((Element) nodes_servers.getElementsByTagName("dest_port").item(0)));
System.out.println("Adding IntraDomain Link! source: "+source+", dest: "+dest+", source_port: "+source_port+", dest_port: "+dest_port);
MyEdge auxEdge = new TEDUpdaterController().new MyEdge(source, dest, vlan, source_port, dest_port);
interDomainLinks.put(auxEdge.hashCode(), auxEdge);
if (direction.equals("bidirectional"))
{
MyEdge reverseEdge = new TEDUpdaterController().new MyEdge(dest, source, vlan, source_port, dest_port);
interDomainLinks.put(reverseEdge.hashCode(), reverseEdge);
}
}
}
catch (Exception e)
{
System.out.println(e.toString());
}
return interDomainLinks;
}
private static String getCharacterDataFromElement(Element e)
{
Node child = e.getFirstChild();
if (child instanceof CharacterData)
{
CharacterData cd = (CharacterData) child;
return cd.getData();
}
else
{
return "?";
}
}
public class MyEdge
{
String source;
String dest;
Integer source_port;
Integer dest_port;
Integer vlan;
MyEdge(String source, String dest)
{
this.source = source;
this.dest = dest;
}
MyEdge(String source, String dest, Integer vlan, Integer source_port, Integer dest_port)
{
this.source = source;
this.dest = dest;
this.source_port = source_port;
this.dest_port = dest_port;
this.vlan = vlan;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dest == null) ? 0 : dest.hashCode());
result = prime * result
+ ((source == null) ? 0 : source.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MyEdge other = (MyEdge) obj;
if (dest == null) {
if (other.dest != null)
return false;
} else if (!dest.equals(other.dest))
return false;
if (source == null) {
if (other.source != null)
return false;
} else if (!source.equals(other.source))
return false;
return true;
}
}
public String getInterDomainFile()
{
return interDomainFile;
}
public void setInterDomainFile(String interDomainFile)
{
this.interDomainFile = interDomainFile;
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb.controllers;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import eu.teraflow.tid.tedb.DomainTEDB;
import eu.teraflow.tid.tedb.IntraDomainEdge;
import eu.teraflow.tid.tedb.SimpleTEDB;
import eu.teraflow.tid.tedb.TE_Information;
import eu.teraflow.tid.tedb.elements.RouterInfoPM;
/**
* Thread that reads topology from Openflow controller and from XML if there are intradomain links
* @author jaume
*
*/
public class TEDUpdaterFloodlight extends TEDUpdaterController
{
public static String controllerName = "Floodlight";
private String topologyPathLinks = "/wm/topology/links/json";
private String topologyPathNodes = "/wm/core/controller/switches/json";
public TEDUpdaterFloodlight(String ip,String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super();
ips = new ArrayList<String>();
ports = new ArrayList<String>();
ips.add(ip);
ports.add(port);
this.TEDB = (SimpleTEDB)ted;
this.log = log;
}
public TEDUpdaterFloodlight(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log, Lock lock)
{
super( ip, port, topologyPathLinks, topologyPathNodes, ted, log, lock);
}
public TEDUpdaterFloodlight(ArrayList<String> ips, ArrayList<String>ports , String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super(ips, ports , topologyPathLinks, topologyPathNodes, ted, log);
}
@Override
public void run()
{
if(interDomainFile != null)
{
interDomainLinks = TEDUpdaterController.readInterDomainFile(interDomainFile);
}
String responseLinks = "";
String responseNodes = "";
try
{
//log.info("TopologyUpdaterWLAN thread, Updating TEDB");
Hashtable<String,RouterInfoPM> nodes = new Hashtable<String,RouterInfoPM>();
log.info("ips.size():"+ips.size());
for (int i = 0; i < ips.size(); i++)
{
responseNodes = queryForNodes(ips.get(i), ports.get(i));
parseNodes(responseNodes, nodes, ips.get(i), ports.get(i));
log.info("responseNodes:::"+responseNodes);
}
for (int i = 0; i < ips.size(); i++)
{
responseLinks = queryForLinks(ips.get(i), ports.get(i));
log.info("responseLinks:::"+responseLinks);
lock();
parseLinks(responseLinks, nodes);
unlock();
}
//parseJSON("[{\"src-switch\":\"00:14:2c:59:e5:5e:2b:00\",\"src-port\":20,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:64:21:00\",\"dst-port\":19,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:64:21:00\",\"src-port\":19,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:5e:2b:00\",\"dst-port\":20,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:66:ed:00\",\"src-port\":9,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:64:21:00\",\"dst-port\":20,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:64:21:00\",\"src-port\":20,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:66:ed:00\",\"dst-port\":9,\"dst-port-state\":0,\"type\":\"internal\"}]");
//System.out.println(response);
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{
try
{
JSONParser parser = new JSONParser();
Object obj = parser.parse(response);
JSONArray msg = (JSONArray) obj;
Iterator<JSONObject> iterator = msg.iterator();
while (iterator.hasNext())
{
JSONObject jsonObject = (JSONObject) iterator.next();
RouterInfoPM rInfo = new RouterInfoPM();
rInfo.setMacAddress((String)jsonObject.get("mac"));
rInfo.setRouterID((String)jsonObject.get("dpid"));
rInfo.setControllerType(TEDUpdaterFloodlight.controllerName);
JSONArray ports = (JSONArray) jsonObject.get("ports");
Iterator<JSONObject> portIterator = ports.iterator();
while (portIterator.hasNext())
{
JSONObject jsonPortObject = (JSONObject) portIterator.next();
rInfo.setMacAddress((String)jsonPortObject.get("hardwareAddress"));
}
log.info("(String)((JSONObject)jsonObject.get(description)).get(manufacturer)::"+(String)((JSONObject)jsonObject.get("description")).get("manufacturer"));
rInfo.setRouterType((String)((JSONObject)jsonObject.get("description")).get("manufacturer"));
rInfo.setConfigurationMode("Openflow");
rInfo.setControllerIdentifier(ip, port);
rInfo.setControllerIP(ip);
rInfo.setControllerPort(port);
rInfo.setHardware((String)((JSONObject)jsonObject.get("description")).get("hardware"));
routerInfoList.put(rInfo.getRouterID(),rInfo);
log.info("Adding Vertex::"+rInfo);
((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);
}
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void parseLinks(String links,Hashtable<String,RouterInfoPM> nodes)
{
try {
//log.info("Inside parseJSON");
JSONParser parser = new JSONParser();
Object obj = parser.parse(links);
JSONArray msg = (JSONArray) obj;
Iterator<JSONObject> iterator = msg.iterator();
while (iterator.hasNext())
{
JSONObject jsonObject = (JSONObject) iterator.next();
//System.out.println(jsonObject.get("src-switch"));
IntraDomainEdge edge= new IntraDomainEdge();
RouterInfoPM source = nodes.get(jsonObject.get("src-switch"));
RouterInfoPM dest = nodes.get(jsonObject.get("dst-switch"));
//((SimpleTEDB)TEDB).getNetworkGraph().addVertex(source);
//((SimpleTEDB)TEDB).getNetworkGraph().addVertex(dest);
log.info("Adding Vertex->"+source+" hashcode:"+source.hashCode());
log.info("Adding Vertex->"+dest+" hashcode:"+dest.hashCode());
edge.setSrc_if_id((Long)jsonObject.get("src-port"));
edge.setDst_if_id((Long)jsonObject.get("dst-port"));
// This is a big problem because info is not initialized from file
// and the controller doesn't give information about how many wlans
// the are
TE_Information tE_info = new TE_Information();
tE_info.setNumberWLANs(15);
tE_info.initWLANs();
if (interDomainFile != null)
{
completeTE_Information(tE_info, source.getRouterID(), dest.getRouterID());
}
edge.setTE_info(tE_info);
String isBidirectional = (String)jsonObject.get("direction");
//log.info("isBidirectional::"+isBidirectional);
if ((1==1)||(isBidirectional != null) && (isBidirectional.equals("bidirectional")))
{
//((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
TE_Information tE_infoOtherWay = new TE_Information();
tE_infoOtherWay.setNumberWLANs(15);
tE_infoOtherWay.initWLANs();
IntraDomainEdge edgeOtherWay= new IntraDomainEdge();
edgeOtherWay.setSrc_if_id((Long)jsonObject.get("dst-port"));
edgeOtherWay.setDst_if_id((Long)jsonObject.get("src-port"));
edgeOtherWay.setTE_info(tE_infoOtherWay);
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(dest, source, edgeOtherWay);
completeTE_Information(tE_info, dest.getRouterID(), source.getRouterID());
log.info("source::"+source);
log.info("dest::"+dest);
log.info("edgeOtherWay::"+edgeOtherWay);
log.info("edge::"+edge);
//log.info("Adding two!");
}
else
{
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
}
//log.info("Edge added:"+edge);
//log.info(((SimpleTEDB)TEDB).getIntraDomainLinks().toString());
}
//parseRemainingLinksFromXML(nodes);
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void completeTE_Information(TE_Information tE_info, String source, String dest)
{
MyEdge auxEdge = new MyEdge(source, dest);
MyEdge completEdge = interDomainLinks.get(auxEdge.hashCode());
if ((completEdge != null)&&(completEdge.vlan != null))
{
tE_info.setVlanLink(true);
tE_info.setVlan(completEdge.vlan);
//If it has been found it will be removed so the rest can be proccessed later
interDomainLinks.remove(completEdge.vlan);
}
else
{
tE_info.setVlanLink(false);
}
}
private String queryForLinks(String ip, String port)
{
String response = "";
try
{
URL topoplogyURL = new URL("http://"+ip+":"+port+topologyPathLinks);
//log.info("URL::"+"http://"+ip+":"+port+topologyPathLinks);
URLConnection yc = topoplogyURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
response = response + inputLine;
}
}
catch (Exception e)
{
log.info(e.toString());
}
return response;
}
private String queryForNodes(String ip, String port)
{
String response = "";
try
{
URL topoplogyURL = new URL("http://"+ip+":"+port+topologyPathNodes);
log.info("http://+port+topologyPathNodes:::"+"http://"+ip+":"+port+topologyPathNodes);
URLConnection yc = topoplogyURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
response = response + inputLine;
}
in.close();
}
catch (Exception e)
{
log.info(e.toString());
}
return response;
}
private void lock()
{
if (lock != null)
{
lock.lock();
}
}
private void unlock()
{
if (lock != null)
{
lock.unlock();
}
}
private String getCharacterDataFromElement(Element e) {
Node child = e.getFirstChild();
if (child instanceof CharacterData) {
CharacterData cd = (CharacterData) child;
return cd.getData();
} else {
return "?";
}
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb.controllers;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.teraflow.tid.tedb.DomainTEDB;
import eu.teraflow.tid.tedb.IntraDomainEdge;
import eu.teraflow.tid.tedb.SimpleTEDB;
import eu.teraflow.tid.tedb.TE_Information;
import eu.teraflow.tid.tedb.elements.RouterInfoPM;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
public class TEDUpdaterNOX extends TEDUpdaterController
{
public static String controllerName = "NOX";
private Hashtable<Integer,MyEdge> interDomainLinks = new Hashtable<Integer,MyEdge>();
//Overwritten father variables and fixing the topology urls in code
private String topologyPathNodes = "/get_vtopology/";
private String topologyPathLinks = "/get_graph/";//??
public TEDUpdaterNOX(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super( ip, port, topologyPathLinks, topologyPathNodes, ted, log);
}
public TEDUpdaterNOX(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log, Lock lock)
{
super( ip, port, topologyPathLinks, topologyPathNodes, ted, log, lock);
}
public TEDUpdaterNOX(ArrayList<String> ips, ArrayList<String>ports , String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super(ips, ports , topologyPathLinks, topologyPathNodes, ted, log);
}
@Override
public void run()
{
if(interDomainFile != null)
{
interDomainLinks = TEDUpdaterController.readInterDomainFile(interDomainFile);
}
String responseLinks = "";
String responseNodes = "";
try
{
Hashtable<String,RouterInfoPM> nodes = new Hashtable<String,RouterInfoPM>();
for (int i = 0; i < ips.size(); i++)
{
responseNodes = queryForNodes(ips.get(i), ports.get(i));//query for topology
parseNodes(responseNodes, nodes, ips.get(i), ports.get(i));
log.info("responseNodes:::"+responseNodes);
}
}
catch (Exception e)
{
log.info(e.toString());
}
}
private String BristoltoFloodlight(String BristolFormat)
{
String floodFormat = new String(BristolFormat);
//Por algo se me conoce como el hacker
for (int i = 2; i < floodFormat.length(); i += 3)
{
floodFormat = floodFormat.substring(0, i) + ":" + floodFormat.substring(i, floodFormat.length());
}
log.info("BristolFormat--> " + BristolFormat + ", floodFormat-->" + floodFormat);
return floodFormat;
}
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{
try
{
JSONParser parser = new JSONParser();
Object obj = parser.parse(response);
JSONObject jsonaux=(JSONObject) obj;
Iterator<String> iterkeys=jsonaux.keySet().iterator();
Hashtable<String,RouterInfoPM> nodes= new Hashtable<String,RouterInfoPM>();
while (iterkeys.hasNext()) {
String dpid = iterkeys.next();
System.out.println("Key: "+dpid.replace("-", ":"));
RouterInfoPM rInfo = new RouterInfoPM();
rInfo.setRouterID(dpid.replace("-", ":"));//Bristol to floodlight?
rInfo.setConfigurationMode("Openflow");
rInfo.setControllerType(TEDUpdaterNOX.controllerName);
rInfo.setControllerIdentifier(ip, port);
rInfo.setControllerIP(ip);
rInfo.setControllerPort(port);
routerInfoList.put(rInfo.getRouterID(),rInfo);
nodes.put(dpid.replace("-", ":"),rInfo);
((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);
}
//Getting Links
Iterator<String> nodeiter=nodes.keySet().iterator();
while (nodeiter.hasNext()){
String node= nodeiter.next();
parseLinks(node, (String)jsonaux.get(node.replace(":", "-")).toString(), nodes);
}
//parseLinks(dpid, jsonarray)
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void parseLinks(String dpid,String links, Hashtable<String,RouterInfoPM> nodes)
{
try {
//log.info("Inside parseJSON");
JSONParser parser = new JSONParser();
Object obj = parser.parse(links);
JSONArray msg = (JSONArray) obj;
Iterator<JSONObject> iterator = msg.iterator();
while (iterator.hasNext())
{
JSONObject jsonObject = (JSONObject) iterator.next();
//System.out.println(jsonObject.get("src-switch"));
IntraDomainEdge edge= new IntraDomainEdge();
String labels = (String) jsonObject.get("labels");//??
String destnode = ((String) jsonObject.get("peer_node")).replace("-", ":");
String type = (String) jsonObject.get("port_type");
RouterInfoPM source = nodes.get(dpid);
RouterInfoPM dest = nodes.get(destnode);
//((SimpleTEDB)TEDB).getNetworkGraph().addVertex(source);
//((SimpleTEDB)TEDB).getNetworkGraph().addVertex(dest);
System.out.println("Srcnode: "+dpid);
System.out.println("Dstnode: "+destnode);
System.out.println("Srcport: "+jsonObject.get("port_id"));
System.out.println("Dstport: "+jsonObject.get("peer_port"));
if ((dest!= null)&&(source!=null)){
edge.setSrc_if_id(Long.parseLong((String)jsonObject.get("port_id")));
edge.setDst_if_id(Long.parseLong((String)jsonObject.get("peer_port")));
edge.setType(type);
// This is a big problem because info is not initialized from file
// and the controller doesn't give information about how many wlans
// the are
TE_Information tE_info = new TE_Information();
System.out.println("Labels: Original ("+labels+") and Parsed ("+labels.substring(labels.indexOf(",")+1,labels.indexOf("]"))+")");
tE_info.setNumberWLANs(Integer.parseInt(labels.substring(labels.indexOf(",")+1,labels.indexOf("]"))));
tE_info.initWLANs();
if (interDomainFile != null)
{
completeTE_Information(tE_info, source.getRouterID(), dest.getRouterID());
}
edge.setTE_info(tE_info);
edge.setDirectional(true);
//Bidirectional case? See other TEDUpdaters.
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
} else {
System.out.println("Link with an unknown node. Ingnoring...");
}
//log.info("Edge added:"+edge);
//log.info(((SimpleTEDB)TEDB).getIntraDomainLinks().toString());
}
//parseRemainingLinksFromXML(nodes);
}
catch (Exception e)
{
log.info(e.toString());
}
}
// private void parseLinks(String links,Hashtable<String,RouterInfoPM> nodes)
// {
// try {
// //log.info("Inside parseJSON");
// JSONParser parser = new JSONParser();
// Object obj = parser.parse(links);
//
// JSONArray msg = (JSONArray) obj;
// Iterator<JSONObject> iterator = msg.iterator();
// while (iterator.hasNext())
// {
// JSONObject jsonObject = (JSONObject) iterator.next();
// //System.out.println(jsonObject.get("src-switch"));
// IntraDomainEdge edge= new IntraDomainEdge();
//
// JSONObject jsonObject_src = (JSONObject) jsonObject.get("src");
// JSONObject jsonObject_dst = (JSONObject) jsonObject.get("dst");
//
// RouterInfoPM source = nodes.get(BristoltoFloodlight((String)jsonObject_src.get("dpid")));
// RouterInfoPM dest = nodes.get(BristoltoFloodlight((String)jsonObject_dst.get("dpid")));
//
// //((SimpleTEDB)TEDB).getNetworkGraph().addVertex(source);
// //((SimpleTEDB)TEDB).getNetworkGraph().addVertex(dest);
//
// log.info("Adding Vertex->"+source+" hashcode:"+source.hashCode());
// log.info("Adding Vertex->"+dest+" hashcode:"+dest.hashCode());
//
// edge.setSrc_if_id((Long)jsonObject_src.get("port_no"));
// edge.setDst_if_id((Long)jsonObject_dst.get("port_no"));
//
//
// // This is a big problem because info is not initialized from file
// // and the controller doesn't give information about how many wlans
// // the are
//
// TE_Information tE_info = new TE_Information();
// tE_info.setNumberWLANs(15);
// tE_info.initWLANs();
//
// if (interDomainFile != null)
// {
// completeTE_Information(tE_info, source.getRouterID(), dest.getRouterID());
// }
//
// edge.setTE_info(tE_info);
//
// String isBidirectional = (String)jsonObject.get("direction");
//
//
// // En Bristol los enlaces son unidirecctionales, pero asumimos que hay uno en una direccion
// // esta el otro
// isBidirectional = "bidirectional";
//
// //log.info("isBidirectional::"+isBidirectional);
//
// if ((1==1)||(isBidirectional != null) && (isBidirectional.equals("bidirectional")))
// {
// //((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
//
// TE_Information tE_infoOtherWay = new TE_Information();
// tE_infoOtherWay.setNumberWLANs(15);
// tE_infoOtherWay.initWLANs();
// IntraDomainEdge edgeOtherWay= new IntraDomainEdge();
//
// edgeOtherWay.setSrc_if_id((Long)jsonObject_src.get("port_no"));
// edgeOtherWay.setDst_if_id((Long)jsonObject_dst.get("port_no"));
// edgeOtherWay.setTE_info(tE_infoOtherWay);
//
// ((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
// ((SimpleTEDB)TEDB).getNetworkGraph().addEdge(dest, source, edgeOtherWay);
//
// completeTE_Information(tE_info, dest.getRouterID(), source.getRouterID());
//
// log.info("source::"+source);
// log.info("dest::"+dest);
// log.info("edgeOtherWay::"+edgeOtherWay);
// log.info("edge::"+edge);
// //log.info("Adding two!");
// }
// else
// {
// ((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
// }
//
// //log.info("Edge added:"+edge);
// //log.info(((SimpleTEDB)TEDB).getIntraDomainLinks().toString());
// }
// //parseRemainingLinksFromXML(nodes);
//
//
// }
// catch (Exception e)
// {
// log.info(UtilsFunctions.exceptionToString(e));
// }
// }
private void completeTE_Information(TE_Information tE_info, String source, String dest)
{
MyEdge auxEdge = new MyEdge(source, dest);
MyEdge completEdge = interDomainLinks.get(auxEdge.hashCode());
if ((completEdge != null)&&(completEdge.vlan != null))
{
tE_info.setVlanLink(true);
tE_info.setVlan(completEdge.vlan);
//If it has been found it will be removed so the rest can be proccessed later
interDomainLinks.remove(completEdge.vlan);
}
else
{
tE_info.setVlanLink(false);
}
}
private String queryForLinks(String ip, String port)
{
String response = "";
try
{
URL topoplogyURL = new URL("http://"+ip+":"+port+topologyPathLinks);
log.info("URL::"+"http://"+ip+":"+port+topologyPathLinks);
URLConnection yc = topoplogyURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
response = response + inputLine;
}
}
catch (Exception e)
{
log.info(e.toString());
}
return response;
}
private String queryForNodes(String ip, String port)
{
String response = "";
try
{
URL topoplogyURL = new URL("http://"+ip+":"+port+topologyPathNodes);
log.info("http://+port+topologyPathNodes:::"+"http://"+ip+":"+port+topologyPathNodes);
URLConnection yc = topoplogyURL.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
response = response + inputLine;
}
in.close();
}
catch (Exception e)
{
log.info(e.toString());
}
return response;
}
public String getInterDomainFile()
{
return interDomainFile;
}
public void setInterDomainFile(String interDomainFile)
{
this.interDomainFile = interDomainFile;
}
private void lock()
{
if (lock != null)
{
lock.lock();
}
}
private void unlock()
{
if (lock != null)
{
lock.unlock();
}
}
}
// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package eu.teraflow.tid.tedb.controllers;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import eu.teraflow.tid.tedb.DomainTEDB;
import eu.teraflow.tid.tedb.IntraDomainEdge;
import eu.teraflow.tid.tedb.SimpleTEDB;
import eu.teraflow.tid.tedb.TE_Information;
import eu.teraflow.tid.tedb.elements.RouterInfoPM;
/**
* Thread that reads topology from Openflow controller and from XML if there are intradomain links
* @author jaume
*
*/
public class TEDUpdaterODL extends TEDUpdaterController
{
public static String controllerName = "ODL";
private String topologyPathLinks = "/controller/nb/v2/topology/default";
private String topologyPathNodes = "/controller/nb/v2/switchmanager/default/nodes";
public TEDUpdaterODL(String ip,String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super();
ips = new ArrayList<String>();
ports = new ArrayList<String>();
ips.add(ip);
ports.add(port);
this.TEDB = (SimpleTEDB)ted;
this.log = log;
}
public TEDUpdaterODL(String ip, String port, String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log, Lock lock)
{
super( ip, port, topologyPathLinks, topologyPathNodes, ted, log, lock);
}
public TEDUpdaterODL(ArrayList<String> ips, ArrayList<String>ports , String topologyPathLinks, String topologyPathNodes,DomainTEDB ted, Logger log)
{
super(ips, ports , topologyPathLinks, topologyPathNodes, ted, log);
}
@Override
public void run()
{
if(interDomainFile != null)
{
interDomainLinks = TEDUpdaterController.readInterDomainFile(interDomainFile);
}
String responseLinks = "";
String responseNodes = "";
try
{
Hashtable<String,RouterInfoPM> nodes = new Hashtable<String,RouterInfoPM>();
log.info("ips.size():"+ips.size());
log.info("ODL updates_______________________________________________________START____");
for (int i = 0; i < ips.size(); i++)
{
responseNodes = queryForNodes(ips.get(i), ports.get(i));
parseNodes(responseNodes, nodes, ips.get(i), ports.get(i));
}
for (int i = 0; i < ips.size(); i++)
{
responseLinks = queryForLinks(ips.get(i), ports.get(i));
lock();
parseLinks(responseLinks, nodes);
unlock();
}
log.info("ODL updates_______________________________________________________END____");
//parseJSON("[{\"src-switch\":\"00:14:2c:59:e5:5e:2b:00\",\"src-port\":20,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:64:21:00\",\"dst-port\":19,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:64:21:00\",\"src-port\":19,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:5e:2b:00\",\"dst-port\":20,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:66:ed:00\",\"src-port\":9,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:64:21:00\",\"dst-port\":20,\"dst-port-state\":0,\"type\":\"internal\"},{\"src-switch\":\"00:14:2c:59:e5:64:21:00\",\"src-port\":20,\"src-port-state\":0,\"dst-switch\":\"00:14:2c:59:e5:66:ed:00\",\"dst-port\":9,\"dst-port-state\":0,\"type\":\"internal\"}]");
//System.out.println(response);
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{
try
{
JSONParser parser = new JSONParser();
Object obj = parser.parse(response);
JSONArray msg = (JSONArray) ((JSONObject) obj).get("nodeProperties");
Iterator<JSONObject> iterator = msg.iterator();
while (iterator.hasNext())
{
JSONObject jsonObject = iterator.next();
RouterInfoPM rInfo = new RouterInfoPM();
String dpid = (String) (((JSONObject) jsonObject.get("node")).get("id"));
rInfo.setRouterID(dpid);
rInfo.setConfigurationMode("Openflow");
rInfo.setControllerType(TEDUpdaterODL.controllerName);
rInfo.setControllerIdentifier(ip, port);
rInfo.setControllerIP(ip);
rInfo.setControllerPort(port);
routerInfoList.put(rInfo.getRouterID(),rInfo);
log.info("Adding Vertex::"+rInfo);
((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);
}
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void parseLinks(String links,Hashtable<String,RouterInfoPM> nodes)
{
try {
JSONParser parser = new JSONParser();
Object obj = parser.parse(links);
JSONArray msg = (JSONArray) ((JSONObject) obj).get("edgeProperties");
Iterator<JSONObject> iterator = msg.iterator();
while (iterator.hasNext())
{
JSONObject jsonObject = (JSONObject) iterator.next().get("edge");
JSONObject jSrc = (JSONObject) jsonObject.get("headNodeConnector");
JSONObject jDst = (JSONObject) jsonObject.get("tailNodeConnector");
IntraDomainEdge edge= new IntraDomainEdge();
RouterInfoPM source = nodes.get(((JSONObject) jSrc.get("node")).get("id"));// jsonObject.get("src-switch"));
RouterInfoPM dest = nodes.get(((JSONObject) jDst.get("node")).get("id"));// jsonObject.get("dst-switch"));
edge.setSrc_if_id(Long.parseLong((String)jSrc.get("id"))); //jsonObject.get("src-port"));
edge.setDst_if_id(Long.parseLong((String)jDst.get("id"))); //jsonObject.get("dst-port"));
// This is a big problem because info is not initialized from file
// and the controller doesn't give information about how many wlans
// the are
TE_Information tE_info = new TE_Information();
tE_info.setNumberWLANs(15);
tE_info.initWLANs();
if (interDomainFile != null)
{
completeTE_Information(tE_info, source.getRouterID(), dest.getRouterID());
}
edge.setTE_info(tE_info);
String isBidirectional = (String)jsonObject.get("direction");
//log.info("isBidirectional::"+isBidirectional);
if ((1==1)||(isBidirectional != null) && (isBidirectional.equals("bidirectional")))
{
//((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
TE_Information tE_infoOtherWay = new TE_Information();
tE_infoOtherWay.setNumberWLANs(15);
tE_infoOtherWay.initWLANs();
IntraDomainEdge edgeOtherWay= new IntraDomainEdge();
edgeOtherWay.setSrc_if_id(Long.parseLong((String)jDst.get("id")));
edgeOtherWay.setDst_if_id(Long.parseLong((String)jSrc.get("id")));
edgeOtherWay.setTE_info(tE_infoOtherWay);
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(dest, source, edgeOtherWay);
completeTE_Information(tE_info, dest.getRouterID(), source.getRouterID());
log.info("________EDGE_____");
log.info("source::"+source);
log.info("dest::"+dest);
log.info("edgeOtherWay::"+edgeOtherWay);
log.info("edge::"+edge);
log.info("--------EDGE-----");
}
else
{
((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
}
//log.info("Edge added:"+edge);
//log.info(((SimpleTEDB)TEDB).getIntraDomainLinks().toString());
}
//parseRemainingLinksFromXML(nodes);
}
catch (Exception e)
{
log.info(e.toString());
}
}
private void completeTE_Information(TE_Information tE_info, String source, String dest)
{
MyEdge auxEdge = new MyEdge(source, dest);
MyEdge completEdge = interDomainLinks.get(auxEdge.hashCode());
if ((completEdge != null)&&(completEdge.vlan != null))
{
tE_info.setVlanLink(true);
tE_info.setVlan(completEdge.vlan);
//If it has been found it will be removed so the rest can be proccessed later
interDomainLinks.remove(completEdge.vlan);
}
else
{
tE_info.setVlanLink(false);
}
}
private String queryForLinks(String ip, String port)
{
return query("http://"+ip+":"+port+topologyPathLinks);
}
private String queryForNodes(String ip, String port)
{
return query("http://"+ip+":"+port+topologyPathNodes);
}
private String query(String url)
{
log.info("Attempting to curl: "+url);
String response = "";
try
{
String credentials = "admin:admin";
String credentialsEncoded = "YWRtaW46YWRtaW4=";
URL topoplogyURL = new URL(url);
URLConnection yc = topoplogyURL.openConnection();
HttpURLConnection httpcon = (HttpURLConnection) yc;
httpcon.setDoOutput(true);
httpcon.setRequestProperty("Content-Type", "application/json");
httpcon.setRequestProperty("Authorization", "Basic "+credentialsEncoded);
BufferedReader in = new BufferedReader(
new InputStreamReader(
httpcon.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
response = response + inputLine;
}
in.close();
return response;
}
catch (Exception e)
{
log.info(e.toString());
}
return "";
}
private void lock()
{
if (lock != null)
{
lock.lock();
}
}
private void unlock()
{
if (lock != null)
{
lock.unlock();
}
}
private String getCharacterDataFromElement(Element e) {
Node child = e.getFirstChild();
if (child instanceof CharacterData) {
CharacterData cd = (CharacterData) child;
return cd.getData();
} else {
return "?";
}
}
}