├── .gitignore ├── .project ├── .travis.yml ├── CHANGELOG ├── LICENSE ├── README.md ├── VERSION ├── pom.xml └── src └── main ├── java └── es │ └── tid │ ├── emulator │ ├── node │ │ ├── FastPCEPSession.java │ │ ├── FastPCEPSessionServer.java │ │ ├── NetworkNode.java │ │ ├── NodeInformation.java │ │ ├── NodeLauncher.java │ │ ├── RemoteLSPInitPCEPSession.java │ │ ├── RemoteLSPInitPCEPSessionServer.java │ │ ├── management │ │ │ ├── NodeManagementSession.java │ │ │ └── NodeManagementSever.java │ │ ├── resources │ │ │ ├── Resource.java │ │ │ ├── ResourceManager.java │ │ │ ├── mpls │ │ │ │ └── MPLSResourceManager.java │ │ │ ├── sson │ │ │ │ └── SSONResourceManager.java │ │ │ └── wson │ │ │ │ └── WSONResourceManager.java │ │ ├── tedb │ │ │ └── SimpleLocalTEDB.java │ │ ├── topology │ │ │ ├── Handler.java │ │ │ ├── HandlerTestMain.java │ │ │ └── ParametersPrueba.java │ │ └── transport │ │ │ ├── EmulatedPCCPCEPSession.java │ │ │ ├── Errors.java │ │ │ ├── ForwardingTable.java │ │ │ ├── Interfaz.java │ │ │ ├── LSPCreationException.java │ │ │ ├── LSPReservationException.java │ │ │ ├── PathComputationClient.java │ │ │ ├── RequestedLSPinformation.java │ │ │ ├── RequestedLSPinformationMPLS.java │ │ │ ├── RequestedLSPinformationSSON.java │ │ │ ├── RequestedLSPinformationWSON.java │ │ │ ├── defineLocalTEDB.java │ │ │ ├── lsp │ │ │ ├── LSP.java │ │ │ ├── LSPCreationErrorTypes.java │ │ │ ├── LSPKey.java │ │ │ ├── LSPManager.java │ │ │ ├── LSPParameters.java │ │ │ ├── Node_State_Parameters.java │ │ │ ├── NotifyLSP.java │ │ │ ├── PathState.java │ │ │ └── te │ │ │ │ ├── LSPTE.java │ │ │ │ ├── PathStateParameters.java │ │ │ │ ├── TEPathState.java │ │ │ │ └── TechnologyParameters.java │ │ │ ├── ospf │ │ │ ├── OSPFController.java │ │ │ ├── OSPFSendAllTopology.java │ │ │ ├── OSPFSenderManager.java │ │ │ └── OSPFSenderThread.java │ │ │ └── rsvp │ │ │ ├── RSVPListener.java │ │ │ ├── RSVPManager.java │ │ │ ├── RSVPProcessor.java │ │ │ ├── RSVPSender.java │ │ │ └── RSVPSession.java │ └── pccPrueba │ │ ├── ClientRequestManagerPrueba.java │ │ ├── RemoteAutomaticPCC.java │ │ ├── RemoteAutomaticPCCLauncher.java │ │ ├── RemoteLSPInitPCEPSession.java │ │ └── RemoteLSPInitPCEPSessionServer.java │ ├── ipnms │ ├── datamodel │ │ ├── misc │ │ │ ├── Address.java │ │ │ ├── AuthInfo.java │ │ │ ├── IPAddressUtils.java │ │ │ └── package-info.java │ │ ├── router │ │ │ ├── GRETunnel │ │ │ │ └── GRETunnelDesc.java │ │ │ ├── IPinterface │ │ │ │ ├── IPInterfaceConfig.java │ │ │ │ └── IPInterfaceDesc.java │ │ │ ├── LabelSwitchedPath │ │ │ │ ├── LabelSwitchedPath.java │ │ │ │ ├── LabelSwitchedPathProperties.java │ │ │ │ └── LabelSwitchedPathWithUnnumIf.java │ │ │ ├── RouterDesc.java │ │ │ └── routing │ │ │ │ ├── StaticRouteDesc.java │ │ │ │ ├── acl │ │ │ │ ├── ACLDesc.java │ │ │ │ └── ForwardingRuleDesc.java │ │ │ │ └── routingprotocol │ │ │ │ └── RProtocolDesc.java │ │ └── utils │ │ │ └── IPSubnetUtils.java │ └── wsimpl │ │ ├── IPnmsWs.java │ │ └── impl │ │ ├── IPnmsALUCliImpl.java │ │ ├── IPnmsCiscoCliImpl.java │ │ ├── IPnmsJuniperCliImpl.java │ │ ├── IdaTelnetClientPrueba.java │ │ ├── JuniperNetconfImpl.java │ │ └── JuniperOFImpl.java │ ├── netManager │ ├── NetworkLSPManager.java │ ├── NetworkLSPManagerParameters.java │ ├── NetworkLSPManagerTypes.java │ ├── OSPFSender.java │ ├── TCPOSPFSender.java │ ├── emulated │ │ ├── AdvancedEmulatedNetworkLSPManager.java │ │ ├── CompletedEmulatedNetworkLSPManager.java │ │ ├── DummyEmulatedNetworkLSPManager.java │ │ ├── EmulatedUniNetworkLSPManager.java │ │ ├── LayerTypes.java │ │ └── SimpleEmulatedNetworkLSPManager.java │ └── uni │ │ ├── ChangeIPRoute.java │ │ ├── CreateLSP.java │ │ ├── DeleteLSP.java │ │ ├── DispatcherObjects.java │ │ ├── NoIPNMSDispatcher.java │ │ └── UniNetworkLSPManager.java │ ├── pce │ └── client │ │ ├── emulator │ │ ├── AutomaticTesterStatistics.java │ │ ├── Emulator.java │ │ ├── PrintStatistics.java │ │ └── TestClient_NetEmulated.java │ │ ├── management │ │ ├── AutomaticTesterManagementSession.java │ │ ├── AutomaticTesterManagementSever.java │ │ └── StopManagement.java │ │ ├── multiDomain │ │ ├── AutomaticTesterSpainNetwork.java │ │ ├── AutomaticTesterSpainNetworkTask.java │ │ └── CreateSpainNetwork.java │ │ ├── multiLayer │ │ ├── AutomaticExponentialTesterMLNetworkTask.java │ │ ├── AutomaticTesterMLNetwork.java │ │ ├── AutomaticTesterMLNetworkRandomTask.java │ │ ├── AutomaticTesterMLNetworkTask.java │ │ └── RealiseMLCapacityTask.java │ │ └── tester │ │ ├── Activity.java │ │ ├── AutomaticClient.java │ │ ├── AutomaticClientTask.java │ │ ├── AutomaticTesterNetworkTask.java │ │ ├── ClientSendTopology.java │ │ ├── ClientSendTopologyConfiguration.java │ │ ├── DummyActivity.java │ │ ├── InformationRequest.java │ │ ├── LSPConfirmationDispatcher.java │ │ ├── LSPConfirmationProcessorThread.java │ │ ├── NetworkEmulatorActivity.java │ │ ├── PCCPCEPSessionParameters.java │ │ ├── RealiseCapacityTask.java │ │ ├── RealiseControlPlaneCapacityTask.java │ │ ├── RealiseMLCapacityTask.java │ │ ├── RequestParametersConfiguration.java │ │ ├── RequestToSend.java │ │ ├── SendTopologyClientTask.java │ │ ├── StatefulPCEPSession.java │ │ ├── StatefulSession.java │ │ ├── VNTMActivity.java │ │ ├── restoration │ │ ├── DisconnectingLinkTask.java │ │ ├── RestorationCaseClient.java │ │ ├── RestorationCaseInformation.java │ │ ├── RestorationCaseParameters.java │ │ ├── RestorationCaseStatistics.java │ │ ├── RestorationCaseTable.java │ │ └── SendRequestRestorationCase.java │ │ └── singleClient.java │ ├── provisioningManager │ └── objects │ │ └── openflow │ │ ├── PushFlowController.java │ │ ├── PushFlowFloodlight.java │ │ ├── PushFlowODL.java │ │ ├── PushFlowRYU.java │ │ └── StaticFlow.java │ ├── test │ ├── InterfaceDisable.java │ ├── PCEClient.java │ ├── ReactivateInterface.java │ ├── RestartInterfaces.java │ └── TestRawSocket.java │ └── vntm │ ├── LSP.java │ ├── LSPManager.java │ ├── LigthPathCreateIP.java │ ├── LigthPathManagement.java │ ├── OpTable.java │ ├── VNTMParameters.java │ ├── VNTMServer.java │ ├── VNTMSession.java │ ├── client │ ├── VNTMClient.java │ └── VNTMClientSession.java │ ├── emulator │ ├── OSPFSender.java │ └── TCPOSPFSender.java │ ├── management │ ├── VNTMManagementSession.java │ └── VNTMManagementSever.java │ └── topology │ ├── VNTMGraph.java │ ├── elements │ ├── Bandwidth.java │ ├── BgpParams.java │ ├── EndPoint.java │ ├── IPNodeParams.java │ ├── Intf.java │ ├── IsisParams.java │ ├── Link.java │ ├── Location.java │ ├── Node.java │ ├── OspfParams.java │ ├── Path.java │ ├── PhyLinkParams.java │ ├── Service.java │ └── StaticRoutingParams.java │ └── interlayerTopology.xml └── sample-config-files ├── defaultConfiguration.properties ├── example1_Triangle_SSON ├── Node1 │ ├── defaultConfiguration.properties │ ├── killRoadm.sh │ ├── log4j2.xml │ ├── roadm.sh │ └── topologia.xml ├── Node2 │ ├── defaultConfiguration.properties │ ├── log4j2.xml │ ├── roadm.sh │ └── topologia.xml ├── Node3 │ ├── defaultConfiguration.properties │ ├── log4j2.xml │ ├── roadm.sh │ └── topologia.xml └── PCE │ ├── PCEServerConfiguration_SSON.xml │ └── log4j2.xml ├── log4j2.xml └── topologia-1.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories # 2 | /build/ 3 | /bin/ 4 | target/ 5 | 6 | *.class 7 | 8 | # Package Files # 9 | *.jar 10 | *.war 11 | *.ear 12 | *.db 13 | *.log 14 | *.log.* 15 | 16 | ###################### 17 | # Windows 18 | ###################### 19 | # Windows image file caches 20 | Thumbs.db 21 | # Folder config file 22 | Desktop.ini 23 | 24 | ###################### 25 | # OSX 26 | ###################### 27 | .DS_Store 28 | .svn 29 | 30 | # Thumbnails 31 | ._* 32 | # Files that might appear on external disk 33 | .Spotlight-V100 34 | .Trashes 35 | 36 | ###################### 37 | # Eclipse 38 | ###################### 39 | *.pydevproject 40 | .project 41 | .metadata 42 | bin/** 43 | tmp/** 44 | tmp/**/* 45 | *.tmp 46 | *.bak 47 | *.swp 48 | *~.nib 49 | local.properties 50 | .classpath 51 | .settings/ 52 | .loadpath 53 | /src/main/resources/rebel.xml 54 | # External tool builders 55 | .externalToolBuilders/ 56 | # Locally stored "Eclipse launch configurations" 57 | *.launch 58 | # CDT-specific 59 | .cproject 60 | # PDT-specific 61 | .buildpath 62 | 63 | 64 | 65 | # Created by https://www.gitignore.io/api/intellij,intellij+iml 66 | 67 | ### Intellij ### 68 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 69 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 70 | 71 | # User-specific stuff: 72 | .idea/workspace.xml 73 | .idea/tasks.xml 74 | 75 | # Sensitive or high-churn files: 76 | .idea/dataSources/ 77 | .idea/dataSources.ids 78 | .idea/dataSources.xml 79 | .idea/dataSources.local.xml 80 | .idea/sqlDataSources.xml 81 | .idea/dynamic.xml 82 | .idea/uiDesigner.xml 83 | 84 | # Gradle: 85 | .idea/gradle.xml 86 | .idea/libraries 87 | 88 | # Mongo Explorer plugin: 89 | .idea/mongoSettings.xml 90 | 91 | ## File-based project format: 92 | *.iws 93 | 94 | ## Plugin-specific files: 95 | 96 | # IntelliJ 97 | /out/ 98 | 99 | # mpeltonen/sbt-idea plugin 100 | .idea_modules/ 101 | 102 | # JIRA plugin 103 | atlassian-ide-plugin.xml 104 | 105 | # Crashlytics plugin (for Android Studio and IntelliJ) 106 | com_crashlytics_export_strings.xml 107 | crashlytics.properties 108 | crashlytics-build.properties 109 | fabric.properties 110 | 111 | ### Intellij Patch ### 112 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 113 | 114 | # *.iml 115 | # modules.xml 116 | # .idea/misc.xml 117 | # *.ipr 118 | 119 | 120 | ### Intellij+iml ### 121 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 122 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 123 | 124 | # User-specific stuff: 125 | 126 | # Sensitive or high-churn files: 127 | 128 | # Gradle: 129 | 130 | # Mongo Explorer plugin: 131 | 132 | ## File-based project format: 133 | 134 | ## Plugin-specific files: 135 | 136 | # IntelliJ 137 | 138 | # mpeltonen/sbt-idea plugin 139 | 140 | # JIRA plugin 141 | 142 | # Crashlytics plugin (for Android Studio and IntelliJ) 143 | 144 | ### Intellij+iml Patch ### 145 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 146 | 147 | *.iml 148 | modules.xml 149 | .idea/misc.xml 150 | *.ipr 151 | .idea/markdown-navigator/profiles_settings.xml 152 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cne-emulator 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | org.eclipse.wst.common.project.facet.core.nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | - oraclejdk8 5 | script: 6 | - mvn install -X -f ./pom.xml 7 | - mvn org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar 8 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | v1.3.3 2 | - Uploaded to Maven Central 3 | - Example of use added. 4 | - Profile to buid autojar for Transport Node Emulator added 5 | - Updated to work with netphony-network-protocols, netphony-topology and netphony PCE 1.3.3 6 | - License in now Apache 2.0 7 | v1.3.2 8 | - Updated to work with netphony-network-protocols, netphony-topology and netphony PCE 1.3.2 9 | - Added maven profiles 10 | - Updated reference to es.tid.rocksaw library 11 | - Moved all to es.tid package 12 | v1.2 13 | - Fixed maven support 14 | - Works with network protocols 1.2.1 and netphony-topology 1.2.1 15 | v1.1.1 16 | - Added maven support and adaptation to other netphony libraries 17 | v1.0.0 18 | - Initial version 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | netphony-gmpls-emulator v1.3.3 2 | =================== 3 | Repository branch build status: 4 | 5 | | **Master** | **Develop** | 6 | |:---:|:---:| 7 | | [![Build Status](https://travis-ci.org/telefonicaid/netphony-gmpls-emulator.svg?branch=master)](https://travis-ci.org/telefonicaid/netphony-gmpls-emulator) | [![Build Status](https://travis-ci.org/telefonicaid/netphony-gmpls-emulator.svg?branch=develop)](https://travis-ci.org/telefonicaid/netphony-gmpls-emulator) | 8 | 9 | Latest Maven Central Release: 10 | 11 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/es.tid.netphony/network-emulator/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/es.tid.netphony/network-emulator/) 12 | 13 | This software is a Java Based emulator of a Transport Network. It is based on the emulator of a Transport Node, which can have L1 (OTN) and L0 (fixed grid or flexi-grid DWDM) equipment, that runs a GMPLS based control plane. In particular, it has a OSPF-TE daemon that sends/receives OSPF-TE packets and a RSVP-TE daemon to set-up LSPs. It maintains a PCEP connection with a domain PCE. If used in stateless mode, the PCEP connection is used for path queries. If used in stateful mode, the PCEP connection can be used for remote initiation of LSPs. 14 | 15 | For more information and examples, see [Netphony GMPLS Emulator Wiki](https://github.com/telefonicaid/netphony-gmpls-emulator/wiki) 16 | ## Compilation and use 17 | 18 | The software can be built using the maven tool. 19 | To build the .jar file and run the tests, clone the repository, go to the main directory and run: 20 | ```bash 21 | git clone https://github.com/telefonicaid/netphony-gmpls-emulator.git 22 | cd netphony-gmpls-emulator 23 | mvn install 24 | ``` 25 | To use the library in your application, add the dependency in your pom.xml file: 26 | ```xml 27 | 28 | es.tid.netphony 29 | network-emulator 30 | 1.3.3 31 | 32 | ``` 33 | Authors keep also a copy of the artifact in maven central to facilitate the deployment. 34 | Note that, in the develop branch is maintained only in snapshots. 35 | 36 | ##Transport Node Emulator 37 | 38 | NodeLauncher is the main class to run a GMPLS Node emulator. It represents a Transport Node with GMPLS capabilities (e.g. an OTN node or a ROADM). It launches the OSPF-TE, RSVP-TE and PCEP necessary connectiosn. 39 | 40 | To run the Transport Node Emulator as a standalone application use the class NodeLauncher. You can use maven to create an autoexecutable jar that includes all dependencies in a single file. Plase be aware that you need to start as root. 41 | ```bash 42 | git clone https://github.com/telefonicaid/netphony-gmpls-emulator.git 43 | cd netphony-gmpls-emulator 44 | mvn clean package -P generate-autojar 45 | cd target 46 | sudo java -jar Emulator-jar-with-dependencies.jar 47 | ``` 48 | 49 | Before running, you should configure the parameteres. The parameters are configured in an xml file. By default, if used with NodeLauncher, or it is not specified a file name, XXX.xml should be used. An example of the file is located in examples/xxx.xml (and with the maven assembly build, it is copied in the target directory). 50 | 51 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.3.3 2 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/FastPCEPSessionServer.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node; 2 | 3 | import java.net.Inet4Address; 4 | import java.net.ServerSocket; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.emulator.node.transport.lsp.LSPManager; 9 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 10 | 11 | public class FastPCEPSessionServer extends Thread { 12 | 13 | private Logger log; 14 | private Inet4Address idRoadm; 15 | private LSPManager lspManager; 16 | private int nodeTechnology; 17 | private AutomaticTesterStatistics stats; 18 | 19 | public FastPCEPSessionServer(LSPManager lspManager, Inet4Address idRoadm, int nodeTechnology) 20 | { 21 | log=LoggerFactory.getLogger("ROADM"); 22 | this.idRoadm=idRoadm; 23 | this.lspManager=lspManager; 24 | this.nodeTechnology=nodeTechnology; 25 | } 26 | 27 | public void run(){ 28 | ServerSocket serverSocket = null; 29 | boolean listening=true; 30 | try { 31 | log.info("Listening Fast PCEP on port 2222 ooohhh"); 32 | serverSocket = new ServerSocket(2222); 33 | } 34 | catch (Exception e){ 35 | log.error("Could not listen fast PCEP on port 222"); 36 | e.printStackTrace(); 37 | return; 38 | } 39 | try { 40 | while (listening) { 41 | log.info("Waiting for connection Fast PCEP"); 42 | new FastPCEPSession(serverSocket.accept(), lspManager, idRoadm, nodeTechnology,stats).start(); 43 | } 44 | serverSocket.close(); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | log.info("Ending Fast PCEP Session!!"); 49 | } 50 | 51 | public AutomaticTesterStatistics getStats() { 52 | return stats; 53 | } 54 | 55 | public void setStats(AutomaticTesterStatistics stats) { 56 | this.stats = stats; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/NodeLauncher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package es.tid.emulator.node; 6 | 7 | /** 8 | * MAIN ROADM: Launches the ROADM 9 | */ 10 | 11 | public class NodeLauncher { 12 | 13 | /** 14 | * @param args the command line arguments 15 | */ 16 | public static void main(String[] args) { 17 | NetworkNode r = new NetworkNode(); 18 | r.setConfig(args); 19 | r.startNode(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/RemoteLSPInitPCEPSessionServer.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node; 2 | 3 | import java.net.Inet4Address; 4 | import java.net.ServerSocket; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.emulator.node.transport.lsp.LSPManager; 9 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 10 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 11 | 12 | public class RemoteLSPInitPCEPSessionServer implements Runnable { 13 | 14 | private Logger log; 15 | private Inet4Address idRoadm; 16 | private LSPManager lspManager; 17 | private int nodeTechnology; 18 | private AutomaticTesterStatistics stats; 19 | private boolean isStateful; 20 | 21 | public RemoteLSPInitPCEPSessionServer(LSPManager lspManager, Inet4Address idRoadm, int nodeTechnology, boolean isStateful) 22 | { 23 | log=LoggerFactory.getLogger("ROADM"); 24 | this.idRoadm=idRoadm; 25 | this.lspManager=lspManager; 26 | this.nodeTechnology=nodeTechnology; 27 | this.isStateful = isStateful; 28 | } 29 | 30 | @Override 31 | public void run() { 32 | ServerSocket serverSocket = null; 33 | boolean listening=true; 34 | try { 35 | log.info("Listening PCEP on port 4189"); 36 | serverSocket = new ServerSocket(4189); 37 | } 38 | catch (Exception e){ 39 | log.error("Could not listen fast PCEP on port 4189"); 40 | e.printStackTrace(); 41 | return; 42 | } 43 | try { 44 | while (listening) { 45 | //Socket s, LSPManager lspManager, Inet4Address idRoadm, PCEPSessionsInformation pcepSessionManager) 46 | log.info("New PCEP Session Open with Client!"); 47 | PCEPSessionsInformation pceSessionInf = new PCEPSessionsInformation(); 48 | pceSessionInf.setStateful(isStateful); 49 | log.info("Session is stateful ? :"+ isStateful); 50 | new RemoteLSPInitPCEPSession(serverSocket.accept(), lspManager, idRoadm, pceSessionInf).start(); 51 | } 52 | serverSocket.close(); 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/management/NodeManagementSever.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.management; 2 | 3 | import java.net.ServerSocket; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import es.tid.emulator.node.NetworkNode; 8 | 9 | public class NodeManagementSever extends Thread { 10 | 11 | private Logger log; 12 | private NetworkNode node; 13 | 14 | 15 | public NodeManagementSever(NetworkNode node){ 16 | log =LoggerFactory.getLogger("PCEServer"); 17 | this.node=node; 18 | } 19 | 20 | @Override 21 | public void run(){ 22 | ServerSocket serverSocket = null; 23 | boolean listening=true; 24 | try { 25 | log.info("Listening on port 6666"); 26 | serverSocket = new ServerSocket(6666); 27 | } 28 | catch (Exception e){ 29 | log.error("Could not listen management on port 6666"); 30 | e.printStackTrace(); 31 | return; 32 | } 33 | try { 34 | while (listening) { 35 | new NodeManagementSession(serverSocket.accept(), node).start(); 36 | } 37 | serverSocket.close(); 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/resources/Resource.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.resources; 2 | 3 | /** 4 | * 5 | * Class to include the needed information to check, reserve or free a network resource 6 | * 7 | * @author Fernando Mu�oz del Nuevo 8 | * 9 | * FIXME: A�adir la informaci�n necesaria para tocar los recursos 10 | * 11 | */ 12 | 13 | public class Resource { 14 | 15 | private String resourceName; 16 | 17 | public String getResourceName() { 18 | return resourceName; 19 | } 20 | 21 | public void setResourceName(String resourceName) { 22 | this.resourceName = resourceName; 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/resources/ResourceManager.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.resources; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.Hashtable; 5 | 6 | import es.tid.emulator.node.transport.lsp.LSPKey; 7 | import es.tid.emulator.node.transport.lsp.te.LSPTE; 8 | import es.tid.pce.pcep.messages.PCEPRequest; 9 | import es.tid.rsvp.messages.RSVPPathTearMessage; 10 | import es.tid.rsvp.messages.te.RSVPTEPathMessage; 11 | import es.tid.rsvp.messages.te.RSVPTEResvMessage; 12 | 13 | 14 | public interface ResourceManager { 15 | 16 | public boolean checkResources(LSPTE lsp); 17 | 18 | public boolean reserveResources(LSPTE lsp, Inet4Address dstNodeLink); 19 | 20 | 21 | public boolean freeResources(LSPTE lsp); 22 | 23 | public PCEPRequest getPCEPRequest(LSPTE lspInfo); 24 | 25 | //public boolean checkLocalResources(LSPTE lspInfo); 26 | 27 | public RSVPTEPathMessage getRSVPTEPathMessageFromPCEPResponse(LSPTE lsp); 28 | public RSVPPathTearMessage getRSVPPathTearMessage(LSPTE lsp); 29 | public RSVPTEResvMessage getRSVPResvMessageFromDestination(RSVPTEPathMessage path, LSPTE lsp); 30 | public RSVPTEPathMessage forwardRSVPpath(LSPTE lsp,RSVPTEPathMessage path); 31 | 32 | public Hashtable getProxHopIPv4List(); 33 | 34 | public void setProxHopIPv4List(Hashtable proxHopIPv4List); 35 | 36 | public Hashtable getPreviousHopIPv4List(); 37 | 38 | public void setPreviousHopIPv4List(Hashtable previousHopIPv4List); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/resources/mpls/MPLSResourceManager.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.resources.mpls; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.Hashtable; 5 | 6 | import es.tid.emulator.node.resources.ResourceManager; 7 | import es.tid.emulator.node.tedb.SimpleLocalTEDB; 8 | import es.tid.emulator.node.transport.lsp.LSPKey; 9 | import es.tid.emulator.node.transport.lsp.te.LSPTE; 10 | import es.tid.pce.pcep.messages.PCEPRequest; 11 | import es.tid.rsvp.messages.RSVPPathTearMessage; 12 | import es.tid.rsvp.messages.te.RSVPTEPathMessage; 13 | import es.tid.rsvp.messages.te.RSVPTEResvMessage; 14 | import es.tid.tedb.MDTEDB; 15 | 16 | /** 17 | * 18 | * Class implementing an MPLS resource manager 19 | * 20 | * @author Fernando Mu�oz del Nuevo 21 | * 22 | */ 23 | 24 | public class MPLSResourceManager implements ResourceManager{ 25 | 26 | private SimpleLocalTEDB ted; 27 | private Inet4Address localID; 28 | 29 | public MPLSResourceManager(SimpleLocalTEDB tedb, Inet4Address localID){ 30 | this.ted=tedb; 31 | this.localID=localID; 32 | } 33 | 34 | public MPLSResourceManager(SimpleLocalTEDB tedb, Inet4Address localID, MDTEDB MDted){ 35 | this.ted=tedb; 36 | this.localID=localID; 37 | } 38 | 39 | @Override 40 | public boolean checkResources(LSPTE lsp) { 41 | 42 | return false; 43 | } 44 | 45 | @Override 46 | public PCEPRequest getPCEPRequest(LSPTE lspInfo) { 47 | 48 | return null; 49 | } 50 | 51 | @Override 52 | public RSVPTEPathMessage forwardRSVPpath(LSPTE lsp, RSVPTEPathMessage path) { 53 | // TODO Auto-generated method stub 54 | return null; 55 | } 56 | 57 | @Override 58 | public boolean freeResources(LSPTE lsp) { 59 | // TODO Auto-generated method stub 60 | return false; 61 | } 62 | 63 | 64 | @Override 65 | public Hashtable getPreviousHopIPv4List() { 66 | // TODO Auto-generated method stub 67 | return null; 68 | } 69 | 70 | @Override 71 | public Hashtable getProxHopIPv4List() { 72 | // TODO Auto-generated method stub 73 | return null; 74 | } 75 | 76 | @Override 77 | public RSVPPathTearMessage getRSVPPathTearMessage(LSPTE lsp) { 78 | // TODO Auto-generated method stub 79 | return null; 80 | } 81 | 82 | @Override 83 | public RSVPTEResvMessage getRSVPResvMessageFromDestination(RSVPTEPathMessage path, 84 | LSPTE lsp) { 85 | // TODO Auto-generated method stub 86 | return null; 87 | } 88 | 89 | @Override 90 | public boolean reserveResources(LSPTE lsp, Inet4Address dstNodeLink) { 91 | // TODO Auto-generated method stub 92 | return false; 93 | } 94 | 95 | @Override 96 | public RSVPTEPathMessage getRSVPTEPathMessageFromPCEPResponse(LSPTE lsp) { 97 | // TODO Auto-generated method stub 98 | return null; 99 | } 100 | 101 | @Override 102 | public void setProxHopIPv4List( 103 | Hashtable proxHopIPv4List) { 104 | // TODO Auto-generated method stub 105 | 106 | } 107 | 108 | @Override 109 | public void setPreviousHopIPv4List( 110 | Hashtable previousHopIPv4List) { 111 | // TODO Auto-generated method stub 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/topology/HandlerTestMain.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.topology; 2 | 3 | import java.util.concurrent.LinkedBlockingQueue; 4 | 5 | import es.tid.netManager.TCPOSPFSender; 6 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 7 | 8 | 9 | public class HandlerTestMain { 10 | 11 | /** 12 | * @param args 13 | */ 14 | public static void main(String[] args) { 15 | // TODO Auto-generated method stub 16 | ParametersPrueba params= new ParametersPrueba(); 17 | params.initialize("parametersPrueba.xml"); 18 | Handler handler = new Handler(); 19 | handler.XMLRead(params.getNetworkFile()); 20 | LinkedBlockingQueue sendingQueue; 21 | TCPOSPFSender TCPOSPFsender = new TCPOSPFSender(params.getPCETEDBAddressList(),params.getOSPF_TCP_PORTList()); 22 | TCPOSPFsender.start(); 23 | sendingQueue=TCPOSPFsender.getSendingQueue(); 24 | handler.sendTopology(sendingQueue); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/Errors.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class Errors { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/ForwardingTable.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.net.Inet4Address; 6 | import java.net.InetAddress; 7 | import java.util.Properties; 8 | 9 | import es.tid.emulator.node.NetworkNode; 10 | 11 | /** 12 | * Forwarding Table Class 13 | * Implements methods to get the next hop to reach a destination node 14 | * @author fmn 15 | * 16 | */ 17 | 18 | public class ForwardingTable { 19 | 20 | private NetworkNode roadm; 21 | 22 | public ForwardingTable(NetworkNode roadm){ 23 | 24 | this.roadm = roadm; 25 | } 26 | public static Inet4Address getNextHop(Inet4Address destinationAddress){ 27 | Properties props = new Properties(); 28 | try{ 29 | props.load(new FileInputStream("defaultConfiguration.properties")); 30 | String nextHop = props.getProperty("nextHop"); 31 | try{ 32 | Inet4Address addr = (Inet4Address) InetAddress.getByName(nextHop); 33 | return addr; 34 | }catch(Exception e){ 35 | return null; 36 | } 37 | }catch(IOException e){ 38 | // FIXME: Meter mensaje de error 39 | return null; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/Interfaz.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package es.tid.emulator.node.transport; 6 | /** 7 | * Interfaz Class will represent the information that the ROADM needs to know about its own interfaces 8 | * in order to be able of connecting itself with other nodes. 9 | * 10 | * The main information to be stored about every Interfaz will be the following: 11 | * 12 | * 1.- Interfaz ID: FIXME: IP? No numerada? habr� que verlo 13 | * 2.- Grid: The transmission bandwidth over a single channel FIXME: RFCs 14 | * 3.- Channel Number: Number of channels that can be used per interface FIXME: RFCs 15 | * 4.- Channels: The status of every channel (occupied, free, reserved... ) FIXME: Decidirlo 16 | * 17 | * @author fmn 18 | */ 19 | public class Interfaz { 20 | 21 | private int idInterfaz; 22 | private int grid; 23 | private int channelNumber; 24 | private int[] channels; 25 | 26 | /** 27 | * 28 | * Default constructor 29 | * Creates an Interfaz with id = 0, grid = 0, channelNumber = 0 and creates 30 | * an empty channel array. 31 | * 32 | */ 33 | 34 | public Interfaz(){ 35 | 36 | idInterfaz = 0; 37 | grid = 0; 38 | channelNumber = 0; 39 | 40 | } 41 | 42 | /** 43 | * Constructor with parameters to fill idInterfaz, grid and channel number 44 | * attributes. It also initalizes the channel array to channelNumber size 45 | * with all channels free (0 value) 46 | * @param idInterfaz 47 | * @param grid 48 | * @param channelNumber 49 | */ 50 | 51 | public Interfaz(int idInterfaz, int grid, int channelNumber){ 52 | 53 | this.idInterfaz = idInterfaz; 54 | this.grid = grid; 55 | this.channelNumber = channelNumber; 56 | this.channels = new int[channelNumber]; 57 | 58 | } 59 | 60 | /** 61 | * @return idInterfaz parameter 62 | */ 63 | 64 | public int getIdIntefaz(){ 65 | 66 | return idInterfaz; 67 | 68 | } 69 | 70 | /** 71 | * 72 | * @return grid parameter 73 | */ 74 | 75 | public int getGrid(){ 76 | 77 | return grid; 78 | 79 | } 80 | 81 | /** 82 | * Method to extract channelNumber attribute 83 | * @return channelNumber 84 | */ 85 | 86 | public int getChannelNumber(){ 87 | 88 | return channelNumber; 89 | 90 | } 91 | 92 | /** 93 | * This method returns the channels status with the following legend: 94 | * 0 --> Free 95 | * 1 --> Used 96 | * 2 --> Down 97 | * 3 --> Admin Down 98 | * @return The array containing the channels status 99 | */ 100 | 101 | public int[] getChannels(){ 102 | 103 | return channels; 104 | 105 | } 106 | 107 | /** 108 | * 109 | * @param idInterfaz to fill idInterfaz attribute 110 | */ 111 | 112 | public void setIdInterfaz(int idInterfaz){ 113 | 114 | this.idInterfaz = idInterfaz; 115 | 116 | } 117 | 118 | /** 119 | * 120 | * @param grid to fill grid attribute 121 | */ 122 | 123 | public void setGrid(int grid){ 124 | 125 | this.grid = grid; 126 | 127 | } 128 | 129 | /** 130 | * Method to set the value of channelNumber attribute 131 | * @param channelNumber The number of channels to be set 132 | */ 133 | 134 | public void setChannelNumber(int channelNumber){ 135 | 136 | this.channelNumber = channelNumber; 137 | 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/LSPCreationException.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class LSPCreationException extends Exception { 4 | private static final long serialVersionUID = 0; 5 | private int errorType; 6 | private long lspID; 7 | 8 | 9 | public LSPCreationException(String msg){ 10 | super(msg); 11 | } 12 | public LSPCreationException(int errorType){ 13 | this.errorType = errorType; 14 | } 15 | public int getErrorType() { 16 | return errorType; 17 | } 18 | public void setErrorType(int errorType) { 19 | this.errorType = errorType; 20 | } 21 | public long getLspID() { 22 | return lspID; 23 | } 24 | public void setLspID(long lspID) { 25 | this.lspID = lspID; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/LSPReservationException.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class LSPReservationException extends Exception { 4 | private static final long serialVersionUID = 0; 5 | 6 | public LSPReservationException(){ 7 | super(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/RequestedLSPinformation.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | import java.net.Inet4Address; 4 | 5 | public class RequestedLSPinformation { 6 | //toda la información de entrada para el lsp en la request 7 | private Inet4Address source; 8 | 9 | private Inet4Address destination; 10 | 11 | //exclude nodes 12 | 13 | //exclude links 14 | 15 | //include nodes 16 | 17 | //include links 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/RequestedLSPinformationMPLS.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class RequestedLSPinformationMPLS extends RequestedLSPinformation{ 4 | //toda la información de entrada para el lsp en la request 5 | private long bandwidth; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/RequestedLSPinformationSSON.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class RequestedLSPinformationSSON extends RequestedLSPinformation{ 4 | //toda la información de entrada para el lsp en la request 5 | private int suggestedN; 6 | private int suggestedM; 7 | private long bandwidth; 8 | 9 | public RequestedLSPinformationSSON (){ 10 | 11 | } 12 | 13 | public int getSuggestedN() { 14 | return suggestedN; 15 | } 16 | 17 | public void setSuggestedN(int suggestedN) { 18 | this.suggestedN = suggestedN; 19 | } 20 | 21 | public int getSuggestedM() { 22 | return suggestedM; 23 | } 24 | 25 | public void setSuggestedM(int suggestedM) { 26 | this.suggestedM = suggestedM; 27 | } 28 | 29 | public long getBandwidth() { 30 | return bandwidth; 31 | } 32 | 33 | public void setBandwidth(long bandwidth) { 34 | this.bandwidth = bandwidth; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/RequestedLSPinformationWSON.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | public class RequestedLSPinformationWSON extends RequestedLSPinformation{ 4 | //toda la información de entrada para el lsp en la request 5 | private int suggestedLambda; 6 | 7 | public RequestedLSPinformationWSON(){ 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/defineLocalTEDB.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.Iterator; 5 | import java.util.Set; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import org.jgrapht.graph.DirectedWeightedMultigraph; 10 | import org.jgrapht.graph.SimpleDirectedWeightedGraph; 11 | 12 | import es.tid.tedb.InterDomainEdge; 13 | import es.tid.tedb.IntraDomainEdge; 14 | 15 | public class defineLocalTEDB { 16 | private static Logger log; 17 | // Podate Simple TEDB 18 | public static SimpleDirectedWeightedGraph podateGraph(SimpleDirectedWeightedGraph Graph, Inet4Address RoadmID){ 19 | log = LoggerFactory.getLogger("ROADM"); 20 | SimpleDirectedWeightedGraph local_graph = new SimpleDirectedWeightedGraph(IntraDomainEdge.class); 21 | local_graph = (SimpleDirectedWeightedGraph) Graph.clone(); 22 | Set links = Graph.edgeSet(); 23 | Iterator iteredges = links.iterator(); 24 | IntraDomainEdge link; 25 | while (iteredges.hasNext()) 26 | { 27 | link = iteredges.next(); 28 | if (!(link.getSource().equals(RoadmID))){ 29 | local_graph.removeEdge(link); 30 | } 31 | } 32 | 33 | Set nodes = Graph.vertexSet(); 34 | Iterator iternodes = nodes.iterator(); 35 | Object node = null; 36 | boolean found = true; 37 | while (iternodes.hasNext()) 38 | { 39 | node = iternodes.next(); 40 | links = local_graph.edgeSet(); 41 | iteredges = links.iterator(); 42 | found = false; 43 | while (iteredges.hasNext() && (found == false)) 44 | { 45 | link = iteredges.next(); 46 | if (!((link.getSource()).equals(node)) && !((link.getTarget()).equals(node))){ 47 | found = false; 48 | } 49 | else 50 | found = true; 51 | } 52 | if (found == false) 53 | local_graph.removeVertex(node); 54 | } 55 | return local_graph; 56 | } 57 | 58 | // Podate Multi Domain TEDB 59 | public static DirectedWeightedMultigraph podateMDGraph(DirectedWeightedMultigraph Graph, Object RoadmID){ 60 | DirectedWeightedMultigraph local_graph = new DirectedWeightedMultigraph(InterDomainEdge.class); 61 | local_graph = (DirectedWeightedMultigraph) Graph.clone(); 62 | Set links = Graph.edgeSet(); 63 | Iterator iteredges = links.iterator(); 64 | InterDomainEdge link; 65 | while (iteredges.hasNext()) 66 | { 67 | link = iteredges.next(); 68 | if (!(link.getSource().equals(RoadmID))){ 69 | log.info("Podate Link: "+link.toString()); 70 | local_graph.removeEdge(link); 71 | } 72 | } 73 | Set nodes = Graph.vertexSet(); 74 | Iterator iternodes = nodes.iterator(); 75 | Object node = null; 76 | boolean found = true; 77 | while (iternodes.hasNext()) 78 | { 79 | node = iternodes.next(); 80 | links = local_graph.edgeSet(); 81 | iteredges = links.iterator(); 82 | found = false; 83 | while (iteredges.hasNext() && (found == false)) 84 | { 85 | link = iteredges.next(); 86 | if (!((link.getSource()).equals(node)) && !((link.getTarget()).equals(node))){ 87 | found = false; 88 | } 89 | else 90 | found = true; 91 | } 92 | if (found == false){ 93 | log.info("Delete Node: "+node.toString()); 94 | local_graph.removeVertex(node); 95 | } 96 | } 97 | return local_graph; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/LSP.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package es.tid.emulator.node.transport.lsp; 6 | 7 | import java.net.Inet4Address; 8 | 9 | /** 10 | * This class represents all the needed LSP information to completely characterize it. 11 | * 12 | * Parameters: 13 | * 14 | * 1.- LSP ID: The unique LSP identifier 15 | * 2.- Source ID: The source node address 16 | * 3.- Destination ID: The destination node address 17 | * 4.- Characteristics: The LSP main characteristics used to compose a correct RSVP message. 18 | * @author fmn 19 | */ 20 | public class LSP { 21 | 22 | private long idLSP; 23 | private Inet4Address idSource; 24 | private Inet4Address idDestination; 25 | //private PathState pathState; 26 | private int pathState; 27 | 28 | /** 29 | * 30 | * @param idSource 31 | * @param idDestination 32 | * @param characteristics 33 | */ 34 | 35 | public LSP(Long idLSP,Inet4Address idSource, Inet4Address idDestination, int pathState){ 36 | 37 | this.idLSP = idLSP; 38 | this.idSource = idSource; 39 | this.idDestination = idDestination; 40 | this.pathState=pathState; 41 | this.idSource = idSource; 42 | 43 | //this.pathState = new PathState(); 44 | 45 | } 46 | 47 | /** 48 | * 49 | * @return 50 | */ 51 | 52 | public Inet4Address getIdSource(){ 53 | return idSource; 54 | } 55 | 56 | /** 57 | * 58 | * @return 59 | */ 60 | 61 | public Inet4Address getIdDestination(){ 62 | return idDestination; 63 | } 64 | 65 | public Long getIdLSP() { 66 | return idLSP; 67 | } 68 | 69 | public void setIdLSP(Long idLSP) { 70 | this.idLSP = idLSP; 71 | } 72 | 73 | public int getPathState() { 74 | return pathState; 75 | } 76 | 77 | public void setPathState(int pathState) { 78 | this.pathState = pathState; 79 | } 80 | 81 | public void setIdSource(Inet4Address idSource) { 82 | this.idSource = idSource; 83 | } 84 | 85 | public void setIdDestination(Inet4Address idDestination) { 86 | this.idDestination = idDestination; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/LSPCreationErrorTypes.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp; 2 | 3 | public class LSPCreationErrorTypes { 4 | public static final int NO_PATH = 1; 5 | public static final int NO_RESPONSE = 2; 6 | public static final int NO_RESOURCES = 3; 7 | public static final int ERROR_REQUEST = 4; 8 | } -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/LSPKey.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp; 2 | 3 | import java.net.Inet4Address; 4 | 5 | public class LSPKey { 6 | 7 | public long lspId; 8 | public Inet4Address sourceAddress; 9 | 10 | public LSPKey (Inet4Address sourceIP, long Id){ 11 | //LSPList = new Hashtable>(); 12 | this.sourceAddress=sourceIP; 13 | this.lspId=Id; 14 | } 15 | 16 | public long getLspId() { 17 | return lspId; 18 | } 19 | 20 | public void setLspId(long lspId) { 21 | this.lspId = lspId; 22 | } 23 | 24 | public Inet4Address getSourceAddress() { 25 | return sourceAddress; 26 | } 27 | 28 | public void setSourceAddress(Inet4Address sourceAddress) { 29 | this.sourceAddress = sourceAddress; 30 | } 31 | 32 | @Override 33 | public int hashCode() { 34 | final int prime = 31; 35 | int result = 1; 36 | result = prime * result + (int) (lspId ^ (lspId >>> 32)); 37 | result = prime * result 38 | + ((sourceAddress == null) ? 0 : sourceAddress.hashCode()); 39 | return result; 40 | } 41 | 42 | @Override 43 | public boolean equals(Object obj) { 44 | if (this == obj) 45 | return true; 46 | if (obj == null) 47 | return false; 48 | if (getClass() != obj.getClass()) 49 | return false; 50 | LSPKey other = (LSPKey) obj; 51 | if (lspId != other.lspId) 52 | return false; 53 | if (sourceAddress == null) { 54 | if (other.sourceAddress != null) 55 | return false; 56 | } else if (!sourceAddress.equals(other.sourceAddress)) 57 | return false; 58 | return true; 59 | } 60 | 61 | public String toString() 62 | { 63 | return ""; 64 | } 65 | 66 | 67 | /* public synchronized long getIdNewLSP(Inet4Address src) { 68 | LSPKey.idNewLSP=LSPKey.idNewLSP+1; 69 | long newLSP=LSPKey.idNewLSP; 70 | if (LSPKey.idNewLSP>=Integer.MAX_VALUE){ 71 | LSPKey.idNewLSP=0; 72 | } 73 | return newLSP; 74 | // int id_LSP=0; 75 | // if (LSPList.get(src) == null){ 76 | // id_from_source = new Hashtable(); 77 | // id_LSP = 1; 78 | // id_from_source.put(src, id_LSP); 79 | // } 80 | // else { 81 | // id_LSP = id_from_source.get(src); 82 | // id_LSP++; 83 | // id_from_source.put(src, id_LSP); 84 | // } 85 | //return id_LSP; 86 | }*/ 87 | 88 | /*public void setLSP (LSPTE lsp, long id, Inet4Address src){ 89 | Hashtable LSPList_src; 90 | int ID = 0; 91 | if (LSPList.get(src) == null){ 92 | LSPList_src = new Hashtable(); 93 | LSPList_src.put(id, lsp); 94 | } 95 | else { 96 | LSPList_src = LSPList.get(src); 97 | LSPList_src.put (id, lsp); 98 | } 99 | LSPList.put(src, LSPList_src); 100 | } 101 | public void removeLSP(long ID, Inet4Address src){ 102 | Hashtable LSPList_dst = LSPList.get(src); 103 | LSPList_dst.remove(ID); 104 | if (LSPList_dst.isEmpty()){ 105 | LSPList.remove(src); 106 | } 107 | }*/ 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/LSPParameters.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp; 2 | 3 | public class LSPParameters { 4 | 5 | public static final int LSP_NODE_TYPE_SOURCE = 1; 6 | public static final int LSP_NODE_TYPE_DESTINATION = -1; 7 | public static final int LSP_NODE_TYPE_TRANSIT = 0; 8 | 9 | public static final int LABEL_REQUEST_L3_PID_IP = 0x0800; 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/Node_State_Parameters.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp; 2 | 3 | public class Node_State_Parameters { 4 | public static final int PATH_STATE = 0; 5 | public static final int RESERVATION_STATE = 1; 6 | public static final int SOFT_STATE = 2; 7 | public static final int BLOCKADE_STATE = 3; 8 | } -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/PathState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package es.tid.emulator.node.transport.lsp; 6 | /** 7 | * Class representing RSVP Path State 8 | * @author fmn 9 | */ 10 | public class PathState { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/te/PathStateParameters.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp.te; 2 | 3 | public class PathStateParameters { 4 | public static final int creatingLPS = 0; 5 | public static final int addingLPS = 1; 6 | public static final int LSPEstablished = 2; 7 | public static final int StartingDelentionLSP = 3; 8 | public static final int DelentingLSP = 4; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/te/TEPathState.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.lsp.te; 2 | 3 | import es.tid.emulator.node.transport.lsp.PathState; 4 | import es.tid.rsvp.constructs.SenderDescriptor; 5 | import es.tid.rsvp.objects.ERO; 6 | import es.tid.rsvp.objects.LabelRequest; 7 | import es.tid.rsvp.objects.PolicyData; 8 | import es.tid.rsvp.objects.RSVPHop; 9 | import es.tid.rsvp.objects.Session; 10 | import es.tid.rsvp.objects.SessionAttribute; 11 | import es.tid.rsvp.objects.TimeValues; 12 | 13 | /** 14 | * TE Path State class implements the complete path state of an RSVP-TE path. 15 | * @author Fernando Mu�oz del Nuevo fmn@tid.es 16 | */ 17 | 18 | public class TEPathState extends PathState { 19 | 20 | private Session session; 21 | private RSVPHop previousHop; 22 | private TimeValues timeValues; 23 | private ERO explicitRoute; 24 | private LabelRequest labelRequest; 25 | private SessionAttribute sessionAttribute; 26 | private PolicyData policyData; 27 | private SenderDescriptor senderDescriptor; 28 | 29 | public Session getSession() { 30 | return session; 31 | } 32 | public void setSession(Session session) { 33 | this.session = session; 34 | } 35 | public RSVPHop getPreviousHop() { 36 | return previousHop; 37 | } 38 | public void setPreviousHop(RSVPHop previousHop) { 39 | this.previousHop = previousHop; 40 | } 41 | public TimeValues getTimeValues() { 42 | return timeValues; 43 | } 44 | public void setTimeValues(TimeValues timeValues) { 45 | this.timeValues = timeValues; 46 | } 47 | public ERO getExplicitRoute() { 48 | return explicitRoute; 49 | } 50 | public void setExplicitRoute(ERO explicitRoute) { 51 | this.explicitRoute = explicitRoute; 52 | } 53 | public LabelRequest getLabelRequest() { 54 | return labelRequest; 55 | } 56 | public void setLabelRequest(LabelRequest labelRequest) { 57 | this.labelRequest = labelRequest; 58 | } 59 | public SessionAttribute getSessionAttribute() { 60 | return sessionAttribute; 61 | } 62 | public void setSessionAttribute(SessionAttribute sessionAttribute) { 63 | this.sessionAttribute = sessionAttribute; 64 | } 65 | public PolicyData getPolicyData() { 66 | return policyData; 67 | } 68 | public void setPolicyData(PolicyData policyData) { 69 | this.policyData = policyData; 70 | } 71 | public SenderDescriptor getSenderDescriptor() { 72 | return senderDescriptor; 73 | } 74 | public void setSenderDescriptor(SenderDescriptor senderDescriptor) { 75 | this.senderDescriptor = senderDescriptor; 76 | } 77 | 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/lsp/te/TechnologyParameters.java: -------------------------------------------------------------------------------- 1 | /** PCEP header fields values for protocol messages according to RFC 5440 and extensions 2 | * See http://www.iana.org/assignments/pcep/pcep.xml for updated values 3 | * @author Carlos Garcia Argos (cgarcia@novanotio.es) 4 | * @author Oscar Gonzalez de Dios (ogondio@tid.es) 5 | * Last update: Jun 2011 6 | */ 7 | 8 | package es.tid.emulator.node.transport.lsp.te; 9 | 10 | public class TechnologyParameters { 11 | public static final int UNKNOWN = 0; 12 | public static final int WSON = 1; 13 | public static final int SSON = 2; 14 | public static final int MPLS = 3; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/ospf/OSPFController.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.ospf; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.concurrent.LinkedBlockingQueue; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 9 | import es.tid.tedb.DomainTEDB; 10 | 11 | public class OSPFController { 12 | private DomainTEDB domainTEDB; 13 | private OSPFSenderThread ospfSenderThread; 14 | private Inet4Address nodeID; 15 | private Inet4Address localNodeAddress; 16 | private OSPFSendAllTopology ospfSendAllTopology; 17 | private OSPFSenderManager ospfSenderManager; 18 | 19 | /** 20 | * Queue to read the messages to send to the PCE peer 21 | */ 22 | private LinkedBlockingQueue sendingQueue; 23 | 24 | Logger log=LoggerFactory.getLogger("OSPFParser"); 25 | 26 | public OSPFController(){ 27 | sendingQueue= new LinkedBlockingQueue(); 28 | } 29 | 30 | public void configureOSPFController(Inet4Address nodeID, DomainTEDB tedb, Inet4Address localNodeAddress){ 31 | this.nodeID=nodeID; 32 | this.domainTEDB=tedb; 33 | this.localNodeAddress=localNodeAddress; 34 | } 35 | 36 | public void initialize (){ 37 | ospfSenderThread = new OSPFSenderThread(sendingQueue, localNodeAddress); 38 | ospfSenderThread.start(); 39 | ospfSenderManager = new OSPFSenderManager(); 40 | ospfSenderManager.setSendingQueue(sendingQueue); 41 | ospfSenderManager.setDomainTEDB(domainTEDB); 42 | ospfSendAllTopology = new OSPFSendAllTopology (domainTEDB, ospfSenderManager); 43 | ospfSendAllTopology.start(); 44 | } 45 | 46 | public DomainTEDB getDomainTEDB() { 47 | return domainTEDB; 48 | } 49 | 50 | public void setDomainTEDB(DomainTEDB domainTEDB) { 51 | this.domainTEDB = domainTEDB; 52 | } 53 | 54 | public LinkedBlockingQueue getSendingQueue() { 55 | return sendingQueue; 56 | } 57 | 58 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 59 | this.sendingQueue = sendingQueue; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/ospf/OSPFSendAllTopology.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PCEP KeepAlive management Thread 3 | * 4 | * Carlos Garcia Argos (cgarcia@novanotio.es) 5 | * Feb. 11 2010 6 | */ 7 | 8 | package es.tid.emulator.node.transport.ospf; 9 | 10 | import java.net.Inet4Address; 11 | import java.util.Iterator; 12 | import java.util.Set; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import org.jgrapht.graph.SimpleDirectedWeightedGraph; 17 | 18 | import es.tid.tedb.DomainTEDB; 19 | import es.tid.tedb.IntraDomainEdge; 20 | import es.tid.tedb.SimpleTEDB; 21 | 22 | public class OSPFSendAllTopology extends Thread { 23 | 24 | private boolean running; 25 | //private Roadm roadm; 26 | private DomainTEDB domainTEDB; 27 | private OSPFSenderManager ospfSenderManager; 28 | private Logger log; 29 | 30 | public OSPFSendAllTopology(DomainTEDB domainTEDB, OSPFSenderManager ospfsenderManager) { 31 | //this.roadm=roadm; 32 | this.domainTEDB=domainTEDB; 33 | this.ospfSenderManager=ospfsenderManager; 34 | log = LoggerFactory.getLogger("OSPFParser"); 35 | } 36 | /** 37 | * Starts the keepAliveLSP process 38 | */ 39 | 40 | public void run(){ 41 | running=true; 42 | while (running) { 43 | try { 44 | sleep(10000); // send all topology every 10 seconds 45 | log.info("SEND ALL TOPOLOGY"); 46 | SimpleDirectedWeightedGraph networkGraph = ((SimpleTEDB)domainTEDB).getNetworkGraph(); 47 | Set edgeSet= networkGraph.edgeSet(); 48 | Iterator edgeIterator=edgeSet.iterator(); 49 | while (edgeIterator.hasNext()){ 50 | IntraDomainEdge edge= edgeIterator.next(); 51 | ospfSenderManager.sendMessageOSPF((Inet4Address)edge.getSource(),(Inet4Address)edge.getTarget()); 52 | } 53 | } catch (InterruptedException e) { 54 | if (running==false){ 55 | log.info("Ending SendAllTopology - Thread"); 56 | return; 57 | } 58 | else { 59 | //Keep-alive Timer is reseted 60 | log.info("Reseting SendAllTopology timer"); 61 | } 62 | } 63 | } 64 | } 65 | /** 66 | * Sets the running variable to false. After this, an interrupt will cause 67 | * the KeepaliveThread to end. 68 | */ 69 | public void stopRunning(){ 70 | running=false; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/ospf/OSPFSenderManager.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.ospf; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.LinkedList; 5 | import java.util.concurrent.LinkedBlockingQueue; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 10 | import es.tid.ospf.ospfv2.lsa.LSA; 11 | import es.tid.ospf.ospfv2.lsa.OSPFTEv2LSA; 12 | import es.tid.ospf.ospfv2.lsa.tlv.LinkTLV; 13 | import es.tid.ospf.ospfv2.lsa.tlv.subtlv.LinkID; 14 | import es.tid.ospf.ospfv2.lsa.tlv.subtlv.LinkLocalRemoteIdentifiers; 15 | import es.tid.ospf.ospfv2.lsa.tlv.subtlv.LocalInterfaceIPAddress; 16 | import es.tid.ospf.ospfv2.lsa.tlv.subtlv.RemoteInterfaceIPAddress; 17 | import es.tid.tedb.DomainTEDB; 18 | import es.tid.tedb.IntraDomainEdge; 19 | import es.tid.tedb.SimpleTEDB; 20 | 21 | public class OSPFSenderManager { 22 | 23 | private DomainTEDB domainTEDB; 24 | 25 | public DomainTEDB getDomainTEDB() { 26 | return domainTEDB; 27 | } 28 | 29 | public void setDomainTEDB(DomainTEDB domainTEDB) { 30 | this.domainTEDB = domainTEDB; 31 | } 32 | 33 | private LinkedBlockingQueue sendingQueue; 34 | 35 | Logger log=LoggerFactory.getLogger("OSPFParser"); 36 | 37 | public void sendMessageOSPF(Inet4Address src,Inet4Address dst){ 38 | log.info("SEND OSPF"); 39 | 40 | //changes for multilayer OSPF (UpperLayer and LowerLayer) 41 | IntraDomainEdge edge = null; 42 | 43 | edge=((SimpleTEDB)domainTEDB).getNetworkGraph().getEdge(src, dst); 44 | OSPFv2LinkStateUpdatePacket ospfv2Packet = new OSPFv2LinkStateUpdatePacket(); 45 | ospfv2Packet.setRouterID(src); 46 | 47 | ospfv2Packet.setAreaID(domainTEDB.getReachabilityEntry().getDomainId()); 48 | 49 | LinkedList lsaList = new LinkedList(); 50 | OSPFTEv2LSA lsa = new OSPFTEv2LSA(); 51 | LinkTLV linkTLV=new LinkTLV(); 52 | lsa.setLinkTLV(linkTLV); 53 | lsa.setAdvertisingRouter(src); 54 | /** linkTLV.setMaximumBandwidth(edge.getTE_info().getMaximumBandwidth()); 55 | linkTLV.setUnreservedBandwidth(edge.getTE_info().getUnreservedBandwidth()); 56 | linkTLV.setMaximumReservableBandwidth(edge.getTE_info().getMaximumReservableBandwidth()); 57 | */ LocalInterfaceIPAddress localInterfaceIPAddress= new LocalInterfaceIPAddress(); 58 | LinkedList lista =localInterfaceIPAddress.getLocalInterfaceIPAddressList(); 59 | lista.add(src); 60 | linkTLV.setLocalInterfaceIPAddress(localInterfaceIPAddress); 61 | RemoteInterfaceIPAddress remoteInterfaceIPAddress= new RemoteInterfaceIPAddress(); 62 | LinkedList listar = remoteInterfaceIPAddress.getRemoteInterfaceIPAddressList(); 63 | listar.add(dst); 64 | linkTLV.setRemoteInterfaceIPAddress(remoteInterfaceIPAddress); 65 | LinkLocalRemoteIdentifiers llri= new LinkLocalRemoteIdentifiers(); 66 | llri.setLinkLocalIdentifier(edge.getSrc_if_id()); 67 | llri.setLinkRemoteIdentifier(edge.getDst_if_id()); 68 | linkTLV.setLinkLocalRemoteIdentifiers(llri); 69 | LinkID linkID = new LinkID(); 70 | linkID.setLinkID(dst); 71 | linkTLV.setLinkID(linkID); 72 | if (edge.getTE_info().getAvailableLabels() != null){ 73 | linkTLV.setAvailableLabels(edge.getTE_info().getAvailableLabels()); 74 | } 75 | else 76 | log.info("Available Labels es NULL"); 77 | lsaList.add(lsa); 78 | 79 | ospfv2Packet.setLSAlist(lsaList); 80 | sendingQueue.add(ospfv2Packet); 81 | } 82 | 83 | public LinkedBlockingQueue getSendingQueue() { 84 | return sendingQueue; 85 | } 86 | 87 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 88 | this.sendingQueue = sendingQueue; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/ospf/OSPFSenderThread.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.node.transport.ospf; 2 | 3 | import static es.tid.rocksaw.net.RawSocket.PF_INET; 4 | 5 | import java.io.IOException; 6 | import java.net.Inet4Address; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import es.tid.rocksaw.net.RawSocket; 13 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 14 | 15 | public class OSPFSenderThread extends Thread{ 16 | 17 | // Timeout para el socket 18 | private static final int TIMEOUT = 0; 19 | 20 | private Inet4Address NodeLocalAddress; 21 | 22 | private final String OSPFMulticastAddressString = "224.0.0.5"; 23 | 24 | private Inet4Address OSPFMulticastAddress; 25 | 26 | private LinkedBlockingQueue sendingQueue; 27 | 28 | Logger log=LoggerFactory.getLogger("OSPFParser"); 29 | 30 | public OSPFSenderThread (LinkedBlockingQueue sendingqueue, Inet4Address NodeLocalAddress){ 31 | this.sendingQueue=sendingqueue; 32 | this.NodeLocalAddress = NodeLocalAddress; 33 | try{ 34 | OSPFMulticastAddress = (Inet4Address)Inet4Address.getByName(OSPFMulticastAddressString); 35 | }catch(Exception e){ 36 | } 37 | } 38 | 39 | public void run(){ 40 | OSPFv2LinkStateUpdatePacket OSPF_msg; 41 | RawSocket socket = new RawSocket(); 42 | 43 | try{ 44 | socket.open(PF_INET, 89); 45 | socket.setUseSelectTimeout(true); 46 | socket.setSendTimeout(TIMEOUT); 47 | socket.setReceiveTimeout(TIMEOUT); 48 | socket.bind(NodeLocalAddress); 49 | log.info("Raw Socket Opened for OSPF with local address binded to "+NodeLocalAddress); 50 | }catch(IOException e){ 51 | e.printStackTrace(); 52 | System.exit(-1); 53 | } 54 | while (true){ 55 | log.info("Socket is open??:" + socket.isOpen()); 56 | try { 57 | 58 | OSPF_msg=sendingQueue.take(); 59 | } catch (InterruptedException e) { 60 | log.error("Exception tying to take a OSPF message from the sendingQueue in OSPFSender."); 61 | return; 62 | } 63 | try { 64 | //OSPFv2LinkStateUpdatePacket ospf_packet= new OSPFv2LinkStateUpdatePacket(); 65 | //(ospf_packet.getLSAlist()).add(LSA_msg); 66 | //ospf_packet.encode(); 67 | OSPF_msg.encode(); 68 | //for (int i=0;i getSendingQueue() { 80 | return sendingQueue; 81 | } 82 | 83 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 84 | this.sendingQueue = sendingQueue; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/rsvp/RSVPListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package es.tid.emulator.node.transport.rsvp; 7 | import java.io.IOException; 8 | import java.util.concurrent.LinkedBlockingQueue; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import es.tid.rocksaw.net.RawSocket; 13 | 14 | import es.tid.emulator.node.NetworkNode; 15 | import es.tid.rsvp.RSVPProtocolViolationException; 16 | import es.tid.rsvp.messages.RSVPMessage; 17 | import es.tid.rsvp.messages.RSVPMessageTypes; 18 | import es.tid.rsvp.messages.RSVPPathTearMessage; 19 | import es.tid.rsvp.messages.te.RSVPTEPathMessage; 20 | import es.tid.rsvp.messages.te.RSVPTEResvMessage; 21 | 22 | /** 23 | * Takes care of every RSVP message that the ROADM receives. 24 | * @author fmn 25 | */ 26 | public class RSVPListener extends Thread{ 27 | 28 | private static final int TIMEOUT = 0; 29 | private RawSocket socket; 30 | private NetworkNode roadm; 31 | public static Logger log; 32 | private int tipo; 33 | private LinkedBlockingQueue RSVPMessageQueue; 34 | 35 | public RSVPListener(LinkedBlockingQueue RSVPMessageQueue,RawSocket socket ){ 36 | this.socket=socket; 37 | this.RSVPMessageQueue=RSVPMessageQueue; 38 | log=LoggerFactory.getLogger("ROADM"); 39 | } 40 | 41 | private int getTipo(){ 42 | return tipo; 43 | } 44 | 45 | public void run(){ 46 | log.info("Listener RSVP Started"); 47 | boolean running = true; 48 | 49 | while(running){ 50 | 51 | try{ 52 | 53 | int bufferSize = socket.getReceiveBufferSize(); 54 | byte[] data2 = new byte[bufferSize]; 55 | 56 | socket.read(data2); 57 | 58 | byte[] data = new byte[bufferSize-20]; // Cabecera IP fuera 59 | 60 | System.arraycopy(data2, 20, data, 0, bufferSize-20); 61 | 62 | int messageType = RSVPMessage.getMsgType(data); 63 | int length = RSVPMessage.getMsgLength(data); 64 | 65 | switch(messageType){ 66 | case RSVPMessageTypes.MESSAGE_PATH: 67 | log.info("RSVP-TE Path Message Received"); 68 | 69 | RSVPTEPathMessage path = new RSVPTEPathMessage(data, length); 70 | try{ 71 | path.decode(); 72 | RSVPMessageQueue.add(path); 73 | 74 | }catch(RSVPProtocolViolationException e){ 75 | log.error("Failure decoding RSVP-TE Path Message"); 76 | } 77 | break; 78 | case RSVPMessageTypes.MESSAGE_RESV: 79 | log.info("RSVP-TE Resv Message Received"); 80 | RSVPTEResvMessage resv = new RSVPTEResvMessage(data, length); 81 | try{ 82 | resv.decode(); 83 | RSVPMessageQueue.add(resv); 84 | }catch(RSVPProtocolViolationException e){ 85 | log.error("Failure decoding RSVP-TE Resv Message"); 86 | } 87 | break; 88 | case RSVPMessageTypes.MESSAGE_PATHTEAR: 89 | log.info("RSVP-TE Path Tear Message Received"); 90 | RSVPPathTearMessage tear = new RSVPPathTearMessage(data, length); 91 | try{ 92 | tear.decode(); 93 | RSVPMessageQueue.add(tear); 94 | }catch(RSVPProtocolViolationException e){ 95 | log.error("Failure decoding RSVP-TE Path Tear Message"); 96 | } 97 | break; 98 | default: 99 | log.error("Unrecongizable RSVP Message"); 100 | break; 101 | } 102 | }catch(IOException e){ 103 | e.printStackTrace(); 104 | System.exit(0); 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/rsvp/RSVPSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package es.tid.emulator.node.transport.rsvp; 7 | 8 | /** 9 | * 10 | * @author fmn 11 | */ 12 | public class RSVPSender { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/node/transport/rsvp/RSVPSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package es.tid.emulator.node.transport.rsvp; 7 | 8 | import java.util.Timer; 9 | 10 | 11 | /** 12 | * 13 | * @author fmn 14 | */ 15 | public class RSVPSession extends Thread { 16 | 17 | private RSVPListener listener; 18 | private RSVPSender sender; 19 | private boolean no_delay=false; 20 | private String ID_dest; 21 | private int port; 22 | private int deadTimerLocal = 0; 23 | private Timer timer; 24 | private int keepAliveLocal = 0; 25 | private boolean running = true; 26 | 27 | public RSVPSession(String ip_destination, int port, boolean no_delay){ 28 | this.no_delay=no_delay; 29 | this.ID_dest=ip_destination; 30 | this.port=port; 31 | this.keepAliveLocal=30; 32 | this.deadTimerLocal=120; 33 | this.timer = new Timer(); 34 | } 35 | 36 | public void run(){ 37 | running=true; 38 | /*System.out.println("Nueva Sesion RSVP"); 39 | System.out.println("Opening new RSVP Session with host "+ ID_dest + " on port " + port);*/ 40 | 41 | 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/pccPrueba/RemoteAutomaticPCCLauncher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package es.tid.emulator.pccPrueba; 6 | 7 | /** 8 | * MAIN ROADM: Launches the ROADM 9 | */ 10 | 11 | public class RemoteAutomaticPCCLauncher { 12 | 13 | /** 14 | * @param args the command line arguments 15 | */ 16 | public static void main(String[] args) { 17 | RemoteAutomaticPCC r = new RemoteAutomaticPCC(); 18 | r.startRemoteAutomaticPCC(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/es/tid/emulator/pccPrueba/RemoteLSPInitPCEPSessionServer.java: -------------------------------------------------------------------------------- 1 | package es.tid.emulator.pccPrueba; 2 | 3 | import java.net.Socket; 4 | import java.util.Timer; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 9 | import es.tid.pce.pcepsession.GenericPCEPSession; 10 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 11 | import es.tid.pce.pcepsession.PCEPValues; 12 | 13 | public class RemoteLSPInitPCEPSessionServer extends GenericPCEPSession { 14 | 15 | private Logger log; 16 | private AutomaticTesterStatistics stats; 17 | private ClientRequestManagerPrueba crm; 18 | private Socket socket; 19 | 20 | private String peerNode_IPaddress; 21 | private boolean no_delay; 22 | private PCEPSessionsInformation pcepSessionManager; 23 | 24 | public RemoteLSPInitPCEPSessionServer(String ip, boolean no_delay, PCEPSessionsInformation pcepSessionManager, 25 | ClientRequestManagerPrueba crm) { 26 | super(pcepSessionManager); 27 | this.setFSMstate(PCEPValues.PCEP_STATE_IDLE); 28 | log=LoggerFactory.getLogger("PCCClient"); 29 | this.peerNode_IPaddress=ip; 30 | this.crm= crm; 31 | this.keepAliveLocal=30; 32 | this.deadTimerLocal=120; 33 | timer=new Timer(); 34 | this.no_delay=no_delay; 35 | this.pcepSessionManager=pcepSessionManager; 36 | } 37 | 38 | @Override 39 | public void run() { 40 | socket = null; 41 | boolean listening=true; 42 | 43 | try { 44 | while (listening){ 45 | log.info("New PCEP Session listening on 2222!"); 46 | //new RemoteLSPInitPCEPSession(socket, pcepSessionManager, crm).start(); 47 | this.sleep(1000); 48 | } 49 | socket.close(); 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } 53 | } 54 | 55 | @Override 56 | protected void endSession() { 57 | // TODO Auto-generated method stub 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/misc/Address.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.misc; 2 | 3 | public class Address { 4 | /**IP v4 Address in string format*/ 5 | private String ipv4Address; 6 | 7 | /**Port number associated witht he IPv4 Address */ 8 | private int port; 9 | 10 | /** 11 | * @return the ipv4Address 12 | */ 13 | public String getIpv4Address() { 14 | return ipv4Address; 15 | } 16 | 17 | /** 18 | * @param ipv4Address the ipv4Address to set 19 | */ 20 | public void setIpv4Address(String ipv4Address) { 21 | this.ipv4Address = ipv4Address; 22 | } 23 | 24 | /** 25 | * @return the port 26 | */ 27 | public int getPort() { 28 | return port; 29 | } 30 | 31 | /** 32 | * @param port the port to set 33 | */ 34 | public void setPort(int port) { 35 | this.port = port; 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/misc/AuthInfo.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.misc; 2 | 3 | public class AuthInfo { 4 | /**User ID to be used for authentication */ 5 | private String userID; 6 | 7 | /**password assicoated with the user ID*/ 8 | private String passwd; 9 | 10 | /** 11 | * @return the userID 12 | */ 13 | public String getUserID() { 14 | return userID; 15 | } 16 | 17 | /** 18 | * @param userID the userID to set 19 | */ 20 | public void setUserID(String userID) { 21 | this.userID = userID; 22 | } 23 | 24 | /** 25 | * @return the passwd 26 | */ 27 | public String getPasswd() { 28 | return passwd; 29 | } 30 | 31 | /** 32 | * @param passwd the passwd to set 33 | */ 34 | public void setPasswd(String passwd) { 35 | this.passwd = passwd; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/misc/IPAddressUtils.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.misc; 2 | 3 | public class IPAddressUtils { 4 | 5 | /**Parses input subnet and returns the longest prefix format*/ 6 | public static String parseSubnet(String input){ 7 | input=input.trim(); 8 | String temp = ""; 9 | if (input.length()<3){ 10 | int temp2 = Integer.parseInt(input); 11 | if ((temp2<=32) && (temp2 >=0)) 12 | temp=Integer.toString(temp2); 13 | } 14 | else { 15 | //input subnet is of type 255.255.255.0 16 | //Get binary String represenation of the individual blocks in the subnet and concatenate to get single represenation 17 | String finalString = ""; 18 | String[] temp1 = input.split("\\."); 19 | for (int i=0;i255) || (x<0)) 35 | { 36 | System.out.println("Error"); 37 | } 38 | String binaryString = ""; 39 | for (int i=0;i<8;i++){ 40 | int y= x%2; 41 | x=x/2; 42 | binaryString = y + binaryString; 43 | } 44 | 45 | return binaryString; 46 | 47 | } 48 | 49 | public static void main (String[] args){ 50 | System.out.println(parseSubnetDotFormat("16")); 51 | } 52 | 53 | public static String parseSubnetDotFormat(String input) { 54 | input=input.trim(); 55 | String temp = ""; 56 | if (input.length()<3){ 57 | int temp2 = Integer.parseInt(input); 58 | if ((temp2<=32) && (temp2 >=0)){ 59 | for (int i=0;i<4;i++){ 60 | if (temp2>=8){ 61 | temp+="255."; 62 | temp2=temp2-8; 63 | } 64 | else if (temp2==0){ 65 | temp+="0."; 66 | } 67 | else { 68 | int temp3 = 0; 69 | for (int j=0;j path; 22 | 23 | /**LSP Properties*/ 24 | private LabelSwitchedPathProperties lspProperties; 25 | 26 | /**Operation*/ 27 | private String operation; 28 | 29 | /**Default constructor*/ 30 | public LabelSwitchedPath(){} 31 | 32 | 33 | /**Constructor with parameters that initializes to an empty path*/ 34 | public LabelSwitchedPath(String lspId, String source, String destination, String pathName, LabelSwitchedPathProperties lspProperties){ 35 | 36 | this.lspId = lspId; 37 | this.source = source; 38 | this.destination = destination; 39 | this.path = new LinkedList(); 40 | this.lspProperties = lspProperties; 41 | this.pathName = pathName; 42 | } 43 | 44 | /** 45 | * @return the tunnelID 46 | */ 47 | public String lspId() { 48 | return lspId; 49 | } 50 | 51 | /** 52 | * @param tunnelID the tunnelID to set 53 | */ 54 | public void setTunnelID(String lspId) { 55 | this.lspId = lspId; 56 | } 57 | 58 | /** 59 | * @return the source 60 | */ 61 | public String getSource() { 62 | return source; 63 | } 64 | 65 | /** 66 | * @param source the source to set 67 | */ 68 | public void setSource(String source) { 69 | this.source = source; 70 | } 71 | 72 | /** 73 | * @return the destination 74 | */ 75 | public String getDestination() { 76 | return destination; 77 | } 78 | 79 | /** 80 | * @param destination the destination to set 81 | */ 82 | public void setDestination(String destination) { 83 | this.destination = destination; 84 | } 85 | 86 | public String getLspId() { 87 | return lspId; 88 | } 89 | 90 | public void setLspId(String lspId) { 91 | this.lspId = lspId; 92 | } 93 | 94 | public String getPathName() { 95 | return pathName; 96 | } 97 | 98 | public void setPathName(String pathName) { 99 | this.pathName = pathName; 100 | } 101 | 102 | public LinkedList getPath() { 103 | return path; 104 | } 105 | 106 | public void setPath(LinkedList path) { 107 | this.path = path; 108 | } 109 | 110 | public LabelSwitchedPathProperties getLspProperties() { 111 | return lspProperties; 112 | } 113 | 114 | public void setLspProperties(LabelSwitchedPathProperties lspProperties) { 115 | this.lspProperties = lspProperties; 116 | } 117 | 118 | public String getOperation() { 119 | return operation; 120 | } 121 | 122 | 123 | public void setOperation(String operation) { 124 | this.operation = operation; 125 | } 126 | 127 | 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/LabelSwitchedPath/LabelSwitchedPathProperties.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.LabelSwitchedPath; 2 | 3 | public class LabelSwitchedPathProperties { 4 | 5 | /** LSP signal bandwidth 6 | * 7 | * 10gigether 8 | * gigether 9 | * 10 | * 11 | */ 12 | 13 | private String signalBandwidth; 14 | 15 | /** LSP switching type 16 | * 17 | * fiber 18 | * lambda-switching 19 | * 20 | */ 21 | 22 | private String switchingType; 23 | 24 | /** LSP encoding type 25 | * 26 | * ethernet 27 | * 28 | */ 29 | 30 | private String encodingType; 31 | 32 | /** LSP gpid 33 | * 34 | * ethernet 35 | * 36 | */ 37 | 38 | private String gpid; 39 | 40 | /** Constructor with parameters */ 41 | public LabelSwitchedPathProperties(){} 42 | 43 | 44 | public LabelSwitchedPathProperties(String signalBandwidth, String switchingType, String encodingType, String gpid){ 45 | 46 | this.signalBandwidth = signalBandwidth; 47 | this.switchingType = switchingType; 48 | this.encodingType = encodingType; 49 | this.gpid = gpid; 50 | 51 | } 52 | 53 | public String getSignalBandwidth() { 54 | return signalBandwidth; 55 | } 56 | 57 | public void setSignalBandwidth(String signalBandwidth) { 58 | this.signalBandwidth = signalBandwidth; 59 | } 60 | 61 | public String getSwitchingType() { 62 | return switchingType; 63 | } 64 | 65 | public void setSwitchingType(String switchingType) { 66 | this.switchingType = switchingType; 67 | } 68 | 69 | public String getEncodingType() { 70 | return encodingType; 71 | } 72 | 73 | public void setEncodingType(String encodingType) { 74 | this.encodingType = encodingType; 75 | } 76 | 77 | public String getGpid() { 78 | return gpid; 79 | } 80 | 81 | public void setGpid(String gpid) { 82 | this.gpid = gpid; 83 | } 84 | 85 | 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/LabelSwitchedPath/LabelSwitchedPathWithUnnumIf.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.LabelSwitchedPath; 2 | 3 | import java.util.LinkedList; 4 | 5 | import es.tid.rsvp.objects.subobjects.EROSubobject; 6 | 7 | 8 | 9 | 10 | public class LabelSwitchedPathWithUnnumIf { 11 | 12 | /**LSP Identifier which is later on used as the Interface ID*/ 13 | private String lspId; 14 | 15 | /**Source IP address for the LSP*/ 16 | private String source; 17 | 18 | /**Destination IP address for the LSP*/ 19 | private String destination; 20 | 21 | /**Path Identifier*/ 22 | private String pathName; 23 | 24 | 25 | private LinkedList path; 26 | 27 | public LinkedList getPath() { 28 | return path; 29 | } 30 | 31 | 32 | public void setPath(LinkedList path) { 33 | this.path = path; 34 | } 35 | 36 | 37 | /**LSP Properties*/ 38 | private LabelSwitchedPathProperties lspProperties; 39 | 40 | /**Operation*/ 41 | private String operation; 42 | 43 | /**Default constructor*/ 44 | public LabelSwitchedPathWithUnnumIf(){} 45 | 46 | 47 | /**Constructor with parameters that initializes to an empty path*/ 48 | public LabelSwitchedPathWithUnnumIf(String lspId, String source, String destination, String pathName, LabelSwitchedPathProperties lspProperties){ 49 | 50 | this.lspId = lspId; 51 | this.source = source; 52 | this.destination = destination; 53 | 54 | this.lspProperties = lspProperties; 55 | this.pathName = pathName; 56 | } 57 | 58 | /** 59 | * @return the tunnelID 60 | */ 61 | public String lspId() { 62 | return lspId; 63 | } 64 | 65 | /** 66 | * @param tunnelID the tunnelID to set 67 | */ 68 | public void setTunnelID(String lspId) { 69 | this.lspId = lspId; 70 | } 71 | 72 | /** 73 | * @return the source 74 | */ 75 | public String getSource() { 76 | return source; 77 | } 78 | 79 | /** 80 | * @param source the source to set 81 | */ 82 | public void setSource(String source) { 83 | this.source = source; 84 | } 85 | 86 | /** 87 | * @return the destination 88 | */ 89 | public String getDestination() { 90 | return destination; 91 | } 92 | 93 | /** 94 | * @param destination the destination to set 95 | */ 96 | public void setDestination(String destination) { 97 | this.destination = destination; 98 | } 99 | 100 | public String getLspId() { 101 | return lspId; 102 | } 103 | 104 | public void setLspId(String lspId) { 105 | this.lspId = lspId; 106 | } 107 | 108 | public String getPathName() { 109 | return pathName; 110 | } 111 | 112 | public void setPathName(String pathName) { 113 | this.pathName = pathName; 114 | } 115 | 116 | 117 | 118 | public LabelSwitchedPathProperties getLspProperties() { 119 | return lspProperties; 120 | } 121 | 122 | public void setLspProperties(LabelSwitchedPathProperties lspProperties) { 123 | this.lspProperties = lspProperties; 124 | } 125 | 126 | public String getOperation() { 127 | return operation; 128 | } 129 | 130 | 131 | public void setOperation(String operation) { 132 | this.operation = operation; 133 | } 134 | 135 | 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/RouterDesc.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router; 2 | 3 | import java.net.Inet4Address; 4 | 5 | import es.tid.ipnms.datamodel.misc.AuthInfo; 6 | 7 | public class RouterDesc { 8 | 9 | /**ID for the router*/ 10 | protected String routerID; 11 | 12 | /**Description of the physical Location */ 13 | private String phyDesc; 14 | 15 | /**Addres for the configuration of the router*/ 16 | private Inet4Address managementAddress; 17 | 18 | private int configurationPort; 19 | 20 | /**Authentication Info for configuring the router*/ 21 | private AuthInfo authInfo; 22 | 23 | /**Router Vendor Type*/ 24 | private String routerType; 25 | 26 | /**IOS version*/ 27 | private String iosVersion; 28 | 29 | private String macAddress; 30 | /** 31 | * @return the routerID 32 | */ 33 | public String getRouterID() { 34 | return routerID; 35 | } 36 | /** 37 | * @param routerID the routerID to set 38 | */ 39 | public void setRouterID(String routerID) { 40 | this.routerID = routerID; 41 | } 42 | /** 43 | * @return the phyDesc 44 | */ 45 | public String getPhyDesc() { 46 | return phyDesc; 47 | } 48 | /** 49 | * @param phyDesc the phyDesc to set 50 | */ 51 | public void setPhyDesc(String phyDesc) { 52 | this.phyDesc = phyDesc; 53 | } 54 | /* *//** 55 | * @return the confAddress 56 | *//* 57 | public Address getConfAddress() { 58 | return confAddress; 59 | } 60 | *//** 61 | * @param confAddress the confAddress to set 62 | *//* 63 | public void setConfAddress(Address confAddress) { 64 | this.confAddress = confAddress; 65 | }*/ 66 | /** 67 | * @return the authInfo 68 | */ 69 | public AuthInfo getAuthInfo() { 70 | return authInfo; 71 | } 72 | /** 73 | * @param authInfo the authInfo to set 74 | */ 75 | public void setAuthInfo(AuthInfo authInfo) { 76 | this.authInfo = authInfo; 77 | } 78 | /** 79 | * @return the routerType 80 | */ 81 | public String getRouterType() { 82 | return routerType; 83 | } 84 | /** 85 | * @param routerType the routerType to set 86 | */ 87 | public void setRouterType(String routerType) { 88 | this.routerType = routerType; 89 | } 90 | /** 91 | * @return the iosVersion 92 | */ 93 | public String getIosVersion() { 94 | return iosVersion; 95 | } 96 | /** 97 | * @param iosVersion the iosVersion to set 98 | */ 99 | public void setIosVersion(String iosVersion) { 100 | this.iosVersion = iosVersion; 101 | } 102 | public Inet4Address getManagementAddress() { 103 | return managementAddress; 104 | } 105 | public void setManagementAddress(Inet4Address managementAddress) { 106 | this.managementAddress = managementAddress; 107 | } 108 | public int getConfigurationPort() { 109 | return configurationPort; 110 | } 111 | public void setConfigurationPort(int configurationPort) { 112 | this.configurationPort = configurationPort; 113 | } 114 | public String getMacAddress() { 115 | return macAddress; 116 | } 117 | public void setMacAddress(String macAddress) { 118 | this.macAddress = macAddress; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/routing/StaticRouteDesc.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.routing; 2 | 3 | import es.tid.ipnms.datamodel.misc.IPAddressUtils; 4 | 5 | public class StaticRouteDesc { 6 | /**Operation to add/del an IP route*/ 7 | private String operation; //add / delete 8 | 9 | /**Destination Network address */ 10 | private String destIP; 11 | /**Destination Subnet mask */ 12 | private String destSubnet; 13 | 14 | /**Next hop Interface ID*/ 15 | private String destIFID; //use one of the two i.e. IFID or IFIP 16 | 17 | /**Next Hop IP address */ 18 | private String nextHopIP; 19 | 20 | /** 21 | * @return the operation 22 | */ 23 | public String getOperation() { 24 | return operation; 25 | } 26 | 27 | /** 28 | * @param operation the operation to set 29 | */ 30 | public void setOperation(String operation) { 31 | this.operation = operation; 32 | } 33 | 34 | /** 35 | * @return the destIP 36 | */ 37 | public String getDestIP() { 38 | return destIP; 39 | } 40 | 41 | /** 42 | * @param destIP the destIP to set 43 | */ 44 | public void setDestIP(String destIP) { 45 | this.destIP = destIP; 46 | } 47 | 48 | /** 49 | * @return the destSubnet 50 | */ 51 | public String getDestSubnet() { 52 | return destSubnet; 53 | } 54 | 55 | /** 56 | * @return the destSubnet 57 | */ 58 | public String getDestSubnetDotFormat() { 59 | return IPAddressUtils.parseSubnetDotFormat(destSubnet); 60 | } 61 | 62 | /** 63 | * @param destSubnet the destSubnet to set 64 | */ 65 | public void setDestSubnet(String destSubnet) { 66 | this.destSubnet = IPAddressUtils.parseSubnet(destSubnet); 67 | } 68 | 69 | /** 70 | * @return the destIFID 71 | */ 72 | public String getDestIFID() { 73 | return destIFID; 74 | } 75 | 76 | /** 77 | * @param destIFID the destIFID to set 78 | */ 79 | public void setDestIFID(String destIFID) { 80 | this.destIFID = destIFID; 81 | } 82 | 83 | /** 84 | * @return the nextHopIP 85 | */ 86 | public String getNextHopIP() { 87 | return nextHopIP; 88 | } 89 | 90 | /** 91 | * @param nextHopIP the nextHopIP to set 92 | */ 93 | public void setNextHopIP(String nextHopIP) { 94 | this.nextHopIP = nextHopIP; 95 | } 96 | 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/routing/acl/ACLDesc.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.routing.acl; 2 | 3 | public class ACLDesc { 4 | 5 | /**ACL ID */ 6 | private String aclID; 7 | 8 | /**Operation (add delete) ACL*/ 9 | private String operation; 10 | 11 | /**Source IP for ACL filtering*/ 12 | private String sourceIP; 13 | 14 | /**Source Subnet for ACL filtering*/ 15 | private String sourceSubnet; 16 | 17 | /**Destination IP for subnet filtering*/ 18 | private String destIP; 19 | /**Destination Subnet for ACL filtering*/ 20 | private String destSubnet; 21 | 22 | /**protocol used */ 23 | private String protocol; 24 | 25 | /**destination port to be filtered*/ 26 | private int port; 27 | 28 | /** 29 | * @return the aclID 30 | */ 31 | public String getAclID() { 32 | return aclID; 33 | } 34 | 35 | /** 36 | * @param aclID the aclID to set 37 | */ 38 | public void setAclID(String aclID) { 39 | this.aclID = aclID; 40 | } 41 | 42 | /** 43 | * @return the operation 44 | */ 45 | public String getOperation() { 46 | return operation; 47 | } 48 | 49 | /** 50 | * @param operation the operation to set 51 | */ 52 | public void setOperation(String operation) { 53 | this.operation = operation; 54 | } 55 | 56 | /** 57 | * @return the sourceIP 58 | */ 59 | public String getSourceIP() { 60 | return sourceIP; 61 | } 62 | 63 | /** 64 | * @param sourceIP the sourceIP to set 65 | */ 66 | public void setSourceIP(String sourceIP) { 67 | this.sourceIP = sourceIP; 68 | } 69 | 70 | /** 71 | * @return the sourceSubnet 72 | */ 73 | public String getSourceSubnet() { 74 | return sourceSubnet; 75 | } 76 | 77 | /** 78 | * @param sourceSubnet the sourceSubnet to set 79 | */ 80 | public void setSourceSubnet(String sourceSubnet) { 81 | this.sourceSubnet = sourceSubnet; 82 | } 83 | 84 | /** 85 | * @return the destIP 86 | */ 87 | public String getDestIP() { 88 | return destIP; 89 | } 90 | 91 | /** 92 | * @param destIP the destIP to set 93 | */ 94 | public void setDestIP(String destIP) { 95 | this.destIP = destIP; 96 | } 97 | 98 | /** 99 | * @return the destSubnet 100 | */ 101 | public String getDestSubnet() { 102 | return destSubnet; 103 | } 104 | 105 | /** 106 | * @param destSubnet the destSubnet to set 107 | */ 108 | public void setDestSubnet(String destSubnet) { 109 | this.destSubnet = destSubnet; 110 | } 111 | 112 | /** 113 | * @return the protocol 114 | */ 115 | public String getProtocol() { 116 | return protocol; 117 | } 118 | 119 | /** 120 | * @param protocol the protocol to set 121 | */ 122 | public void setProtocol(String protocol) { 123 | this.protocol = protocol; 124 | } 125 | 126 | /** 127 | * @return the port 128 | */ 129 | public int getPort() { 130 | return port; 131 | } 132 | 133 | /** 134 | * @param port the port to set 135 | */ 136 | public void setPort(int port) { 137 | this.port = port; 138 | } 139 | 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/routing/acl/ForwardingRuleDesc.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.routing.acl; 2 | 3 | public class ForwardingRuleDesc { 4 | /**Operation (add/del) */ 5 | private String operation; // drop, forward 6 | 7 | /**Destination Interface to be forwarded on*/ 8 | private String destIF; 9 | 10 | /**nextHop IP to be forwarded on */ 11 | private String nextHopIP; 12 | 13 | /** 14 | * @return the operation 15 | */ 16 | public String getOperation() { 17 | return operation; 18 | } 19 | 20 | /** 21 | * @param operation the operation to set 22 | */ 23 | public void setOperation(String operation) { 24 | this.operation = operation; 25 | } 26 | 27 | /** 28 | * @return the destIF 29 | */ 30 | public String getDestIF() { 31 | return destIF; 32 | } 33 | 34 | /** 35 | * @param destIF the destIF to set 36 | */ 37 | public void setDestIF(String destIF) { 38 | this.destIF = destIF; 39 | } 40 | 41 | /** 42 | * @return the nextHopIP 43 | */ 44 | public String getNextHopIP() { 45 | return nextHopIP; 46 | } 47 | 48 | /** 49 | * @param nextHopIP the nextHopIP to set 50 | */ 51 | public void setNextHopIP(String nextHopIP) { 52 | this.nextHopIP = nextHopIP; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/router/routing/routingprotocol/RProtocolDesc.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.router.routing.routingprotocol; 2 | 3 | public class RProtocolDesc { 4 | /**Type of protocol used */ 5 | private String protocolType; //ospf RIP BGP 6 | 7 | /**Operation */ 8 | private String operation; 9 | 10 | /**process ID to be used for the configure operation*/ 11 | private int processID; 12 | 13 | /**network in which protocol should run*/ 14 | private String network; 15 | 16 | /**Subnet mask over which protocol should run*/ 17 | private String mask; 18 | 19 | /**Area ID {OSPF Specific}*/ 20 | private int areaID; 21 | 22 | /** 23 | * @return the protocolType 24 | */ 25 | public String getProtocolType() { 26 | return protocolType; 27 | } 28 | 29 | /** 30 | * @param protocolType the protocolType to set 31 | */ 32 | public void setProtocolType(String protocolType) { 33 | this.protocolType = protocolType; 34 | } 35 | 36 | /** 37 | * @return the operation 38 | */ 39 | public String getOperation() { 40 | return operation; 41 | } 42 | 43 | /** 44 | * @param operation the operation to set 45 | */ 46 | public void setOperation(String operation) { 47 | this.operation = operation; 48 | } 49 | 50 | /** 51 | * @return the processID 52 | */ 53 | public int getProcessID() { 54 | return processID; 55 | } 56 | 57 | /** 58 | * @param processID the processID to set 59 | */ 60 | public void setProcessID(int processID) { 61 | this.processID = processID; 62 | } 63 | 64 | /** 65 | * @return the network 66 | */ 67 | public String getNetwork() { 68 | return network; 69 | } 70 | 71 | /** 72 | * @param network the network to set 73 | */ 74 | public void setNetwork(String network) { 75 | this.network = network; 76 | } 77 | 78 | /** 79 | * @return the mask 80 | */ 81 | public String getMask() { 82 | return mask; 83 | } 84 | 85 | /** 86 | * @param mask the mask to set 87 | */ 88 | public void setMask(String mask) { 89 | this.mask = mask; 90 | } 91 | 92 | /** 93 | * @return the areaID 94 | */ 95 | public int getAreaID() { 96 | return areaID; 97 | } 98 | 99 | /** 100 | * @param areaID the areaID to set 101 | */ 102 | public void setAreaID(int areaID) { 103 | this.areaID = areaID; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/datamodel/utils/IPSubnetUtils.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.datamodel.utils; 2 | 3 | public class IPSubnetUtils { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/wsimpl/IPnmsWs.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.wsimpl; 2 | 3 | import es.tid.ipnms.datamodel.router.RouterDesc; 4 | import es.tid.ipnms.datamodel.router.GRETunnel.GRETunnelDesc; 5 | import es.tid.ipnms.datamodel.router.IPinterface.IPInterfaceConfig; 6 | import es.tid.ipnms.datamodel.router.IPinterface.IPInterfaceDesc; 7 | import es.tid.ipnms.datamodel.router.LabelSwitchedPath.LabelSwitchedPath; 8 | import es.tid.ipnms.datamodel.router.LabelSwitchedPath.LabelSwitchedPathWithUnnumIf; 9 | import es.tid.ipnms.datamodel.router.routing.StaticRouteDesc; 10 | import es.tid.ipnms.datamodel.router.routing.acl.ACLDesc; 11 | import es.tid.ipnms.datamodel.router.routing.acl.ForwardingRuleDesc; 12 | import es.tid.ipnms.datamodel.router.routing.routingprotocol.RProtocolDesc; 13 | 14 | public interface IPnmsWs { 15 | 16 | /**Service endpoint to configure IP interface*/ 17 | public int configureIPInterface(RouterDesc desc, IPInterfaceDesc ifDesc, IPInterfaceConfig config); 18 | 19 | 20 | /**Service endpoint to create a GRE tunnel Interface*/ 21 | public int createGREInterface (RouterDesc desc, GRETunnelDesc tunnDesc); 22 | 23 | /**Service endpoint to configure the routing protocol*/ 24 | public int configureRoutingProtocol(RouterDesc desc, RProtocolDesc rDesc); 25 | 26 | /**Service endpoint to configure a Static Route*/ 27 | public int configureStaticRoute(RouterDesc desc, StaticRouteDesc rDesc); 28 | 29 | 30 | /**Service endpoint to configure an ACL based static forwarding rule*/ 31 | public int configureACLStaticRoute(RouterDesc desc, ACLDesc aclDesc, ForwardingRuleDesc ruleDesc); 32 | 33 | 34 | /**Service endpoint to configure a Label Switched Path*/ 35 | public int configureLabelSwitchedPath(RouterDesc desc, LabelSwitchedPath lsp); 36 | 37 | /**Service endpoint to configure a Label Switched Path*/ 38 | public int configureLabelSwitchedPathWithUnnIf(RouterDesc desc, LabelSwitchedPathWithUnnumIf lsp); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/es/tid/ipnms/wsimpl/impl/JuniperOFImpl.java: -------------------------------------------------------------------------------- 1 | package es.tid.ipnms.wsimpl.impl; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import es.tid.ipnms.datamodel.router.RouterDesc; 7 | import es.tid.ipnms.datamodel.router.GRETunnel.GRETunnelDesc; 8 | import es.tid.ipnms.datamodel.router.IPinterface.IPInterfaceConfig; 9 | import es.tid.ipnms.datamodel.router.IPinterface.IPInterfaceDesc; 10 | import es.tid.ipnms.datamodel.router.LabelSwitchedPath.LabelSwitchedPath; 11 | import es.tid.ipnms.datamodel.router.LabelSwitchedPath.LabelSwitchedPathWithUnnumIf; 12 | import es.tid.ipnms.datamodel.router.routing.StaticRouteDesc; 13 | import es.tid.ipnms.datamodel.router.routing.acl.ACLDesc; 14 | import es.tid.ipnms.datamodel.router.routing.acl.ForwardingRuleDesc; 15 | import es.tid.ipnms.datamodel.router.routing.routingprotocol.RProtocolDesc; 16 | import es.tid.ipnms.wsimpl.IPnmsWs; 17 | import es.tid.provisioningManager.objects.openflow.PushFlowController; 18 | import es.tid.provisioningManager.objects.openflow.PushFlowFloodlight; 19 | import es.tid.provisioningManager.objects.openflow.StaticFlow; 20 | 21 | public class JuniperOFImpl implements IPnmsWs { 22 | private Logger log=LoggerFactory.getLogger("JuniperOFImpl"); 23 | @Override 24 | public int configureIPInterface(RouterDesc desc, IPInterfaceDesc ifDesc, 25 | IPInterfaceConfig config) { 26 | // TODO Auto-generated method stub 27 | return 0; 28 | } 29 | 30 | @Override 31 | public int createGREInterface(RouterDesc desc, GRETunnelDesc tunnDesc) { 32 | // TODO Auto-generated method stub 33 | return 0; 34 | } 35 | 36 | @Override 37 | public int configureRoutingProtocol(RouterDesc desc, RProtocolDesc rDesc) { 38 | // TODO Auto-generated method stub 39 | return 0; 40 | } 41 | 42 | @Override 43 | public int configureStaticRoute(RouterDesc desc, StaticRouteDesc rDesc) { 44 | // TODO Auto-generated method stub 45 | /*Comamands are sent to the controller*/ 46 | /*We need to find the MAC adddress of each router*/ 47 | /*Test lest send a curl*/ 48 | StaticFlow staticFlow = new StaticFlow(); 49 | staticFlow.setSwitchID("00:00:00:a0:a5:62:7b:4e"); 50 | staticFlow.setName("flow-mod-2"); 51 | staticFlow.setPriority(32768); 52 | staticFlow.setIngressPort("2"); 53 | staticFlow.setActive(true); 54 | staticFlow.setActions("output=1"); 55 | StaticFlow staticFlow2 = new StaticFlow(); 56 | staticFlow2.setSwitchID("00:00:00:a0:a5:62:7b:4e"); 57 | staticFlow2.setName("flow-mod-1"); 58 | staticFlow2.setPriority(32768); 59 | staticFlow2.setIngressPort("1"); 60 | staticFlow2.setActive(true); 61 | staticFlow2.setActions("output=2"); 62 | PushFlowController pushFlow = new PushFlowFloodlight(staticFlow,"172.16.1.3","8888"); 63 | log.info("Sending first Request"); 64 | pushFlow.sendRequest(); 65 | PushFlowController pushFlow2 = new PushFlowFloodlight(staticFlow2,"172.16.1.3","8888"); 66 | log.info("Sending second Request"); 67 | pushFlow2.sendRequest(); 68 | 69 | return 0; 70 | } 71 | 72 | @Override 73 | public int configureACLStaticRoute(RouterDesc desc, ACLDesc aclDesc, 74 | ForwardingRuleDesc ruleDesc) { 75 | // TODO Auto-generated method stub 76 | return 0; 77 | } 78 | 79 | @Override 80 | public int configureLabelSwitchedPath(RouterDesc desc, LabelSwitchedPath lsp) { 81 | // TODO Auto-generated method stub 82 | return 0; 83 | } 84 | 85 | @Override 86 | public int configureLabelSwitchedPathWithUnnIf(RouterDesc desc, 87 | LabelSwitchedPathWithUnnumIf lsp) { 88 | // TODO Auto-generated method stub 89 | return 0; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/NetworkLSPManagerTypes.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager; 2 | 3 | public class NetworkLSPManagerTypes { 4 | 5 | public static final int DUMMY_EMULATED_NETWORK = 1; 6 | public static final int SIMPLE_EMULATED_NETWORK = 2; 7 | public static final int ADVANCED_EMULATED_NETWORK = 3; 8 | public static final int COMPLETED_EMULATED_NETWORK = 4; 9 | 10 | public static final int UNI_EMULATED_NETWORK = 5; 11 | public static final int UNI_NETWORK = 6; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/OSPFSender.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager; 2 | 3 | import static es.tid.rocksaw.net.RawSocket.PF_INET; 4 | 5 | import java.io.IOException; 6 | import java.net.Inet4Address; 7 | import java.net.InetAddress; 8 | import java.util.LinkedList; 9 | import java.util.concurrent.LinkedBlockingQueue; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import es.tid.rocksaw.net.RawSocket; 14 | 15 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 16 | 17 | public class OSPFSender extends Thread { 18 | 19 | // Timeout para el socket 20 | private static final int TIMEOUT = 0; 21 | 22 | /** 23 | * Queue to read the messages to send to the PCE peer 24 | */ 25 | private LinkedBlockingQueue sendingQueue; 26 | Inet4Address address; 27 | LinkedList PCETEDBAddressList; 28 | Logger log=LoggerFactory.getLogger("OSPFParser"); 29 | public OSPFSender(LinkedList PCETEDBAddress, Inet4Address address){ 30 | sendingQueue= new LinkedBlockingQueue(); 31 | this.address=address; 32 | this.PCETEDBAddressList=PCETEDBAddress; 33 | } 34 | 35 | public void run(){ 36 | OSPFv2LinkStateUpdatePacket OSPF_msg; 37 | RawSocket socket = new RawSocket(); 38 | try{ 39 | socket.open(PF_INET, 89); 40 | socket.setUseSelectTimeout(true); 41 | socket.setSendTimeout(TIMEOUT); 42 | socket.setReceiveTimeout(TIMEOUT); 43 | //FIXME: ESTE BIND ESTA A FUEGO 44 | socket.bind(InetAddress.getByName("PCETEDBAddressList")); 45 | }catch(IOException e){ 46 | 47 | } 48 | while (true){ 49 | try { 50 | OSPF_msg=sendingQueue.take(); 51 | } catch (InterruptedException e) { 52 | log.error("Exception tying to take a OSPF message from the sendingQueue in OSPFSender."); 53 | return; 54 | } 55 | try { 56 | OSPF_msg.encode(); 57 | for (int i=0;i getSendingQueue() { 70 | return sendingQueue; 71 | } 72 | 73 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 74 | this.sendingQueue = sendingQueue; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/TCPOSPFSender.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | import java.net.Inet4Address; 6 | import java.net.Socket; 7 | import java.util.LinkedList; 8 | import java.util.concurrent.LinkedBlockingQueue; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 13 | 14 | public class TCPOSPFSender extends Thread { 15 | 16 | /** 17 | * Queue to read the messages to send to the PCE peer 18 | */ 19 | private LinkedBlockingQueue sendingQueue; 20 | private LinkedList sockList; 21 | private LinkedList out; 22 | Logger log=LoggerFactory.getLogger("OSPFParser"); 23 | 24 | public TCPOSPFSender(LinkedList dirPCEList, LinkedList portList){ 25 | if ((dirPCEList ==null)||(portList==null)) 26 | log.error("Error: Empty list (dirPCEList or portList) in TCPOSPFSender."); 27 | if (dirPCEList.size() != portList.size()) 28 | log.warn("Error: dirPCEList and portList with different size in TCPOSPFSender."); 29 | sendingQueue= new LinkedBlockingQueue(); 30 | sockList=new LinkedList(); 31 | out=new LinkedList(); 32 | 33 | for (int i=0;i getSendingQueue() { 75 | return sendingQueue; 76 | } 77 | 78 | 79 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 80 | this.sendingQueue = sendingQueue; 81 | } 82 | 83 | 84 | 85 | 86 | // public Inet4Address readPCEAddress(){ 87 | // 88 | // try { 89 | // return (Inet4Address) Inet4Address.getByName(vntmParams.getNetworkEmulatorPCEAddress().getHostAddress()); 90 | // } catch (UnknownHostException e) { 91 | // // TODO Auto-generated catch block 92 | // e.printStackTrace(); 93 | // } 94 | // 95 | // return null; 96 | // } 97 | 98 | // public int readOSPFTCPPort(){ 99 | // 100 | // // FIXME: Definir procedimiento de lectura de puerto 101 | // 102 | // return vntmParams.getVNTMPort(); 103 | // 104 | // } 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/emulated/DummyEmulatedNetworkLSPManager.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.emulated; 2 | 3 | 4 | import java.util.LinkedList; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.netManager.NetworkLSPManager; 9 | import es.tid.netManager.NetworkLSPManagerTypes; 10 | import es.tid.pce.pcep.objects.BandwidthRequestedGeneralizedBandwidth; 11 | import es.tid.rsvp.objects.subobjects.EROSubobject; 12 | 13 | 14 | public class DummyEmulatedNetworkLSPManager extends NetworkLSPManager{ 15 | 16 | boolean multilayer=false; 17 | private Logger log= LoggerFactory.getLogger("PCCClient"); 18 | public DummyEmulatedNetworkLSPManager(){ 19 | this.setEmulatorType(NetworkLSPManagerTypes.DUMMY_EMULATED_NETWORK); 20 | 21 | 22 | 23 | 24 | } 25 | @Override 26 | public boolean setLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 27 | // TODO Auto-generated method stub 28 | log.info("Setting LSP with ERO: "+erolist.toString()); 29 | 30 | 31 | return true; 32 | } 33 | 34 | @Override 35 | public boolean setMLLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 36 | // TODO Auto-generated method stub 37 | return true; 38 | } 39 | 40 | @Override 41 | public void removeLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 42 | // TODO Auto-generated method stub 43 | log.info("REmoving LSP with ERO: "+erolist.toString()); 44 | } 45 | 46 | @Override 47 | public void removeMLLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 48 | // TODO Auto-generated method stub 49 | 50 | } 51 | @Override 52 | public void removeLSP(LinkedList erolist, boolean bidirect, 53 | BandwidthRequestedGeneralizedBandwidth GB, float bw) { 54 | // TODO Auto-generated method stub 55 | 56 | } 57 | @Override 58 | public boolean setLSP_UpperLayer( 59 | LinkedList eROSubobjectListIP, float bw, 60 | boolean bidirect) { 61 | // TODO Auto-generated method stub 62 | return false; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/emulated/EmulatedUniNetworkLSPManager.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.emulated; 2 | 3 | import java.util.LinkedList; 4 | 5 | import es.tid.netManager.NetworkLSPManager; 6 | import es.tid.netManager.NetworkLSPManagerTypes; 7 | import es.tid.pce.pcep.objects.BandwidthRequestedGeneralizedBandwidth; 8 | import es.tid.rsvp.objects.subobjects.EROSubobject; 9 | 10 | public class EmulatedUniNetworkLSPManager extends NetworkLSPManager{ 11 | public EmulatedUniNetworkLSPManager(){ 12 | this.setEmulatorType(NetworkLSPManagerTypes.UNI_EMULATED_NETWORK); 13 | } 14 | @Override 15 | public boolean setLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 16 | // TODO Auto-generated method stub 17 | return false; 18 | } 19 | 20 | @Override 21 | public boolean setMLLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 22 | // TODO Auto-generated method stub 23 | return false; 24 | } 25 | 26 | @Override 27 | public void removeLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 28 | // TODO Auto-generated method stub 29 | 30 | } 31 | 32 | @Override 33 | public void removeMLLSP(LinkedList erolist, boolean bidirect, BandwidthRequestedGeneralizedBandwidth GB) { 34 | // TODO Auto-generated method stub 35 | 36 | } 37 | @Override 38 | public void removeLSP(LinkedList erolist, boolean bidirect, 39 | BandwidthRequestedGeneralizedBandwidth GB, float bw) { 40 | // TODO Auto-generated method stub 41 | 42 | } 43 | @Override 44 | public boolean setLSP_UpperLayer( 45 | LinkedList eROSubobjectListIP, float bw, 46 | boolean bidirect) { 47 | // TODO Auto-generated method stub 48 | return false; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/emulated/LayerTypes.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.emulated; 2 | 3 | public class LayerTypes { 4 | /** 5 | 0 = Simple network without layer 6 | 1 = Lower Layer 7 | 2 = Upper Layer 8 | 3 = Inter Layer 9 | 10 | */ 11 | public static final int SIMPLE_NETWORK = 0; 12 | public static final int LOWER_LAYER = 1; 13 | public static final int UPPER_LAYER = 2; 14 | public static final int INTER_LAYER = 3; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/uni/ChangeIPRoute.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.uni; 2 | 3 | import java.net.Inet4Address; 4 | 5 | public class ChangeIPRoute extends DispatcherObjects{ 6 | 7 | private Inet4Address nodeToChange; 8 | private Inet4Address destination; 9 | private Inet4Address previousNextHop; 10 | private Inet4Address nextNextHop; 11 | 12 | public ChangeIPRoute(Inet4Address nodeToChange, Inet4Address destination, Inet4Address previousNextHop, Inet4Address nextNextHop){ 13 | 14 | this.nodeToChange = nodeToChange; 15 | this.destination = destination; 16 | this.previousNextHop = previousNextHop; 17 | this.nextNextHop = nextNextHop; 18 | super.setType(1); 19 | 20 | } 21 | 22 | public boolean executeChange(){ 23 | 24 | return true; 25 | 26 | } 27 | 28 | public Inet4Address getDestination() { 29 | return destination; 30 | } 31 | 32 | public void setDestination(Inet4Address destination) { 33 | this.destination = destination; 34 | } 35 | 36 | public Inet4Address getPreviousNextHop() { 37 | return previousNextHop; 38 | } 39 | 40 | public void setPreviousNextHop(Inet4Address previousNextHop) { 41 | this.previousNextHop = previousNextHop; 42 | } 43 | 44 | public Inet4Address getNextNextHop() { 45 | return nextNextHop; 46 | } 47 | 48 | public void setNextNextHop(Inet4Address nextNextHop) { 49 | this.nextNextHop = nextNextHop; 50 | } 51 | 52 | public Inet4Address getNodeToChange() { 53 | return nodeToChange; 54 | } 55 | 56 | public void setNodeToChange(Inet4Address nodeToChange) { 57 | this.nodeToChange = nodeToChange; 58 | } 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/uni/CreateLSP.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.uni; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.LinkedList; 5 | 6 | public class CreateLSP extends DispatcherObjects{ 7 | 8 | private Inet4Address nodeToChange; 9 | private String interfaz; 10 | private String lspName; 11 | private LinkedList path; 12 | 13 | 14 | public CreateLSP(Inet4Address nodeToChange, String interfaz, String lspName, LinkedList path){ 15 | 16 | this.nodeToChange = nodeToChange; 17 | this.interfaz = interfaz; 18 | this.lspName = lspName; 19 | this.path = path; 20 | super.setType(4); 21 | 22 | } 23 | 24 | public boolean executeChange(){ 25 | 26 | return true; 27 | 28 | } 29 | 30 | public Inet4Address getNodeToChange() { 31 | return nodeToChange; 32 | } 33 | 34 | public void setNodeToChange(Inet4Address nodeToChange) { 35 | this.nodeToChange = nodeToChange; 36 | } 37 | 38 | public String getInterfaz() { 39 | return interfaz; 40 | } 41 | 42 | public void setInterfaz(String interfaz) { 43 | this.interfaz = interfaz; 44 | } 45 | 46 | public String getLspName() { 47 | return lspName; 48 | } 49 | 50 | public void setLspName(String lspName) { 51 | this.lspName = lspName; 52 | } 53 | 54 | public LinkedList getPath() { 55 | return path; 56 | } 57 | 58 | public void setPath(LinkedList path) { 59 | this.path = path; 60 | } 61 | 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/uni/DeleteLSP.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.uni; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.LinkedList; 5 | 6 | public class DeleteLSP extends DispatcherObjects{ 7 | 8 | private Inet4Address nodeToChange; 9 | private String interfaz; 10 | private String lspName; 11 | private LinkedList path; 12 | 13 | 14 | public DeleteLSP(Inet4Address nodeToChange, String interfaz, String lspName, LinkedList path){ 15 | 16 | this.nodeToChange = nodeToChange; 17 | this.interfaz = interfaz; 18 | this.lspName = lspName; 19 | this.path = path; 20 | super.setType(5); 21 | 22 | } 23 | 24 | public boolean executeChange(){ 25 | 26 | return true; 27 | 28 | } 29 | 30 | public Inet4Address getNodeToChange() { 31 | return nodeToChange; 32 | } 33 | 34 | public void setNodeToChange(Inet4Address nodeToChange) { 35 | this.nodeToChange = nodeToChange; 36 | } 37 | 38 | public String getInterfaz() { 39 | return interfaz; 40 | } 41 | 42 | public void setInterfaz(String interfaz) { 43 | this.interfaz = interfaz; 44 | } 45 | 46 | public String getLspName() { 47 | return lspName; 48 | } 49 | 50 | public void setLspName(String lspName) { 51 | this.lspName = lspName; 52 | } 53 | 54 | public LinkedList getPath() { 55 | return path; 56 | } 57 | 58 | public void setPath(LinkedList path) { 59 | this.path = path; 60 | } 61 | 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/es/tid/netManager/uni/DispatcherObjects.java: -------------------------------------------------------------------------------- 1 | package es.tid.netManager.uni; 2 | 3 | public class DispatcherObjects { 4 | 5 | /** 6 | * Type = 1 --- Change Route 7 | * Type = 2 --- Create UNI 8 | * Type = 3 --- Eliminate UNI 9 | * Type = 4 --- Create LSP 10 | */ 11 | 12 | private int type; 13 | 14 | public int getType() { 15 | return type; 16 | } 17 | 18 | public void setType(int type) { 19 | this.type = type; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/emulator/PrintStatistics.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.emulator; 2 | 3 | import java.util.TimerTask; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | 8 | 9 | /** 10 | * Print statistics to write in a file the emulation statistics 11 | * Es una tarea que se ejecutara externamente 12 | * @author mcs 13 | * 14 | */ 15 | public class PrintStatistics extends TimerTask { 16 | 17 | AutomaticTesterStatistics ats; 18 | private Logger statsLog; 19 | 20 | public PrintStatistics(AutomaticTesterStatistics ats){ 21 | statsLog=LoggerFactory.getLogger("stats"); 22 | this.ats=ats; 23 | } 24 | 25 | public void run(){ 26 | statsLog.info(ats.print()); 27 | } 28 | 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/management/AutomaticTesterManagementSever.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.management; 2 | 3 | import java.net.ServerSocket; 4 | import java.util.Timer; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 9 | import es.tid.pce.client.emulator.Emulator; 10 | import es.tid.pce.client.tester.InformationRequest; 11 | 12 | public class AutomaticTesterManagementSever extends Thread { 13 | 14 | private Logger log; 15 | 16 | private Timer timer; 17 | private Timer printStatisticsTimer; 18 | // private Timer planificationTimer; 19 | private AutomaticTesterStatistics stats; 20 | 21 | 22 | private InformationRequest informationRequest; 23 | 24 | private Emulator emulator; 25 | 26 | // private PCCPCEPSession PCEsession; 27 | // private PCCPCEPSession PCEsessionVNTM; 28 | 29 | 30 | 31 | public AutomaticTesterManagementSever(/*PCCPCEPSession PCEsession,PCCPCEPSession PCEsessionVNTM,*/Timer timer, Timer printStatisticsTimer, /*Timer planificationTimer,*/AutomaticTesterStatistics stats, InformationRequest info){ 32 | log =LoggerFactory.getLogger("PCCClient"); 33 | this.timer = timer; 34 | this.stats=stats; 35 | this.informationRequest=info; 36 | this.printStatisticsTimer =printStatisticsTimer; 37 | // this.planificationTimer=planificationTimer; 38 | // this.PCEsession=PCEsession; 39 | // this.PCEsessionVNTM=PCEsessionVNTM; 40 | 41 | } 42 | 43 | public AutomaticTesterManagementSever(Emulator emulator){ 44 | log =LoggerFactory.getLogger("PCCClient"); 45 | this.emulator=emulator; 46 | } 47 | 48 | 49 | public void run(){ 50 | ServerSocket serverSocket = null; 51 | boolean listening=true; 52 | int port =emulator.getTesterParams().getManagementClientPort(); 53 | try { 54 | log.info("Listening on port "+port); 55 | serverSocket = new ServerSocket(port); 56 | } 57 | catch (Exception e){ 58 | log.error("Could not listen management on port "+port); 59 | e.printStackTrace(); 60 | return; 61 | } 62 | 63 | try { 64 | while (listening) { 65 | if (emulator==null) 66 | new AutomaticTesterManagementSession(serverSocket.accept(),timer,printStatisticsTimer,stats,/*PCEsession,PCEsessionVNTM,*/informationRequest,informationRequest.calculateLoad()).start(); 67 | else 68 | new AutomaticTesterManagementSession(serverSocket.accept(),emulator); 69 | } 70 | serverSocket.close(); 71 | } catch (Exception e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/management/StopManagement.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.management; 2 | 3 | import java.util.TimerTask; 4 | 5 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 6 | import es.tid.pce.client.emulator.Emulator; 7 | 8 | public class StopManagement extends TimerTask { 9 | 10 | private long blocksNumber; 11 | 12 | private AutomaticTesterStatistics ats; 13 | 14 | private int numberIterations; 15 | private Emulator emulator; 16 | 17 | public StopManagement(Emulator emulator,int numberIterations, long blocksNumber,AutomaticTesterStatistics ats){ 18 | this.blocksNumber=blocksNumber; 19 | this.numberIterations=numberIterations; 20 | this.ats=ats; 21 | this.emulator=emulator; 22 | } 23 | 24 | public void run(){ 25 | if (/*(stopConditionBlockProbabilityConvergence())||*/(maxNumberIterations()))/*(stopCondition(Long.parseLong(ats.getBlockProbability().result())))||*/{ 26 | emulator.stop(); 27 | } 28 | } 29 | // public boolean stopCondition(Long blocksNumber){ 30 | // Long longs = Long.valueOf(this.blocksNumber); 31 | // if (blocksNumber.compareTo(longs) ){ 32 | // return true; 33 | // } 34 | // return false; 35 | // } 36 | public boolean stopConditionBlockProbabilityConvergence(){ 37 | if (ats.getBlockProbability().getConverge() == 1){ 38 | return true; 39 | } 40 | return false; 41 | } 42 | public boolean stopConditionMeanReqTimeConvergence(){ 43 | if (ats.getMeanReqTime().getConverge() == 1){ 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | 50 | public boolean maxNumberIterations(){ 51 | if (this.numberIterations < ats.getNumRequests()){ 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/multiDomain/AutomaticTesterSpainNetwork.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.multiDomain; 2 | import java.util.Timer; 3 | 4 | import es.tid.pce.client.PCCPCEPSession; 5 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 6 | 7 | 8 | /** 9 | * Testeador de caminos 10 | * @author Marta Cuaresma Saturio 11 | * 12 | */ 13 | public class AutomaticTesterSpainNetwork { 14 | 15 | private static int PCEServerPort = 4183; 16 | private static String ipPCE = "localhost"; 17 | private static PCCPCEPSession PCEsession; 18 | private static long timeProcessing = 10000; 19 | /** 20 | * @param args 21 | */ 22 | public static void main(String[] args) { 23 | /*If there are arguments, read the PCEServerPort and ipPCE*/ 24 | if (args.length < 2) { 25 | System.out.println("Usage: ClientTester "); 26 | return; 27 | } 28 | 29 | ipPCE = args[0]; 30 | PCEServerPort = Integer.valueOf(args[1]).intValue(); 31 | PCEsession = new PCCPCEPSession(ipPCE, PCEServerPort,false, new PCEPSessionsInformation()); 32 | PCEsession.start(); 33 | /*Creo mi testeador*/ 34 | AutomaticTesterSpainNetworkTask srt= new AutomaticTesterSpainNetworkTask(PCEsession,PCEsession.getPeerPCE_port()); 35 | Timer timer=new Timer(); 36 | timer.schedule(srt, 0,timeProcessing); 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/multiDomain/CreateSpainNetwork.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.multiDomain; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.PrintWriter; 6 | import java.net.Inet4Address; 7 | 8 | import javax.xml.parsers.DocumentBuilder; 9 | import javax.xml.parsers.DocumentBuilderFactory; 10 | 11 | import org.w3c.dom.CharacterData; 12 | import org.w3c.dom.Document; 13 | import org.w3c.dom.Element; 14 | import org.w3c.dom.Node; 15 | import org.w3c.dom.NodeList; 16 | 17 | 18 | public class CreateSpainNetwork { 19 | public static void main(String[] args){ 20 | File readFile = new File(args[0]); 21 | FileWriter writeFile = null; 22 | PrintWriter pw = null; 23 | try { 24 | writeFile = new FileWriter("D:/PCE/Spain_Network.txt"); 25 | pw = new PrintWriter(writeFile); 26 | 27 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 28 | Document doc = builder.parse(readFile); 29 | 30 | NodeList nodes_domains = doc.getElementsByTagName("domain"); 31 | 32 | for (int j = 0; j < nodes_domains.getLength(); j++) { 33 | 34 | NodeList edges = doc.getElementsByTagName("edge"); 35 | for (int i = 0; i < edges.getLength(); i++) { 36 | 37 | Element element = (Element) edges.item(i); 38 | 39 | NodeList source = element.getElementsByTagName("source"); 40 | Element source_router_el = (Element) source.item(0); 41 | NodeList source_router_id = source_router_el.getElementsByTagName("router_id"); 42 | Element source_router_id_el = (Element) source_router_id.item(0); 43 | String s_r_id = getCharacterDataFromElement(source_router_id_el); 44 | Inet4Address s_router_id_addr = (Inet4Address) Inet4Address.getByName(s_r_id); 45 | pw.append("("+String.valueOf(i)+","); 46 | pw.append(String.valueOf(s_router_id_addr.hashCode())+","); 47 | 48 | NodeList dest_nl = element 49 | .getElementsByTagName("destination"); 50 | Element dest_el = (Element) dest_nl.item(0); 51 | NodeList dest_router_id_nl = dest_el 52 | .getElementsByTagName("router_id"); 53 | Element dest_router_id_el = (Element) dest_router_id_nl 54 | .item(0); 55 | String d_r_id = getCharacterDataFromElement(dest_router_id_el); 56 | 57 | Inet4Address d_router_id_addr = (Inet4Address) Inet4Address.getByName(d_r_id); 58 | pw.append(String.valueOf(d_router_id_addr.hashCode())+","); 59 | 60 | pw.println("1,0,0,0,80),"); 61 | 62 | 63 | } 64 | } 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | finally { 69 | try { 70 | // Nuevamente aprovechamos el finally para 71 | // asegurarnos que se cierra el fichero. 72 | if (null != writeFile) 73 | writeFile.close(); 74 | } catch (Exception e2) { 75 | e2.printStackTrace(); 76 | } 77 | } 78 | } 79 | public static String getCharacterDataFromElement(Element e) { 80 | Node child = e.getFirstChild(); 81 | if (child instanceof CharacterData) { 82 | CharacterData cd = (CharacterData) child; 83 | return cd.getData(); 84 | } else { 85 | return "?"; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/Activity.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import es.tid.emulator.node.transport.EmulatedPCCPCEPSession; 4 | import es.tid.netManager.NetworkLSPManager; 5 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 6 | import es.tid.pce.pcep.messages.PCEPRequest; 7 | import es.tid.pce.pcep.messages.PCEPResponse; 8 | import es.tid.vntm.LigthPathManagement; 9 | 10 | /** 11 | * Interface to describe an activity you can simulate in the client. The posible activities are: 12 | * - NetworkEmulator 13 | * - VNTM 14 | * @author mcs 15 | * 16 | */ 17 | public interface Activity extends Runnable{ 18 | 19 | public void addVNTMSession(EmulatedPCCPCEPSession VNTMSession); 20 | public void addNetworkEmulator(NetworkLSPManager networkLSPManager); 21 | public void addStatistics(AutomaticTesterStatistics stats); 22 | public void addRequest(PCEPRequest request); 23 | public void addResponse(PCEPResponse response); 24 | public void addPCEsessionVNTM(EmulatedPCCPCEPSession vNTMSession); 25 | public void addLigthPathManagement(LigthPathManagement ligthPathManagement); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/AutomaticTesterNetworkTask.java: -------------------------------------------------------------------------------- 1 | 2 | package es.tid.pce.client.tester; 3 | 4 | 5 | import java.util.TimerTask; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import es.tid.emulator.node.transport.EmulatedPCCPCEPSession; 10 | import es.tid.pce.client.ClientRequestManager; 11 | import es.tid.pce.pcep.messages.PCEPMessage; 12 | import es.tid.pce.pcep.messages.PCEPMonReq; 13 | import es.tid.pce.pcep.messages.PCEPRequest; 14 | import es.tid.pce.pcep.messages.PCEPResponse; 15 | 16 | 17 | public class AutomaticTesterNetworkTask extends TimerTask { 18 | 19 | private ClientRequestManager crm; 20 | private Logger log; 21 | private boolean PCMonReqBool; 22 | static long requestID=123; 23 | 24 | /*Variable used for counter how many requests there are*/ 25 | 26 | PCEPMessage request; 27 | AutomaticTesterNetworkTask(PCEPMessage request,EmulatedPCCPCEPSession ps,boolean PCMonReqBool){ 28 | this.request = request; 29 | log=LoggerFactory.getLogger("PCCClient"); 30 | this.crm=ps.crm; 31 | this.PCMonReqBool = PCMonReqBool; 32 | } 33 | 34 | 35 | 36 | @Override 37 | public void run() { 38 | log.info("Starting Automatic Client Interface"); 39 | PCEPResponse pr; 40 | if (PCMonReqBool){ 41 | pr=crm.newRequest((PCEPMonReq)this.request); 42 | }else { 43 | pr=crm.newRequest((PCEPRequest)this.request); 44 | requestID++; 45 | } 46 | }//End run 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/ClientSendTopologyConfiguration.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import javax.xml.parsers.SAXParser; 8 | import javax.xml.parsers.SAXParserFactory; 9 | 10 | import org.xml.sax.Attributes; 11 | import org.xml.sax.SAXException; 12 | import org.xml.sax.SAXParseException; 13 | import org.xml.sax.helpers.DefaultHandler; 14 | 15 | /** 16 | * Parametros de configuracion 17 | * @author mcs 18 | * 19 | */ 20 | public class ClientSendTopologyConfiguration { 21 | private int PCEServerPort; 22 | private String ipPCE = "localhost"; 23 | private long time_ms; 24 | 25 | private Logger log; 26 | 27 | ClientSendTopologyConfiguration(String readFile){ 28 | try{ 29 | SAXParserFactory factory = SAXParserFactory.newInstance(); 30 | SAXParser saxParser = factory.newSAXParser(); 31 | SaxHandler handler = new SaxHandler(); 32 | 33 | saxParser.parse(readFile, handler); 34 | } 35 | catch (Exception e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | public int getPCEServerPort() { 40 | return PCEServerPort; 41 | } 42 | 43 | public void setPCEServerPort(int pCEServerPort) { 44 | PCEServerPort = pCEServerPort; 45 | } 46 | 47 | public String getIpPCE() { 48 | return ipPCE; 49 | } 50 | 51 | public void setIpPCE(String ipPCE) { 52 | this.ipPCE = ipPCE; 53 | } 54 | 55 | 56 | 57 | public long getTime_ms() { 58 | return time_ms; 59 | } 60 | 61 | public void setTime_ms(long time_ms) { 62 | this.time_ms = time_ms; 63 | } 64 | 65 | 66 | class SaxHandler extends DefaultHandler { 67 | String tempVal; 68 | public void startElement(String uri, String localName,String qName, Attributes attrs) 69 | throws SAXParseException,SAXException { 70 | 71 | 72 | } 73 | public void endElement(String uri, String localName,String qName) throws SAXException { 74 | log = LoggerFactory.getLogger("PCCClient"); 75 | try{ 76 | log.info("End Element :" + qName); 77 | if (qName.equalsIgnoreCase("ipPCE")){ 78 | ipPCE = tempVal.trim(); 79 | } 80 | else if (qName.equalsIgnoreCase("PCEServerPort")){ 81 | PCEServerPort = Integer.parseInt(tempVal.trim()); 82 | } 83 | 84 | else if (qName.equalsIgnoreCase("time_ms")){ 85 | time_ms=Long.valueOf(tempVal.trim()); 86 | } 87 | 88 | 89 | }catch (Exception e) { 90 | e.printStackTrace(); 91 | } 92 | 93 | 94 | } 95 | 96 | public void characters(char ch[], int start, int length) throws SAXException { 97 | tempVal = new String(ch,start,length); 98 | 99 | 100 | } 101 | }//End DefaultHandler 102 | 103 | 104 | 105 | 106 | 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/LSPConfirmationDispatcher.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.util.Timer; 4 | import java.util.concurrent.LinkedBlockingQueue; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import cern.jet.random.Exponential; 9 | import es.tid.netManager.NetworkLSPManager; 10 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 11 | import es.tid.pce.pcep.constructs.Path; 12 | import es.tid.tedb.DomainTEDB; 13 | 14 | 15 | public class LSPConfirmationDispatcher { 16 | 17 | private LinkedBlockingQueue pathList; 18 | 19 | private Logger log; 20 | 21 | private DomainTEDB tedb; 22 | 23 | private NetworkLSPManager networkLSPManager; 24 | 25 | private AutomaticTesterStatistics stats; 26 | private Exponential connectionTime; 27 | private Timer planificationTimer; 28 | private int IDLSP; 29 | 30 | public LSPConfirmationDispatcher(DomainTEDB tedb, NetworkLSPManager networkLSPManager, 31 | AutomaticTesterStatistics stats){ 32 | pathList=new LinkedBlockingQueue(); 33 | this.stats=stats; 34 | this.tedb=tedb; 35 | this.networkLSPManager= networkLSPManager; 36 | 37 | } 38 | 39 | public void dispatchLSPConfirmation(Path path, int IDlsp){ 40 | if (IDlsp == -1){ 41 | stats.addStolenLambdasLSP(); 42 | stats.analyzeLambdaBlockingProbability(1); 43 | stats.analyzeBlockingProbability(1); 44 | } 45 | else 46 | pathList.add(path); 47 | } 48 | 49 | public Exponential getConnectionTime() { 50 | return connectionTime; 51 | } 52 | 53 | public void setConnectionTime(Exponential connectionTime) { 54 | this.connectionTime = connectionTime; 55 | 56 | LSPConfirmationProcessorThread npt=new LSPConfirmationProcessorThread(pathList,tedb, networkLSPManager, 57 | stats, connectionTime, planificationTimer); 58 | 59 | npt.start(); 60 | log=LoggerFactory.getLogger("PCCclient"); 61 | } 62 | 63 | public Timer getPlanificationTimer() { 64 | return planificationTimer; 65 | } 66 | 67 | public void setPlanificationTimer(Timer planificationTimer) { 68 | this.planificationTimer = planificationTimer; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/PCCPCEPSessionParameters.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.util.Hashtable; 4 | 5 | public class PCCPCEPSessionParameters { 6 | private Hashtable PCEServerPortList; 7 | private Hashtable ipPCEList; 8 | private boolean noDelay = true; 9 | /** 10 | * Numero de PCEP sesiones que abrimos entre clientes y PCES 11 | */ 12 | private int numSessions=1; 13 | 14 | 15 | public Hashtable getPCEServerPortList() { 16 | return PCEServerPortList; 17 | } 18 | public void setPCEServerPortList(Hashtable pCEServerPortList) { 19 | PCEServerPortList = pCEServerPortList; 20 | } 21 | public Hashtable getIpPCEList() { 22 | return ipPCEList; 23 | } 24 | public void setIpPCEList(Hashtable ipPCEList) { 25 | this.ipPCEList = ipPCEList; 26 | } 27 | public boolean isNoDelay() { 28 | return noDelay; 29 | } 30 | public void setNoDelay(boolean noDelay) { 31 | this.noDelay = noDelay; 32 | } 33 | public int getNumSessions() { 34 | return numSessions; 35 | } 36 | public void setNumSessions(int numSessions) { 37 | this.numSessions = numSessions; 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/RealiseCapacityTask.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | 4 | import java.util.LinkedList; 5 | import java.util.TimerTask; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import es.tid.netManager.NetworkLSPManager; 10 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 11 | import es.tid.pce.pcep.objects.BandwidthRequestedGeneralizedBandwidth; 12 | import es.tid.rsvp.objects.subobjects.EROSubobject; 13 | 14 | 15 | 16 | public class RealiseCapacityTask extends TimerTask { 17 | 18 | private Logger log; 19 | private BandwidthRequestedGeneralizedBandwidth GB; 20 | private AutomaticTesterStatistics stats; 21 | private LinkedList erolist; 22 | private NetworkLSPManager networkLSPManager; 23 | private boolean bidirectional; 24 | private float bw; 25 | private boolean VirtualTELink=false; 26 | 27 | public RealiseCapacityTask(NetworkLSPManager networkLSPManager, LinkedList erolist,AutomaticTesterStatistics stats, boolean bidirectional, BandwidthRequestedGeneralizedBandwidth GB){ 28 | log=LoggerFactory.getLogger("PCCClient"); 29 | this.stats=stats; 30 | this.erolist=erolist; 31 | this.GB=GB; 32 | this.networkLSPManager=networkLSPManager; 33 | this.bidirectional=bidirectional; 34 | 35 | } 36 | 37 | public RealiseCapacityTask(NetworkLSPManager networkLSPManager, LinkedList erolist,AutomaticTesterStatistics stats, boolean bidirectional, BandwidthRequestedGeneralizedBandwidth GB, 38 | float bw, boolean VirtualTELink){ 39 | log=LoggerFactory.getLogger("PCCClient"); 40 | this.stats=stats; 41 | this.erolist=erolist; 42 | this.GB=GB; 43 | this.networkLSPManager=networkLSPManager; 44 | this.bidirectional=bidirectional; 45 | this.bw=bw; 46 | this.VirtualTELink=VirtualTELink; 47 | } 48 | 49 | @Override 50 | public void run() { 51 | log.info("Deleting LSP, releasing capacity "+erolist.toString()); 52 | if (stats != null) 53 | stats.releaseNumberActiveLSP(); 54 | if (VirtualTELink) 55 | networkLSPManager.removeLSP(erolist,bidirectional,GB,bw); 56 | else 57 | networkLSPManager.removeLSP(erolist,bidirectional,GB); 58 | 59 | }//End run 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/RealiseControlPlaneCapacityTask.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | 4 | import java.util.LinkedList; 5 | import java.util.TimerTask; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import es.tid.emulator.node.transport.EmulatedPCCPCEPSession; 10 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 11 | import es.tid.pce.pcep.constructs.UpdateRequest; 12 | import es.tid.pce.pcep.messages.PCEPUpdate; 13 | import es.tid.pce.pcep.objects.BandwidthRequestedGeneralizedBandwidth; 14 | import es.tid.pce.pcep.objects.LSP; 15 | 16 | public class RealiseControlPlaneCapacityTask extends TimerTask { 17 | 18 | private Logger log; 19 | private BandwidthRequestedGeneralizedBandwidth GB; 20 | private AutomaticTesterStatistics stats; 21 | private LinkedList lspList; 22 | private boolean bidirectional; 23 | private EmulatedPCCPCEPSession PCEPsession; 24 | 25 | 26 | public RealiseControlPlaneCapacityTask(LinkedList lspList,AutomaticTesterStatistics stats, boolean bidirectional, BandwidthRequestedGeneralizedBandwidth GB 27 | , EmulatedPCCPCEPSession PCEPsession){ 28 | log=LoggerFactory.getLogger("PCCClient"); 29 | this.stats=stats; 30 | this.lspList=lspList; 31 | this.GB=GB; 32 | this.bidirectional=bidirectional; 33 | this.PCEPsession=PCEPsession; 34 | } 35 | 36 | @Override 37 | public void run() { 38 | log.info("Deleting LSP, releasing capacity "+lspList.getFirst().getLspId()); 39 | if (stats != null) 40 | stats.releaseNumberActiveLSP(); 41 | 42 | //FIXME: hacer bien el borrado 43 | // Create Message Upd 44 | PCEPUpdate updMssg = new PCEPUpdate(); 45 | LinkedList urList = new LinkedList (); 46 | UpdateRequest ur = new UpdateRequest(); 47 | ur.setLsp(lspList.getFirst()); 48 | 49 | urList.add(ur); 50 | updMssg.setUpdateRequestList(urList); 51 | System.out.println("Enviamos un mensaje de borrado de LSP"); 52 | if (PCEPsession == null){ 53 | log.info("PCEP Sesion Null salimos!"); 54 | System.exit(-1); 55 | }if (updMssg == null){ 56 | log.info("El mensaje a enviar es null"); 57 | } 58 | PCEPsession.crm.sendPCEPMessage(updMssg); 59 | 60 | }//End run 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/RealiseMLCapacityTask.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.io.OutputStreamWriter; 6 | import java.net.Inet4Address; 7 | import java.net.Socket; 8 | import java.net.UnknownHostException; 9 | import java.util.ArrayList; 10 | import java.util.TimerTask; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | import es.tid.pce.client.emulator.AutomaticTesterStatistics; 15 | import es.tid.pce.pcep.messages.PCEPRequest; 16 | import es.tid.pce.pcep.messages.PCEPTELinkTearDownSuggestion; 17 | import es.tid.pce.pcep.objects.EndPointsIPv4; 18 | 19 | 20 | 21 | public class RealiseMLCapacityTask extends TimerTask { 22 | 23 | private Logger log; 24 | private ArrayList sourceList; 25 | private ArrayList destinationList; 26 | private AutomaticTesterStatistics stats; 27 | 28 | /*Variable used for counter how many requests there are*/ 29 | 30 | PCEPRequest request; 31 | 32 | 33 | public RealiseMLCapacityTask(ArrayList sourceList, ArrayList destinationList,AutomaticTesterStatistics stats ){ 34 | log=LoggerFactory.getLogger("PCCClient"); 35 | this.sourceList = sourceList; 36 | this.destinationList=destinationList; 37 | this.stats=stats; 38 | } 39 | 40 | @Override 41 | public void run() { 42 | log.info("Deleting LSP, releasing capacity"); 43 | if (stats != null){ 44 | stats.releaseNumberActiveLSP(); 45 | } 46 | String s1; 47 | EndPointsIPv4 endPointsIPv4 = new EndPointsIPv4(); 48 | for (int i =0; i metricList; 13 | private float bw; 14 | private boolean bandwidth = false; 15 | private long timeReserved; 16 | boolean bidirectional=false; 17 | boolean isVariableBandwidth=false; 18 | 19 | int priority; 20 | boolean reoptimization; 21 | boolean loose; 22 | 23 | 24 | public boolean isBidirectional() { 25 | return bidirectional; 26 | } 27 | public void setBidirectional(boolean bidirectional) { 28 | this.bidirectional = bidirectional; 29 | } 30 | public int getPriority() { 31 | return priority; 32 | } 33 | public void setPriority(int priority) { 34 | this.priority = priority; 35 | } 36 | public boolean isReoptimization() { 37 | return reoptimization; 38 | } 39 | public void setReoptimization(boolean reoptimization) { 40 | this.reoptimization = reoptimization; 41 | } 42 | public boolean isLoose() { 43 | return loose; 44 | } 45 | public void setLoose(boolean loose) { 46 | this.loose = loose; 47 | } 48 | public LinkedList getMetricList() { 49 | return metricList; 50 | } 51 | public void setMetricList(LinkedList metricList) { 52 | this.metricList = metricList; 53 | } 54 | public float getBW() { 55 | return bw; 56 | } 57 | public void setBW(float bw) { 58 | this.bw = bw; 59 | } 60 | public long getTimeReserved() { 61 | return timeReserved; 62 | } 63 | public boolean isVariableBandwidth() { 64 | return isVariableBandwidth; 65 | } 66 | public void setVariableBandwidth(boolean isVariableBanwidth) { 67 | this.isVariableBandwidth = isVariableBanwidth; 68 | } 69 | public boolean Is_bandwidth() { 70 | return bandwidth; 71 | } 72 | public void setBandwidth(boolean Bandwidth) { 73 | bandwidth = Bandwidth; 74 | } 75 | public void setTimeReserved(long timeReserved) { 76 | this.timeReserved = timeReserved; 77 | } 78 | public boolean isOf() { 79 | return of; 80 | } 81 | public void setOf(boolean of) { 82 | this.of = of; 83 | } 84 | public boolean isReservation() { 85 | return isReservation; 86 | } 87 | public void setReservation(boolean isReservation) { 88 | this.isReservation = isReservation; 89 | } 90 | 91 | public int getOfCode() { 92 | return ofCode; 93 | } 94 | public void setOfCode(int ofCode) { 95 | this.ofCode = ofCode; 96 | } 97 | public boolean isDelayMetric() { 98 | return delayMetric; 99 | } 100 | public void setDelayMetric(boolean delayMetric) { 101 | this.delayMetric = delayMetric; 102 | } 103 | @Override 104 | public String toString() { 105 | // TODO Auto-generated method stub 106 | return "bidirectional:"+bidirectional; 107 | } 108 | 109 | 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/RequestToSend.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.net.Inet4Address; 4 | 5 | 6 | public class RequestToSend { 7 | Inet4Address source; 8 | Inet4Address destiny; 9 | RequestParametersConfiguration requestParameters; 10 | 11 | 12 | public Inet4Address getSource() { 13 | return source; 14 | } 15 | public void setSource(Inet4Address source) { 16 | this.source = source; 17 | } 18 | public Inet4Address getDestiny() { 19 | return destiny; 20 | } 21 | public void setDestiny(Inet4Address destiny) { 22 | this.destiny = destiny; 23 | } 24 | public RequestParametersConfiguration getRequestParameters() { 25 | return requestParameters; 26 | } 27 | public void setRequestParameters(RequestParametersConfiguration requestParameters) { 28 | this.requestParameters = requestParameters; 29 | } 30 | @Override 31 | public String toString() { 32 | // TODO Auto-generated method stub 33 | return "Source: "+source.toString()+"Destiny: "+destiny.toString(); 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/SendTopologyClientTask.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.util.TimerTask; 4 | 5 | import es.tid.netManager.NetworkLSPManager; 6 | 7 | public class SendTopologyClientTask extends TimerTask { 8 | private NetworkLSPManager networkLSPManager; 9 | SendTopologyClientTask( NetworkLSPManager networkLSPManager){ 10 | this.networkLSPManager=networkLSPManager; 11 | } 12 | @Override 13 | public void run() { 14 | // TODO Auto-generated method stub 15 | 16 | networkLSPManager.sendAllTopology(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/StatefulSession.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.net.Socket; 7 | 8 | import es.tid.pce.pcep.messages.PCEPMessageTypes; 9 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 10 | 11 | public class StatefulSession { 12 | 13 | 14 | public static void main (String[] args) { 15 | 16 | try { 17 | Runtime.getRuntime().exec("clear"); 18 | } catch (IOException e) { 19 | // TODO Auto-generated catch block 20 | e.printStackTrace(); 21 | } 22 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 23 | 24 | System.out.println("Statefull PCE Session"); 25 | System.out.println("Please get PCEPSession Info:"); 26 | System.out.print("PCE IP:"); 27 | 28 | 29 | 30 | String ip = null; 31 | try { 32 | ip = br.readLine(); 33 | } catch (IOException ioe) { 34 | System.out.println("IO error"); 35 | System.exit(1); 36 | } 37 | 38 | System.out.print("PCE Port:"); 39 | 40 | 41 | 42 | String port = null; 43 | int portnumber=0; 44 | try { 45 | port = br.readLine(); 46 | portnumber=Integer.parseInt(port); 47 | } catch (IOException ioe) { 48 | System.out.println("IO error"); 49 | System.exit(1); 50 | } 51 | 52 | System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); 53 | StatefulPCEPSession vntmsession=null; 54 | 55 | try { 56 | Socket s = new Socket(ip, portnumber); 57 | PCEPSessionsInformation pcepsessioninfo=new PCEPSessionsInformation(); 58 | pcepsessioninfo.setActive(true); 59 | pcepsessioninfo.setStateful(false); 60 | vntmsession = new StatefulPCEPSession( s,pcepsessioninfo, PCEPMessageTypes.MESSAGE_INITIATE); 61 | vntmsession.start(); 62 | } 63 | catch(Exception e){ 64 | e.printStackTrace(); 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/restoration/RestorationCaseInformation.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester.restoration; 2 | 3 | import java.net.Inet4Address; 4 | 5 | public class RestorationCaseInformation { 6 | private Inet4Address source; 7 | private Inet4Address destination; 8 | private long timeToWait; 9 | public Inet4Address getSource() { 10 | return source; 11 | } 12 | public void setSource(Inet4Address source) { 13 | this.source = source; 14 | } 15 | public Inet4Address getDestination() { 16 | return destination; 17 | } 18 | public void setDestination(Inet4Address destination) { 19 | this.destination = destination; 20 | } 21 | public long getTimeToWait() { 22 | return timeToWait; 23 | } 24 | public void setTimeToWait(long timeToWait) { 25 | this.timeToWait = timeToWait; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/es/tid/pce/client/tester/restoration/RestorationCaseTable.java: -------------------------------------------------------------------------------- 1 | package es.tid.pce.client.tester.restoration; 2 | 3 | import java.net.Inet4Address; 4 | import java.util.ArrayList; 5 | 6 | import es.tid.pce.pcep.constructs.Response; 7 | 8 | public class RestorationCaseTable { 9 | 10 | Inet4Address source; 11 | Inet4Address destination; 12 | int idPath; 13 | Response response; 14 | ArrayList path; 15 | Inet4Address initialNodePath; 16 | Inet4Address finalNodePath; 17 | 18 | 19 | public Inet4Address getInitialNodePath() { 20 | return initialNodePath; 21 | } 22 | public void setInitialNodePath(Inet4Address initialNodePath) { 23 | this.initialNodePath = initialNodePath; 24 | } 25 | public Inet4Address getFinalNodePath() { 26 | return finalNodePath; 27 | } 28 | public void setFinalNodePath(Inet4Address finalNodePath) { 29 | this.finalNodePath = finalNodePath; 30 | } 31 | public int getIdPath() { 32 | return idPath; 33 | } 34 | public void setIdPath(int idPath) { 35 | this.idPath = idPath; 36 | } 37 | public Inet4Address getSource() { 38 | return source; 39 | } 40 | public void setSource(Inet4Address source) { 41 | this.source = source; 42 | } 43 | public Inet4Address getDestination() { 44 | return destination; 45 | } 46 | public void setDestination(Inet4Address destination) { 47 | this.destination = destination; 48 | } 49 | 50 | public boolean isTheSameLink(Inet4Address source, Inet4Address destination){ 51 | return (this.source.equals(source)) && (this.destination.equals(destination)); 52 | } 53 | 54 | public Response getResponse() { 55 | return response; 56 | } 57 | public void setResponse(Response response) { 58 | this.response = response; 59 | } 60 | 61 | public ArrayList getPath() { 62 | return path; 63 | } 64 | public void setPath(ArrayList path) { 65 | this.path = path; 66 | } 67 | @Override 68 | public boolean equals(Object obj) { 69 | // TODO Auto-generated method stub 70 | return ((((RestorationCaseTable)obj).getSource().equals(source)) && (((RestorationCaseTable)obj).getDestination().equals(destination))); 71 | 72 | } 73 | @Override 74 | public String toString() { 75 | // TODO Auto-generated method stub 76 | return "Path number: "+ idPath +" Link: "+source.toString()+" - "+destination.toString(); 77 | } 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/es/tid/provisioningManager/objects/openflow/PushFlowController.java: -------------------------------------------------------------------------------- 1 | package es.tid.provisioningManager.objects.openflow; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import org.eclipse.jetty.client.ContentExchange; 8 | import org.eclipse.jetty.client.HttpClient; 9 | import org.eclipse.jetty.http.HttpMethods; 10 | import org.eclipse.jetty.io.ByteArrayBuffer; 11 | import org.json.JSONObject; 12 | 13 | public class PushFlowController { 14 | 15 | StaticFlow flow = new StaticFlow(); 16 | 17 | 18 | String directory; 19 | String url; 20 | Logger log=LoggerFactory.getLogger("PushFlow"); 21 | 22 | public PushFlowController(StaticFlow flow,String ip, String port) 23 | { 24 | this.flow = flow; 25 | } 26 | 27 | 28 | public void sendRequest() 29 | { 30 | log.info("Sending request to controller at "+ url + " with content" + generateJSON().toString()); 31 | //Call ALTO Server Ep 32 | ByteArrayBuffer inputStream; 33 | ContentExchange contentExchange = new ContentExchange(); 34 | try 35 | { 36 | inputStream = new ByteArrayBuffer(generateJSON().toString(), "UTF-8"); 37 | contentExchange.setRequestContent(inputStream); 38 | contentExchange.setURL(url); 39 | contentExchange.setMethod(HttpMethods.POST); 40 | } 41 | catch (UnsupportedEncodingException e) 42 | { 43 | // TODO Auto-generated catch block 44 | e.printStackTrace(); 45 | } 46 | 47 | HttpClient httpClient = new HttpClient(); 48 | //set up httpClient 49 | try 50 | { 51 | httpClient.start(); 52 | } 53 | catch (Exception e) 54 | { 55 | // TODO Auto-generated catch block 56 | e.printStackTrace(); 57 | } 58 | 59 | httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); 60 | try 61 | { 62 | httpClient.send(contentExchange); 63 | contentExchange.waitForDone(); 64 | } 65 | catch (Exception e) 66 | { 67 | // TODO Auto-generated catch block 68 | e.printStackTrace(); 69 | } 70 | System.err.println("Response status: "+ contentExchange.getResponseStatus()); 71 | try 72 | { 73 | System.err.print(contentExchange.getResponseContent()); 74 | } 75 | catch (UnsupportedEncodingException e) 76 | { 77 | // TODO Auto-generated catch block 78 | e.printStackTrace(); 79 | } 80 | } 81 | 82 | 83 | //To be implemented for each controller 84 | public JSONObject generateJSON() 85 | { 86 | return null; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/provisioningManager/objects/openflow/PushFlowFloodlight.java: -------------------------------------------------------------------------------- 1 | package es.tid.provisioningManager.objects.openflow; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PushFlowFloodlight extends PushFlowController { 6 | 7 | 8 | public PushFlowFloodlight(StaticFlow flow,String ip, String port) 9 | { 10 | super(flow,ip,port); 11 | this.directory = "/wm/staticflowentrypusher/json"; 12 | this.url="http://"+ip+":"+port+directory; 13 | } 14 | 15 | 16 | 17 | 18 | @Override 19 | public JSONObject generateJSON() 20 | { 21 | log.info("inside generateJSON"); 22 | JSONObject requestJSON = new JSONObject(); 23 | requestJSON.put("switch", this.flow.getSwitchID()); 24 | requestJSON.put("name", this.flow.getName()); 25 | requestJSON.put("priority", flow.getPriority()); 26 | 27 | 28 | if (this.flow.getIngressPort() != null) 29 | { 30 | requestJSON.put("ingress-port", this.flow.getIngressPort()); 31 | } 32 | 33 | requestJSON.put("active", this.flow.getActive()); 34 | 35 | if (this.flow.getSrcMAC() != null) 36 | { 37 | requestJSON.put("src-mac", this.flow.getSrcMAC()); 38 | } 39 | 40 | if (this.flow.getDstMAC() != null) 41 | { 42 | requestJSON.put("dst-mac", this.flow.getDstMAC()); 43 | } 44 | 45 | String actions = ""; 46 | 47 | if (!this.flow.getVlan_id().equals(StaticFlow.noVlan)) 48 | { 49 | actions = "set-vlan-id=" + this.flow.getVlan_id() + ","; 50 | } 51 | 52 | for (int i = 0; i < this.flow.getPorts().size(); i++) 53 | { 54 | if (i == 0) 55 | { 56 | actions += "output=" + this.flow.getPorts().get(i); 57 | } 58 | else 59 | { 60 | actions += ",output=" + this.flow.getPorts().get(i); 61 | } 62 | } 63 | 64 | requestJSON.put("actions", actions); 65 | 66 | if (flow.getVlan_priority() != null) 67 | { 68 | requestJSON.put("vlan-priority", this.flow.getVlan_priority()); 69 | } 70 | //requestJSON.put("vlan-id", this.flow.getVlan_id()); 71 | return requestJSON; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/es/tid/provisioningManager/objects/openflow/PushFlowRYU.java: -------------------------------------------------------------------------------- 1 | package es.tid.provisioningManager.objects.openflow; 2 | 3 | import org.json.JSONObject; 4 | import org.json.simple.JSONArray; 5 | 6 | public class PushFlowRYU extends PushFlowController { 7 | 8 | 9 | 10 | 11 | public PushFlowRYU(StaticFlow flow,String ip, String port) 12 | { 13 | super(flow,ip,port); 14 | this.directory = "/stats/flowentry/add"; 15 | this.url="http://"+ip+":"+port+directory; 16 | } 17 | 18 | 19 | 20 | 21 | 22 | @Override 23 | public JSONObject generateJSON() 24 | { 25 | JSONObject requestJSON = new JSONObject(); 26 | Long l16 = Long.parseLong(this.flow.getSwitchID().replace(":",""),16); 27 | 28 | requestJSON.put("dpid", l16.toString()); 29 | requestJSON.put("priority", flow.getPriority()); 30 | requestJSON.put("name", this.flow.getName()); 31 | 32 | 33 | JSONObject match = new JSONObject(); 34 | match.put("dl_src", flow.getSrcMAC().replace(":", "")); 35 | match.put("dl_dst", flow.getDstMAC().replace(":", "")); 36 | match.put("in_port", flow.getIngressPort()); 37 | //match.put("out_port", flow.getIngressPort()); 38 | //match.put("tp_src", flow.getIngressPort()); 39 | 40 | requestJSON.put("match", match); 41 | 42 | JSONArray actions = new JSONArray(); 43 | 44 | if (!this.flow.getVlan_id().equals(StaticFlow.noVlan)) 45 | { 46 | JSONObject vlan = new JSONObject(); 47 | vlan.put("type", "SET_VLAN_VID"); 48 | vlan.put("vlan_vid", this.flow.getVlan_id()); 49 | actions.add(vlan); 50 | } 51 | 52 | for (int i = 0; i < this.flow.getPorts().size(); i++) 53 | { 54 | JSONObject port = new JSONObject(); 55 | port.put("type", "OUTPUT"); 56 | port.put("port", this.flow.getPorts().get(i)); 57 | actions.add(port); 58 | } 59 | 60 | requestJSON.put("actions", actions); 61 | 62 | return requestJSON; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/es/tid/provisioningManager/objects/openflow/StaticFlow.java: -------------------------------------------------------------------------------- 1 | package es.tid.provisioningManager.objects.openflow; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class StaticFlow { 6 | /*http://www.openflowhub.org/display/floodlightcontroller/Static+Flow+Pusher+API+%28New%29*/ 7 | 8 | public static String noVlan = "0"; 9 | 10 | /** 11 | * ID of the switch (data path) that this rule should be added to 12 | * xx:xx:xx:xx:xx:xx:xx:xx 13 | * * 14 | **/ 15 | private String switchID; 16 | /** 17 | * Name of the flow entry, this is the primary key, it MUST be unique 18 | */ 19 | private String name; 20 | 21 | /** 22 | * Deprecated variable actions. Now the actions is stored in the ports and vlan_id variables 23 | */ 24 | private String actions; 25 | /** 26 | * default is 32767 27 | * maximum value is 32767 28 | **/ 29 | private int priority = 32767; 30 | 31 | private Boolean active; 32 | /** 33 | * switch port on which the packet is received 34 | * Can be hexadecimal (with leading 0x) or decimal 35 | * 36 | */ 37 | private String ingressPort ; 38 | /** 39 | * Can be hexadecimal (with leading 0x) or decimal 40 | */ 41 | private int ethertype; 42 | /** 43 | * xx.xx.xx.xx 44 | */ 45 | private int srcIp ; 46 | /** 47 | * xx.xx.xx.xx 48 | */ 49 | private int dstIp ; 50 | 51 | /** 52 | * xx.xx.xx.xx.xx.xx 53 | */ 54 | private String srcMAC ; 55 | /** 56 | * xx.xx.xx.xx.xx.xx 57 | */ 58 | private String dstMAC ; 59 | 60 | private String vlan_id = StaticFlow.noVlan; 61 | 62 | private String vlan_priority = null; 63 | 64 | private ArrayList ports = new ArrayList(); 65 | 66 | 67 | /** 68 | * Getters and Setters 69 | **/ 70 | public String getSwitchID() { 71 | return switchID; 72 | } 73 | public void setSwitchID(String switchID) { 74 | this.switchID = switchID; 75 | } 76 | public String getName() { 77 | return name; 78 | } 79 | public void setName(String name) { 80 | this.name = name; 81 | } 82 | public String getActions() { 83 | return actions; 84 | } 85 | public void setActions(String actions) { 86 | this.actions = actions; 87 | } 88 | public int getPriority() { 89 | return priority; 90 | } 91 | public void setPriority(int priority) { 92 | this.priority = priority; 93 | } 94 | public Boolean getActive() { 95 | return active; 96 | } 97 | public void setActive(Boolean active) { 98 | this.active = active; 99 | } 100 | public String getIngressPort() { 101 | return ingressPort; 102 | } 103 | public void setIngressPort(String ingressPort) { 104 | this.ingressPort = ingressPort; 105 | } 106 | public int getEthertype() { 107 | return ethertype; 108 | } 109 | public void setEthertype(int ethertype) { 110 | this.ethertype = ethertype; 111 | } 112 | public int getSrcIp() { 113 | return srcIp; 114 | } 115 | public void setSrcIp(int srcIp) { 116 | this.srcIp = srcIp; 117 | } 118 | public int getDstIp() { 119 | return dstIp; 120 | } 121 | public void setDstIp(int dstIp) { 122 | this.dstIp = dstIp; 123 | } 124 | public String getSrcMAC() { 125 | return srcMAC; 126 | } 127 | public void setSrcMAC(String srcMAC) { 128 | this.srcMAC = srcMAC; 129 | } 130 | public String getDstMAC() { 131 | return dstMAC; 132 | } 133 | public void setDstMAC(String dstMAC) { 134 | this.dstMAC = dstMAC; 135 | } 136 | public String getVlan_id() { 137 | return vlan_id; 138 | } 139 | public void setVlan_id(String vlan_id) { 140 | this.vlan_id = vlan_id; 141 | } 142 | public String getVlan_priority() { 143 | return vlan_priority; 144 | } 145 | public void setVlan_priority(String vlan_priority) { 146 | this.vlan_priority = vlan_priority; 147 | } 148 | public ArrayList getPorts() { 149 | return ports; 150 | } 151 | public void setPorts(ArrayList ports) { 152 | this.ports = ports; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/main/java/es/tid/test/InterfaceDisable.java: -------------------------------------------------------------------------------- 1 | package es.tid.test; 2 | 3 | import es.tid.ipnms.wsimpl.impl.IdaTelnetClientPrueba; 4 | 5 | 6 | public class InterfaceDisable { 7 | 8 | /** 9 | * Info: Este código desabilita la interfaz especificada dentro del Juniper especificado 10 | * @param args 11 | */ 12 | public static void main(String[] args) { 13 | // TODO Auto-generated method stub 14 | String router=args[0]; 15 | String intf=args[1]; 16 | String operation=args[2]; 17 | IdaTelnetClientPrueba telnetClient = new IdaTelnetClientPrueba(true, new String[] {"#", ":", ">"}); 18 | 19 | 20 | String ip= returnManagmentAddress(router); 21 | if (ip!=null){ 22 | System.out.println("Router: "+router+" IP: "+ip+" Interface: "+intf); 23 | try { 24 | telnetClient.connect(ip, 23); 25 | //login to the router 26 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("tid" + "\r")); 27 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("Juniper" + "\r")); 28 | 29 | String response = telnetClient.send("\n\r"); 30 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + response ); 31 | 32 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("configure \r")); 33 | if (operation.equals("enable")) 34 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("delete interfaces "+intf+" disable \r")); 35 | else if (operation.equals("disable")) 36 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("set interfaces "+intf+" disable \r")); 37 | 38 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("commit \r")); 39 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 40 | //System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 41 | telnetClient.close(); 42 | }catch (Exception e){ 43 | e.printStackTrace(); 44 | } 45 | } 46 | } 47 | 48 | private static String returnManagmentAddress(String router) { 49 | if (router.equals("MX240-1")) 50 | return "10.95.73.72"; 51 | if (router.equals("MX240-2")) 52 | return "10.95.73.73"; 53 | if (router.equals("MX240-3")) 54 | return "10.95.73.74"; 55 | System.out.println("Error en el nombre del router"); 56 | return null; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/es/tid/test/PCEClient.java: -------------------------------------------------------------------------------- 1 | package es.tid.test; 2 | 3 | import java.net.Inet4Address; 4 | 5 | import es.tid.emulator.node.transport.EmulatedPCCPCEPSession; 6 | import es.tid.pce.client.ClientRequestManager; 7 | import es.tid.pce.pcep.constructs.Request; 8 | import es.tid.pce.pcep.messages.PCEPRequest; 9 | import es.tid.pce.pcep.messages.PCEPResponse; 10 | import es.tid.pce.pcep.objects.BandwidthRequested; 11 | import es.tid.pce.pcep.objects.EndPointsIPv4; 12 | import es.tid.pce.pcep.objects.ObjectiveFunction; 13 | import es.tid.pce.pcep.objects.RequestParameters; 14 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 15 | 16 | public class PCEClient { 17 | 18 | /** 19 | * @param args 20 | */ 21 | public static void main(String[] args) { 22 | // TODO Auto-generated method stub 23 | try{ 24 | String ipOpcticSourceString=args[0]; 25 | String ipOpticDestString=args[1]; 26 | String bandw=args[2]; 27 | Inet4Address ipOpcticSource=(Inet4Address) Inet4Address.getByName(ipOpcticSourceString); 28 | Inet4Address ipOpticDest=(Inet4Address) Inet4Address.getByName(ipOpticDestString); 29 | 30 | PCEPSessionsInformation pcepSessionManagerPCE=new PCEPSessionsInformation(); 31 | EmulatedPCCPCEPSession PCEsession = new EmulatedPCCPCEPSession("localhost", 4189 ,false,pcepSessionManagerPCE); 32 | PCEsession.start(); 33 | Thread.currentThread().sleep(1000); 34 | ClientRequestManager crm = PCEsession.crm; 35 | if (PCEsession.getOut()==null) 36 | System.out.println("La salida esta a null, algo raro pasa..."); 37 | crm.setDataOutputStream(PCEsession.getOut()); 38 | 39 | System.out.println("Enviamos de: "+ipOpcticSource+" a "+ipOpticDest); 40 | 41 | PCEPRequest p_r = new PCEPRequest(); 42 | Request req = new Request(); 43 | p_r.addRequest(req); 44 | RequestParameters rp= new RequestParameters(); 45 | rp.setPbit(true); 46 | req.setRequestParameters(rp); 47 | rp.setRequestID(EmulatedPCCPCEPSession.getNewReqIDCounter()); 48 | //EndPointsIPv4 ep=new EndPointsIPv4(); 49 | EndPointsIPv4 ep= new EndPointsIPv4(); 50 | req.setEndPoints(ep); 51 | ep.setSourceIP(ipOpcticSource); 52 | ep.setDestIP(ipOpticDest); 53 | 54 | 55 | ObjectiveFunction of=new ObjectiveFunction(); 56 | of.setOFcode(1200); 57 | req.setObjectiveFunction(of); 58 | 59 | 60 | float bw = Float.parseFloat(bandw); 61 | BandwidthRequested bandwidth=new BandwidthRequested(); 62 | bandwidth.setBw(bw); 63 | req.setBandwidth(bandwidth); 64 | 65 | 66 | PCEPResponse pr=crm.newRequest(p_r); 67 | System.out.println("OJO!! Respuesta de PCE: "+pr.toString()); 68 | }catch (Exception e) { 69 | e.printStackTrace(); 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/es/tid/test/ReactivateInterface.java: -------------------------------------------------------------------------------- 1 | package es.tid.test; 2 | 3 | import es.tid.ipnms.wsimpl.impl.IdaTelnetClientPrueba; 4 | 5 | 6 | public class ReactivateInterface { 7 | 8 | /** 9 | * Info: Este código desabilita la interfaz especificada dentro del Juniper especificado 10 | * @param args 11 | */ 12 | public static void main(String[] args) { 13 | // TODO Auto-generated method stub 14 | String router=args[0]; 15 | String intf=args[1]; 16 | IdaTelnetClientPrueba telnetClient = new IdaTelnetClientPrueba(true, new String[] {"#", ":", ">"}); 17 | 18 | 19 | String ip= returnManagmentAddress(router); 20 | if (ip!=null){ 21 | System.out.println("Router: "+router+" IP: "+ip+" Interface: "+intf); 22 | try { 23 | telnetClient.connect(ip, 23); 24 | //login to the router 25 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("tid" + "\r")); 26 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("Juniper" + "\r")); 27 | 28 | String response = telnetClient.send("\n\r"); 29 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + response ); 30 | 31 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("configure \r")); 32 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("deactivate interfaces "+intf+" \r")); 33 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("commit \r")); 34 | 35 | System.out.println("********************* Deactivating Interface *******************"); 36 | Thread.sleep(2000); 37 | 38 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("activate interfaces "+intf+" \r")); 39 | System.out.println("********************* Activating Interface *******************"); 40 | 41 | 42 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("commit \r")); 43 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 44 | //System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 45 | telnetClient.close(); 46 | }catch (Exception e){ 47 | e.printStackTrace(); 48 | } 49 | } 50 | } 51 | 52 | private static String returnManagmentAddress(String router) { 53 | if (router.equals("MX240-1")) 54 | return "10.95.73.72"; 55 | if (router.equals("MX240-2")) 56 | return "10.95.73.73"; 57 | if (router.equals("MX240-3")) 58 | return "10.95.73.74"; 59 | System.out.println("Error en el nombre del router"); 60 | return null; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/es/tid/test/RestartInterfaces.java: -------------------------------------------------------------------------------- 1 | package es.tid.test; 2 | 3 | import es.tid.ipnms.wsimpl.impl.IdaTelnetClientPrueba; 4 | 5 | public class RestartInterfaces { 6 | 7 | /** 8 | * Info: Este código borra las IPs establecidas para el One de las interfaces de los Juniper 9 | * @param args 10 | */ 11 | public static void main(String[] args) { 12 | // TODO Auto-generated method stub 13 | 14 | String machine[] = {"MX240-1","MX240-1","MX240-2","MX240-2","MX240-3","MX240-3"}; 15 | String intf[] = {"ge-2/1/8","ge-2/1/9","ge-2/1/8","ge-2/1/9","ge-2/1/8","ge-2/1/9"}; 16 | String ip[] = {"23.23.23.2/30","43.43.43.2/30","43.43.43.1/30","33.33.33.2/30","33.33.33.1/30","23.23.23.1/30"}; 17 | for (int i=0; i<6; i++){ 18 | IdaTelnetClientPrueba telnetClient = new IdaTelnetClientPrueba(true, new String[] {"#", ":", ">"}); 19 | 20 | 21 | String managementip= returnManagmentAddress(machine[i]); 22 | if (ip!=null){ 23 | System.out.println("Router: "+machine[i]+" IP: "+ip+" Interface: "+intf); 24 | try { 25 | telnetClient.connect(managementip, 23); 26 | //login to the router 27 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("tid" + "\r")); 28 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("Juniper" + "\r")); 29 | 30 | String response = telnetClient.send("\n\r"); 31 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + response ); 32 | 33 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("configure \r")); 34 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("delete interfaces "+intf[i]+" unit 0 family inet address "+ip[i]+"\r")); 35 | 36 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("commit \r")); 37 | System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 38 | //System.out.println("JuniperIpConfigurationClient:configure Response get: " + telnetClient.send("exit \r")); 39 | telnetClient.close(); 40 | }catch (Exception e){ 41 | e.printStackTrace(); 42 | } 43 | } 44 | } 45 | } 46 | private static String returnManagmentAddress(String router) { 47 | if (router.equals("MX240-1")) 48 | return "10.95.73.72"; 49 | if (router.equals("MX240-2")) 50 | return "10.95.73.73"; 51 | if (router.equals("MX240-3")) 52 | return "10.95.73.74"; 53 | System.out.println("Error en el nombre del router"); 54 | return null; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/LSP.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm; 2 | 3 | import java.util.Iterator; 4 | import java.util.LinkedList; 5 | 6 | import es.tid.rsvp.objects.subobjects.EROSubobject; 7 | 8 | public class LSP { 9 | private int id; 10 | private LinkedList EROSubobjectList; 11 | 12 | 13 | public int getId() { 14 | return id; 15 | } 16 | public void setId(int id) { 17 | this.id = id; 18 | } 19 | public LinkedList getEROSubobjectList() { 20 | return EROSubobjectList; 21 | } 22 | public void setEROSubobjectList(LinkedList eROSubobjectList) { 23 | EROSubobjectList = eROSubobjectList; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | // TODO Auto-generated method stub 29 | Iterator iteratorERO = EROSubobjectList.iterator(); 30 | String string=""; 31 | EROSubobject eROSubobject; 32 | while (iteratorERO.hasNext()){ 33 | eROSubobject = iteratorERO.next(); 34 | string = string + eROSubobject.toString()+"\n"; 35 | } 36 | return string; 37 | } 38 | 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/LigthPathManagement.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Iterator; 5 | import java.util.Set; 6 | import java.util.TimerTask; 7 | 8 | import org.jgrapht.graph.SimpleDirectedWeightedGraph; 9 | 10 | import es.tid.tedb.DomainTEDB; 11 | import es.tid.tedb.IntraDomainEdge; 12 | import es.tid.tedb.MultiLayerTEDB; 13 | 14 | public class LigthPathManagement extends TimerTask { 15 | 16 | private LigthPathCreateIP LSPDelete; 17 | private DomainTEDB ted; 18 | 19 | private Hashtable LigthPathList; 20 | 21 | LigthPathManagement(){ 22 | LigthPathList = new Hashtable(); 23 | } 24 | 25 | @Override 26 | public void run(){ 27 | SimpleDirectedWeightedGraph graph_IP; 28 | graph_IP = ((MultiLayerTEDB)ted).getInterLayerGraph(); 29 | 30 | Set fiberEdges= graph_IP.edgeSet(); 31 | Iterator iterFiberLink; 32 | iterFiberLink = fiberEdges.iterator(); 33 | 34 | while (iterFiberLink.hasNext()){ 35 | IntraDomainEdge fiberEdge =iterFiberLink.next(); 36 | float bw = fiberEdge.getTE_info().getUnreservedBandwidth().getUnreservedBandwidth()[0]; 37 | if (bw == fiberEdge.getTE_info().getMaximumBandwidth().getMaximumBandwidth()){ 38 | // Ligth path unused 39 | 40 | if (LigthPathList.get(fiberEdge)==null) 41 | LigthPathList.put(0, fiberEdge); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/OpTable.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm; 2 | 3 | /** 4 | * 5 | * @author baam 6 | * 7 | */ 8 | public class OpTable { 9 | 10 | private String AppIP; 11 | private String PCCIP; 12 | private String PCCPort; 13 | private long PCCoperationID; 14 | private String workflow; 15 | 16 | public OpTable (String appString, String pccipString, String PCCport, long pccopidString, String workflow){ 17 | this.AppIP=appString; 18 | this.PCCIP=pccipString; 19 | this.PCCPort=PCCport; 20 | this.PCCoperationID=pccopidString; 21 | this.workflow=workflow; 22 | } 23 | 24 | public String getAppIP() { 25 | return AppIP; 26 | } 27 | 28 | public void setAppIP(String appIP) { 29 | AppIP = appIP; 30 | } 31 | 32 | public String getPCCIP() { 33 | return PCCIP; 34 | } 35 | 36 | public void setPCCIP(String pCCIP) { 37 | PCCIP = pCCIP; 38 | } 39 | 40 | public long getPCCoperationID() { 41 | return PCCoperationID; 42 | } 43 | 44 | public void setPCCoperationID(long pCCoperationID) { 45 | PCCoperationID = pCCoperationID; 46 | } 47 | 48 | public String getPCCPort() { 49 | return PCCPort; 50 | } 51 | 52 | public void setPCCPort(String pCCPort) { 53 | PCCPort = pCCPort; 54 | } 55 | 56 | public String getWorkflow() { 57 | return workflow; 58 | } 59 | 60 | public void setWorkflow(String workflow) { 61 | this.workflow = workflow; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/client/VNTMClient.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.client; 2 | 3 | import java.io.IOException; 4 | import java.net.Socket; 5 | import java.net.UnknownHostException; 6 | 7 | import es.tid.pce.pcepsession.PCEPSessionsInformation; 8 | 9 | public class VNTMClient 10 | { 11 | public static void main(String[] args) 12 | { 13 | 14 | try { 15 | Socket s = new Socket("localhost", 4189); 16 | VNTMClientSession vntmsession = new VNTMClientSession( s,new PCEPSessionsInformation()); 17 | vntmsession.start(); 18 | } catch (UnknownHostException e) { 19 | e.printStackTrace(); 20 | } catch (IOException e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/emulator/OSPFSender.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.emulator; 2 | 3 | import static es.tid.rocksaw.net.RawSocket.PF_INET; 4 | 5 | import java.io.IOException; 6 | import java.net.Inet4Address; 7 | import java.net.InetAddress; 8 | import java.util.concurrent.LinkedBlockingQueue; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import es.tid.rocksaw.net.RawSocket; 13 | 14 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 15 | import es.tid.ospf.ospfv2.lsa.LSA; 16 | 17 | 18 | public class OSPFSender extends Thread { 19 | 20 | // Timeout para el socket 21 | private static final int TIMEOUT = 0; 22 | 23 | /** 24 | * Queue to read the messages to send to the PCE peer 25 | */ 26 | private LinkedBlockingQueue sendingQueue; 27 | Inet4Address dirPCE; 28 | private Logger log; 29 | public OSPFSender(Inet4Address dirPCE){ 30 | log=LoggerFactory.getLogger("OSPFParser"); 31 | sendingQueue= new LinkedBlockingQueue(); 32 | this.dirPCE=dirPCE; 33 | } 34 | 35 | public void run(){ 36 | LSA LSA_msg; 37 | int tipo = 1; 38 | RawSocket socket = new RawSocket(); 39 | Inet4Address dirPCE=null; 40 | try{ 41 | socket.open(PF_INET, 89); 42 | socket.setUseSelectTimeout(true); 43 | socket.setSendTimeout(TIMEOUT); 44 | socket.setReceiveTimeout(TIMEOUT); 45 | //FIXME: ESTE BIND ESTA A FUEGO 46 | socket.bind(InetAddress.getByName("172.16.1.1")); 47 | dirPCE= (Inet4Address)Inet4Address.getByName("172.16.1.3"); 48 | 49 | }catch(IOException e){ 50 | 51 | } 52 | 53 | 54 | log.info("OSPF RAW Socket opened"); 55 | 56 | while (true){ 57 | try { 58 | LSA_msg=sendingQueue.take(); 59 | } catch (InterruptedException e) { 60 | return; 61 | } 62 | 63 | try { 64 | OSPFv2LinkStateUpdatePacket ospf_packet= new OSPFv2LinkStateUpdatePacket(); 65 | (ospf_packet.getLSAlist()).add(LSA_msg); 66 | ospf_packet.encode(); 67 | socket.write(dirPCE,ospf_packet.getBytes()); 68 | log.info(" OSPF Packet sent!!"); 69 | 70 | } catch (IOException e) { 71 | // TODO Auto-generated catch block 72 | e.printStackTrace(); 73 | return; 74 | } 75 | } 76 | } 77 | 78 | public LinkedBlockingQueue getSendingQueue() { 79 | return sendingQueue; 80 | } 81 | 82 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 83 | this.sendingQueue = sendingQueue; 84 | } 85 | 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/emulator/TCPOSPFSender.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.emulator; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | import java.net.Inet4Address; 6 | import java.net.Socket; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import es.tid.ospf.ospfv2.lsa.LSA; 12 | import es.tid.vntm.VNTMParameters; 13 | 14 | public class TCPOSPFSender extends Thread { 15 | 16 | /** 17 | * Queue to read the messages to send to the PCE peer 18 | */ 19 | private LinkedBlockingQueue sendingQueue; 20 | private Socket sock; 21 | private DataOutputStream out; 22 | private VNTMParameters vntmParams; 23 | private Logger log; 24 | 25 | public TCPOSPFSender(Inet4Address dirPCE, int port){ 26 | log=LoggerFactory.getLogger("OSPFParser"); 27 | sendingQueue= new LinkedBlockingQueue(); 28 | try { 29 | this.sock = new Socket(dirPCE, port); 30 | log.info("SOCKET CREADO"); 31 | out=new DataOutputStream(sock.getOutputStream()); 32 | } catch (IOException e) { 33 | // TODO Auto-generated catch block 34 | e.printStackTrace(); 35 | } 36 | //GUARDAS EL OUTPUTSTREAM 37 | } 38 | 39 | 40 | public void run(){ 41 | LSA lsa; 42 | while (true){ 43 | try { 44 | lsa=sendingQueue.take(); 45 | } catch (InterruptedException e) { 46 | return; 47 | } 48 | 49 | try { 50 | lsa.encode(); 51 | out.write(lsa.getLSAbytes()); 52 | log.info(" OSPF LSA Packet sent!!"); 53 | } catch (IOException e) { 54 | // TODO Auto-generated catch block 55 | e.printStackTrace(); 56 | return; 57 | } 58 | } 59 | } 60 | 61 | public LinkedBlockingQueue getSendingQueue() { 62 | return sendingQueue; 63 | } 64 | 65 | public void setSendingQueue(LinkedBlockingQueue sendingQueue) { 66 | this.sendingQueue = sendingQueue; 67 | } 68 | 69 | // public Inet4Address readPCEAddress(){ 70 | // 71 | // try { 72 | // return (Inet4Address) Inet4Address.getByName(vntmParams.getNetworkEmulatorPCEAddress().getHostAddress()); 73 | // } catch (UnknownHostException e) { 74 | // // TODO Auto-generated catch block 75 | // e.printStackTrace(); 76 | // } 77 | // 78 | // return null; 79 | // } 80 | 81 | // public int readOSPFTCPPort(){ 82 | // 83 | // // FIXME: Definir procedimiento de lectura de puerto 84 | // 85 | // return vntmParams.getVNTMPort(); 86 | // 87 | // } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/management/VNTMManagementSession.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.management; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.io.PrintStream; 7 | import java.net.Socket; 8 | import java.util.concurrent.LinkedBlockingQueue; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | import es.tid.netManager.emulated.SimpleEmulatedNetworkLSPManager; 15 | import es.tid.ospf.ospfv2.OSPFv2LinkStateUpdatePacket; 16 | import es.tid.vntm.LSPManager; 17 | 18 | public class VNTMManagementSession extends Thread { 19 | 20 | private Socket socket; 21 | private PrintStream out; 22 | private Logger log; 23 | 24 | private LSPManager lspmanager; 25 | 26 | public VNTMManagementSession(Socket s, LSPManager lspmanager){ 27 | this.socket=s; 28 | this.lspmanager=lspmanager; 29 | log=LoggerFactory.getLogger("PCEServer"); 30 | } 31 | 32 | public void run(){ 33 | log.info("Starting VNTM Management session"); 34 | boolean running=true; 35 | try { 36 | out=new PrintStream(socket.getOutputStream()); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | return; 40 | } 41 | try { 42 | //out.print("-------------\n"); 43 | BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); 44 | while (running) { 45 | out.print("VNTM:>"); 46 | String command = null; 47 | try { 48 | command = br.readLine(); 49 | } catch (IOException ioe) { 50 | log.warn("IO error trying to read your command"); 51 | return; 52 | } 53 | if (command.equals("quit")) { 54 | log.info("Ending VNTM Management Session"); 55 | try { 56 | out.close(); 57 | } catch (Exception e){ 58 | e.printStackTrace(); 59 | } 60 | try { 61 | br.close(); 62 | } catch (Exception e){ 63 | e.printStackTrace(); 64 | } 65 | return; 66 | } 67 | if (command.equals("show TE Links")) { 68 | out.println("TE Links:"); 69 | out.println(lspmanager.printLSPs()); 70 | out.println("Number of TE Links : "+ lspmanager.countTELinks()); 71 | out.println("Number of Reserve Transport Links: "+lspmanager.countCapacity() ); 72 | 73 | } 74 | else if (command.equals("help")){ 75 | out.print("Available commands:\r\n"); 76 | out.print("show TE Links\r\n"); 77 | out.print("quit\r\n"); 78 | 79 | } 80 | else if (command.equals("reset")){ 81 | //Recorrer y Borrar todas las lsps que haya 82 | lspmanager.removeAllLSPs(); 83 | //Llamar al network emulator thread: recargar la topologia 84 | LinkedBlockingQueue sendingQueue = new LinkedBlockingQueue(); 85 | SimpleEmulatedNetworkLSPManager net = new SimpleEmulatedNetworkLSPManager(sendingQueue,"hola"); 86 | //net.reset(); 87 | //rester ok 88 | } 89 | else if (command.equals("hard reset")){ 90 | 91 | } 92 | else if (command.equals("set traces on")) { 93 | // log.setLevel(Level.ALL); 94 | // Logger log2=LoggerFactory.getLogger("VNTMServer"); 95 | // log2.setLevel(Level.ALL); 96 | // Logger log3= LoggerFactory.getLogger("PCEPParser"); 97 | // log3.setLevel(Level.ALL); 98 | out.print("traces on!\r\n"); 99 | } 100 | else if (command.equals("set traces off")) { 101 | // log.setLevel(Level.error); 102 | // Logger log2=LoggerFactory.getLogger("VNTMServer"); 103 | // log2.setLevel(Level.error); 104 | // Logger log3= LoggerFactory.getLogger("PCEPParser"); 105 | // log3.setLevel(Level.error); 106 | out.print("traces off!\r\n"); 107 | } 108 | 109 | else{ 110 | //out.print("invalid command\n"); 111 | out.print("\n"); 112 | } 113 | 114 | } 115 | } catch (Exception e) { 116 | e.printStackTrace(); 117 | return; 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/management/VNTMManagementSever.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.management; 2 | 3 | import java.net.ServerSocket; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import es.tid.vntm.LSPManager; 8 | 9 | public class VNTMManagementSever extends Thread { 10 | 11 | private Logger log; 12 | private LSPManager lspmanager; 13 | int port; 14 | public VNTMManagementSever( LSPManager lspmanager,int port){ 15 | log =LoggerFactory.getLogger("PCEServer"); 16 | this.lspmanager=lspmanager; 17 | } 18 | 19 | public void run(){ 20 | ServerSocket serverSocket = null; 21 | boolean listening=true; 22 | try { 23 | log.info("Listening on port "+port); 24 | serverSocket = new ServerSocket(port); 25 | } 26 | catch (Exception e){ 27 | log.error("Could not listen management on port "+port); 28 | e.printStackTrace(); 29 | return; 30 | } 31 | 32 | try { 33 | while (listening) { 34 | new VNTMManagementSession(serverSocket.accept(),lspmanager).start(); 35 | } 36 | serverSocket.close(); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Bandwidth.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class Bandwidth { 4 | 5 | double maxBandwidth; 6 | double unreservedBw; 7 | 8 | 9 | public Bandwidth (double initBandwidth){ 10 | maxBandwidth = initBandwidth; 11 | unreservedBw = initBandwidth; 12 | } 13 | 14 | 15 | public Bandwidth (double max, double unresv){ 16 | maxBandwidth = max; 17 | unreservedBw = unresv; 18 | } 19 | 20 | 21 | public String toString(){ 22 | return "Unreserved Bw = " + unreservedBw + ", Max Bandwidth = " + maxBandwidth; 23 | } 24 | 25 | /** 26 | * @return the maxBandwidth 27 | */ 28 | public double getMaxBandwidth() { 29 | return maxBandwidth; 30 | } 31 | /** 32 | * @param maxBandwidth the maxBandwidth to set 33 | */ 34 | public void setMaxBandwidth(double maxBandwidth) { 35 | this.maxBandwidth = maxBandwidth; 36 | } 37 | /** 38 | * @return the unreservedBw 39 | */ 40 | public double getUnreservedBw() { 41 | return unreservedBw; 42 | } 43 | /** 44 | * @param unreservedBw the unreservedBw to set 45 | */ 46 | public void setUnreservedBw(double unreservedBw) { 47 | this.unreservedBw = unreservedBw; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/BgpParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class BgpParams { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/EndPoint.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | 4 | 5 | 6 | public class EndPoint { 7 | String node; 8 | 9 | String intf; 10 | 11 | public EndPoint(String node, String intf){ 12 | this.node = node; 13 | this.intf = intf; 14 | } 15 | 16 | /** 17 | * @return the node 18 | */ 19 | public String getNode() { 20 | return node; 21 | } 22 | 23 | /** 24 | * @param node the node to set 25 | */ 26 | public void setNode(String node) { 27 | this.node = node; 28 | } 29 | 30 | /** 31 | * @return the intf 32 | */ 33 | public String getIntf() { 34 | return intf; 35 | } 36 | 37 | /** 38 | * @param intf the intf to set 39 | */ 40 | public void setIntf(String intf) { 41 | this.intf = intf; 42 | } 43 | 44 | 45 | public int compareTo(EndPoint arg0) { 46 | if ((arg0.intf.compareTo(this.intf)==0) && (arg0.node.compareTo(this.node)==0)) 47 | return 0; 48 | else 49 | return 1; 50 | } 51 | @Override 52 | public boolean equals(Object obj) { 53 | if ((this.node.equals(((EndPoint)obj).getNode()))&& 54 | (this.intf.equals(((EndPoint)obj).getIntf()))) 55 | return true; 56 | return false; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | // TODO Auto-generated method stub 62 | String temp=""; 63 | temp += "Node = " + node + " - "; 64 | temp += "Interface = " + intf ; 65 | return temp; 66 | } 67 | 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/IPNodeParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class IPNodeParams { 6 | ArrayList staticRoutingParams; 7 | ArrayList bgpParams; 8 | ArrayList isisParams; 9 | ArrayList ospfParams; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/IsisParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class IsisParams { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Link.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | 4 | 5 | public class Link { 6 | String linkID; 7 | Boolean isDirectional; 8 | EndPoint source; 9 | EndPoint dest; 10 | //TODO change to enumeration physical or service; 11 | String type;//interlayer, interdomain, intradomain 12 | Service service; 13 | PhyLinkParams phyLinkParams; 14 | double teMetric; 15 | 16 | 17 | public String getLinkID() { 18 | return linkID; 19 | } 20 | public void setLinkID(String linkID) { 21 | this.linkID = linkID; 22 | } 23 | /** 24 | * @return the isDirectional 25 | */ 26 | public Boolean isDirectional() { 27 | return isDirectional; 28 | } 29 | /** 30 | * @param isDirectional the isDirectional to set 31 | */ 32 | public void setDirectional(Boolean isDirectional) { 33 | this.isDirectional = isDirectional; 34 | } 35 | /** 36 | * @return the source 37 | */ 38 | public EndPoint getSource() { 39 | return source; 40 | } 41 | /** 42 | * @param source the source to set 43 | */ 44 | public void setSource(EndPoint source) { 45 | this.source = source; 46 | } 47 | /** 48 | * @return the dest 49 | */ 50 | public EndPoint getDest() { 51 | return dest; 52 | } 53 | /** 54 | * @param dest the dest to set 55 | */ 56 | public void setDest(EndPoint dest) { 57 | this.dest = dest; 58 | } 59 | /** 60 | * @return the type 61 | */ 62 | public String getType() { 63 | return type; 64 | } 65 | /** 66 | * @param type the type to set 67 | */ 68 | public void setType(String type) { 69 | this.type = type; 70 | } 71 | /** 72 | * @return the service 73 | */ 74 | public Service getService() { 75 | return service; 76 | } 77 | /** 78 | * @param service the service to set 79 | */ 80 | public void setService(Service service) { 81 | this.service = service; 82 | } 83 | /** 84 | * @return the phyLinkParams 85 | */ 86 | public PhyLinkParams getPhyLinkParams() { 87 | return phyLinkParams; 88 | } 89 | /** 90 | * @param phyLinkParams the phyLinkParams to set 91 | */ 92 | public void setPhyLinkParams(PhyLinkParams phyLinkParams) { 93 | this.phyLinkParams = phyLinkParams; 94 | } 95 | /** 96 | * @return the teMetric 97 | */ 98 | public double getTeMetric() { 99 | return teMetric; 100 | } 101 | /** 102 | * @param teMetric the teMetric to set 103 | */ 104 | public void setTeMetric(double teMetric) { 105 | this.teMetric = teMetric; 106 | } 107 | 108 | @Override 109 | public boolean equals(Object arg0) { 110 | // TODO Auto-generated method stub 111 | if ((linkID.equals(((Link)arg0).linkID)) 112 | &&(this.isDirectional == ((Link)arg0).isDirectional) 113 | &&(this.source.equals(((Link)arg0).getSource())) 114 | &&(this.dest.equals(((Link)arg0).getDest())) 115 | // &&(this.type.equals(((Link)arg0).getType())) 116 | // &&(this.service.equals(((Link)arg0).getService())) 117 | // &&(this.phyLinkParams.equals(((Link)arg0).getPhyLinkParams())) 118 | // &&(this.teMetric == ((Link)arg0).getTeMetric()) 119 | ) 120 | return true; 121 | return false; 122 | } 123 | public String toString(){ 124 | String temp = ""; 125 | temp += "Source = (" + source.getNode() + ", " + source.getIntf() + ") " ; 126 | temp += "Dest = (" + dest.getNode() + ", " + dest.getIntf() + ") " ; 127 | temp += "isDirectional = " + isDirectional + " "; 128 | temp += "Type = " + type+ " "; 129 | if (phyLinkParams !=null) 130 | temp += "Phy Link Params (Delay = " + phyLinkParams.getTransmissionDelay() + " isActive = " + phyLinkParams.getTransmissionDelay() + ") " ; 131 | temp += "TE Metric = " + teMetric; 132 | return temp; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Location.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class Location { 4 | double xCoord; 5 | double yCoord; 6 | 7 | /**Constructor to set the location 8 | * 9 | * @param x X coordinate of the location 10 | * @param y Y coordinate of the location 11 | */ 12 | public Location (double x, double y){ 13 | xCoord=x; 14 | yCoord=y; 15 | } 16 | 17 | /** 18 | * @return the xCoord 19 | */ 20 | public double getxCoord() { 21 | return xCoord; 22 | } 23 | /** 24 | * @param xCoord the xCoord to set 25 | */ 26 | public void setxCoord(double xCoord) { 27 | this.xCoord = xCoord; 28 | } 29 | /** 30 | * @return the yCoord 31 | */ 32 | public double getyCoord() { 33 | return yCoord; 34 | } 35 | /** 36 | * @param yCoord the yCoord to set 37 | */ 38 | public void setyCoord(double yCoord) { 39 | this.yCoord = yCoord; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Node.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | import java.util.ArrayList; 4 | 5 | //import tid.vntm.topology.elements.ipnode.IPNodeParams; 6 | 7 | public class Node { 8 | String nodeID; 9 | ArrayList address; 10 | boolean isPhysical; 11 | ArrayList intfList; 12 | int domain; 13 | Location location; 14 | IPNodeParams ipParams; 15 | String parentRouter; 16 | String layer; 17 | 18 | 19 | /** 20 | * @return the nodeID 21 | */ 22 | public String getNodeID() { 23 | return nodeID; 24 | } 25 | /** 26 | * @param nodeID the nodeID to set 27 | */ 28 | public void setNodeID(String nodeID) { 29 | this.nodeID = nodeID; 30 | } 31 | /** 32 | * @return the address 33 | */ 34 | public ArrayList getAddress() { 35 | return address; 36 | } 37 | /** 38 | * @param address the address to set 39 | */ 40 | public void setAddress(ArrayList address) { 41 | this.address = address; 42 | } 43 | /** 44 | * @return the isPhysical 45 | */ 46 | public boolean isPhysical() { 47 | return isPhysical; 48 | } 49 | /** 50 | * @param isPhysical the isPhysical to set 51 | */ 52 | public void setPhysical(boolean isPhysical) { 53 | this.isPhysical = isPhysical; 54 | } 55 | /** 56 | * @return the intfList 57 | */ 58 | public ArrayList getIntfList() { 59 | return intfList; 60 | } 61 | /** 62 | * @param intfList the intfList to set 63 | */ 64 | public void setIntfList(ArrayList intfList) { 65 | this.intfList = intfList; 66 | } 67 | /** 68 | * @return the domain 69 | */ 70 | public int getDomain() { 71 | return domain; 72 | } 73 | /** 74 | * @param domain the domain to set 75 | */ 76 | public void setDomain(int domain) { 77 | this.domain = domain; 78 | } 79 | /** 80 | * @return the location 81 | */ 82 | public Location getLocation() { 83 | return location; 84 | } 85 | /** 86 | * @param location the location to set 87 | */ 88 | public void setLocation(Location location) { 89 | this.location = location; 90 | } 91 | /** 92 | * @return the ipParams 93 | */ 94 | public IPNodeParams getIpParams() { 95 | return ipParams; 96 | } 97 | /** 98 | * @param ipParams the ipParams to set 99 | */ 100 | public void setIpParams(IPNodeParams ipParams) { 101 | this.ipParams = ipParams; 102 | } 103 | /** 104 | * @return the parentRouter 105 | */ 106 | public String getParentRouter() { 107 | return parentRouter; 108 | } 109 | /** 110 | * @param parentRouter the parentRouter to set 111 | */ 112 | public void setParentRouter(String parentRouter) { 113 | this.parentRouter = parentRouter; 114 | } 115 | 116 | public String getLayer() { 117 | return layer; 118 | } 119 | public void setLayer(String layer) { 120 | this.layer = layer; 121 | } 122 | public String toString(){ 123 | String temp = ""; 124 | temp += "NodeID = " + nodeID +" " ; 125 | if (location!=null) 126 | temp += "Location = (" + location.xCoord + ", " + location.yCoord + ")" + " " ; 127 | temp+= "Addresses ("; 128 | for (int i=0; (address !=null) && i< address.size();i++){ 129 | temp +=address.get(i) + ", "; 130 | } 131 | temp=temp.substring(0, temp.length()-2); 132 | temp += ") "; 133 | temp += "Domain = " + domain + " " ; 134 | temp += "ParentRouter = " + parentRouter + " " ; 135 | temp += "\nInterfaces = {"; 136 | for (int i=0;intfList!=null && i (); 145 | address = new ArrayList (); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/OspfParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class OspfParams { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Path.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Path { 6 | //TODO change to enumeration with values working/protection 7 | String pathType; 8 | 9 | ArrayList links; 10 | 11 | public String toString(){ 12 | String temp = ""; 13 | if (links!=null){ 14 | for (int i=0;i" + links.get(i).getDest() ; 16 | } 17 | return temp; 18 | } 19 | 20 | public Path(ArrayList links){ 21 | this.links = links; 22 | } 23 | 24 | /** 25 | * @return the pathType 26 | */ 27 | public String getPathType() { 28 | return pathType; 29 | } 30 | 31 | /** 32 | * @param pathType the pathType to set 33 | */ 34 | public void setPathType(String pathType) { 35 | this.pathType = pathType; 36 | } 37 | 38 | /** 39 | * @return the links 40 | */ 41 | public ArrayList getLinks() { 42 | return links; 43 | } 44 | 45 | /** 46 | * @param links the links to set 47 | */ 48 | public void setLinks(ArrayList links) { 49 | this.links = links; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/PhyLinkParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class PhyLinkParams { 4 | //Create parameters for Physical Link 5 | double transmissionDelay; 6 | 7 | boolean isActive; 8 | 9 | public PhyLinkParams(double delay, boolean active){ 10 | isActive = active; 11 | transmissionDelay = delay; 12 | } 13 | 14 | /** 15 | * @return the transmissionDelay 16 | */ 17 | public double getTransmissionDelay() { 18 | return transmissionDelay; 19 | } 20 | 21 | /** 22 | * @param transmissionDelay the transmissionDelay to set 23 | */ 24 | public void setTransmissionDelay(double transmissionDelay) { 25 | this.transmissionDelay = transmissionDelay; 26 | } 27 | 28 | /** 29 | * @return the isActive 30 | */ 31 | public boolean isActive() { 32 | return isActive; 33 | } 34 | 35 | /** 36 | * @param isActive the isActive to set 37 | */ 38 | public void setActive(boolean isActive) { 39 | this.isActive = isActive; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/Service.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Service { 6 | 7 | //TODO change to enumeration with possible values active/potential 8 | String status; 9 | 10 | //TODO change to enumeration with possible services like Ethernet/OTN etc. (or based on the layering available in interfaces 11 | String serviceType; 12 | 13 | Bandwidth bw; 14 | 15 | //Change to Enumeration based on protection types 16 | String protection; 17 | 18 | EndPoint source; 19 | 20 | EndPoint dest; 21 | 22 | Path servicePath; 23 | 24 | ArrayList srlg; 25 | 26 | String baseEncapsulation; 27 | 28 | /** 29 | * @return the status 30 | */ 31 | public String getStatus() { 32 | return status; 33 | } 34 | 35 | public String toString(){ 36 | String temp = ""; 37 | temp += "\n\t ServiceType = " + serviceType; 38 | temp += "\n\t Status = " + status; 39 | temp += "\n\t Protection = " + protection; 40 | temp += "\n\t Path = " + servicePath; 41 | temp += "\n\t Bandwidth = " + bw; 42 | return temp; 43 | } 44 | 45 | /** 46 | * @param status the status to set 47 | */ 48 | public void setStatus(String status) { 49 | this.status = status; 50 | } 51 | 52 | /** 53 | * @return the serviceType 54 | */ 55 | public String getServiceType() { 56 | return serviceType; 57 | } 58 | 59 | /** 60 | * @param serviceType the serviceType to set 61 | */ 62 | public void setServiceType(String serviceType) { 63 | this.serviceType = serviceType; 64 | } 65 | 66 | /** 67 | * @return the bw 68 | */ 69 | public Bandwidth getBw() { 70 | return bw; 71 | } 72 | 73 | /** 74 | * @param bw the bw to set 75 | */ 76 | public void setBw(Bandwidth bw) { 77 | this.bw = bw; 78 | } 79 | 80 | /** 81 | * @return the protection 82 | */ 83 | public String getProtection() { 84 | return protection; 85 | } 86 | 87 | /** 88 | * @param protection the protection to set 89 | */ 90 | public void setProtection(String protection) { 91 | this.protection = protection; 92 | } 93 | 94 | /** 95 | * @return the source 96 | */ 97 | public EndPoint getSource() { 98 | return source; 99 | } 100 | 101 | /** 102 | * @param source the source to set 103 | */ 104 | public void setSource(EndPoint source) { 105 | this.source = source; 106 | } 107 | 108 | /** 109 | * @return the dest 110 | */ 111 | public EndPoint getDest() { 112 | return dest; 113 | } 114 | 115 | /** 116 | * @param dest the dest to set 117 | */ 118 | public void setDest(EndPoint dest) { 119 | this.dest = dest; 120 | } 121 | 122 | /** 123 | * @return the servicePath 124 | */ 125 | public Path getServicePath() { 126 | return servicePath; 127 | } 128 | 129 | /** 130 | * @param servicePath the servicePath to set 131 | */ 132 | public void setServicePath(Path servicePath) { 133 | this.servicePath = servicePath; 134 | } 135 | 136 | /** 137 | * @return the srlg 138 | */ 139 | public ArrayList getSrlg() { 140 | return srlg; 141 | } 142 | 143 | /** 144 | * @param srlg the srlg to set 145 | */ 146 | public void setSrlg(ArrayList srlg) { 147 | this.srlg = srlg; 148 | } 149 | 150 | /** 151 | * @return the baseEncapsulation 152 | */ 153 | public String getBaseEncapsulation() { 154 | return baseEncapsulation; 155 | } 156 | 157 | /** 158 | * @param baseEncapsulation the baseEncapsulation to set 159 | */ 160 | public void setBaseEncapsulation(String baseEncapsulation) { 161 | this.baseEncapsulation = baseEncapsulation; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/main/java/es/tid/vntm/topology/elements/StaticRoutingParams.java: -------------------------------------------------------------------------------- 1 | package es.tid.vntm.topology.elements; 2 | 3 | public class StaticRoutingParams { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/sample-config-files/defaultConfiguration.properties: -------------------------------------------------------------------------------- 1 | PCEAddress = 192.168.1.200 2 | PCEPPort = 4189 3 | networkDescriptionFile = /usr/local/nodeConfig/topologia.xml 4 | flexi = true 5 | mpls = false 6 | RSVPMode = true 7 | isMultiDomain = false 8 | SetTraces = true 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node1/defaultConfiguration.properties: -------------------------------------------------------------------------------- 1 | PCEAddress = 192.168.1.200 2 | PCEPPort = 4189 3 | networkDescriptionFile = /usr/local/nodeConfig/topologia.xml 4 | flexi = true 5 | mpls = false 6 | RSVPMode = true 7 | isMultiDomain = false 8 | SetTraces = true 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node1/killRoadm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ERPMPROC=`ps -ef | grep nodeDemo |grep -v grep | awk '{ print $2}' | head -1` 3 | if [ -z "$ERPMPROC" ]; 4 | then 5 | echo "No process! ROADM is not running!" 6 | else 7 | for pids in `ps -ef | grep nodeDemo |grep -v grep | awk '{ print $2}'` 8 | do 9 | kill -9 $pids 10 | done 11 | fi 12 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node1/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node1/roadm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | EMULATOR_HOME=../../ 3 | ROCKSAW_HOME=../../ 4 | TRANSPORT_NODE_NAME=nodeDemo1 5 | TRANSPORT_NODE_CONFIG_HOME=`pwd` 6 | echo java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 7 | java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 8 | 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node2/defaultConfiguration.properties: -------------------------------------------------------------------------------- 1 | PCEAddress = 192.168.1.200 2 | PCEPPort = 4189 3 | networkDescriptionFile = /usr/local/nodeConfig/topologia.xml 4 | flexi = true 5 | mpls = false 6 | RSVPMode = true 7 | isMultiDomain = false 8 | SetTraces = true 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node2/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node2/roadm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | EMULATOR_HOME=../../ 3 | ROCKSAW_HOME=../../ 4 | TRANSPORT_NODE_NAME=nodeDemo1 5 | TRANSPORT_NODE_CONFIG_HOME=`pwd` 6 | echo java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 7 | java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 8 | 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node3/defaultConfiguration.properties: -------------------------------------------------------------------------------- 1 | PCEAddress = 192.168.1.200 2 | PCEPPort = 4189 3 | networkDescriptionFile = /usr/local/nodeConfig/topologia.xml 4 | flexi = true 5 | mpls = false 6 | RSVPMode = true 7 | isMultiDomain = false 8 | SetTraces = true 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node3/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/Node3/roadm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | EMULATOR_HOME=../../ 3 | ROCKSAW_HOME=../../ 4 | TRANSPORT_NODE_NAME=nodeDemo1 5 | TRANSPORT_NODE_CONFIG_HOME=`pwd` 6 | echo java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 7 | java -Djava.library.path=$ROCKSAW_HOME -Dlog4j.configurationFile=$TRANSPORT_NODE_CONFIG_HOME/log4j2.xml -Dname=$TRANSPORT_NODE_NAME -jar $EMULATOR_HOME/Emulator-jar-with-dependencies.jar 8 | 9 | -------------------------------------------------------------------------------- /src/main/sample-config-files/example1_Triangle_SSON/PCE/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/sample-config-files/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/sample-config-files/topologia-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 0.0.0.1 7 | 8 | 192.168.1.0 9 | 12 10 | 11 | 12 | 13 | 192.168.1.1 14 | 15 | 16 | 192.168.1.2 17 | 18 | 19 | 192.168.1.3 20 | 21 | 22 | 23 | 24 | 160 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 192.168.1.1 36 | 2 37 | 38 | 39 | 192.168.1.3 40 | 1 41 | 42 | 43 | 3.14 44 | 45 | 46 | 100 47 | 48 | 49 | 100 50 | 51 | 52 | 53 | 54 | 55 | 56 | 192.168.1.3 57 | 1 58 | 59 | 60 | 192.168.1.1 61 | 2 62 | 63 | 64 | 3.14 65 | 66 | 67 | 100 68 | 69 | 70 | 100 71 | 72 | 73 | 74 | 75 | 76 | 77 | 192.168.1.2 78 | 2 79 | 80 | 81 | 192.168.1.3 82 | 2 83 | 84 | 85 | 3.13 86 | 87 | 88 | 100 89 | 90 | 91 | 100 92 | 93 | 94 | 95 | 96 | 97 | 98 | 192.168.1.3 99 | 2 100 | 101 | 102 | 192.168.1.2 103 | 2 104 | 105 | 106 | 3.13 107 | 108 | 109 | 100 110 | 111 | 112 | 100 113 | 114 | 115 | 116 | 117 | 118 | 119 | 192.168.1.1 120 | 1 121 | 122 | 123 | 192.168.1.2 124 | 1 125 | 126 | 127 | 3.12 128 | 129 | 130 | 100 131 | 132 | 133 | 100 134 | 135 | 136 | 137 | 138 | 139 | 140 | 192.168.1.2 141 | 1 142 | 143 | 144 | 192.168.1.1 145 | 1 146 | 147 | 148 | 3.12 149 | 150 | 151 | 100 152 | 153 | 154 | 100 155 | 156 | 157 | 158 | 159 | --------------------------------------------------------------------------------