Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielaTh committed Nov 28, 2015
1 parent 8315a5d commit 3e8bc19
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 22 deletions.
7 changes: 7 additions & 0 deletions src/Entities/Equipment/Hub.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Entities.Equipment;

import Entities.Network.IPAddressV4;
import Entities.Packages.Packet;

/**
Expand All @@ -12,6 +13,12 @@ public Hub(int connectionsNumber) {
this.connectionsNumber = connectionsNumber;
}

public Hub(int connectionsNumber, IPAddressV4 associated) {
super();
this.connectionsNumber = connectionsNumber;
this.associatedIp = associated;
}

@Override
public void sendPacket(Packet packet) {
for (Equipment equipment : equipments) {
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Equipment/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Router(Equipment defaultEquipment, NetworkOs os){
this.defaultEquipment = defaultEquipment;
this.operatingSystem = os;
}

public void updateRoutingTable(Integer port, IPAddressV4 newIp) {
this.routingTable.put(port, newIp);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Entities/Osystem/NetworkOs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public String getDataVersion(){
data = data + "Tipo: Network \n";
return data;
}

public NetworkOs(){}

public NetworkOs(String name, String version){
this.name = name;
this.version = version;
}


}
99 changes: 78 additions & 21 deletions src/Main/Main.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,88 @@
package Main;

import Entities.Equipment.*;
import Entities.Osystem.*;
import Exceptions.*;;
import Entities.Packages.Sendmsg;
import Entities.Network.*;

public class Main {

public static void main(String[] args) {

Hub hub1 = new Hub(15);

TerminalOs osServerHub1 = new TerminalOs("Windows Server", "2012", 10);
IPAddressV4 ipServerHub1 = new IPAddressV4(190,210,2,1);
Terminal serverHub1 = new Terminal(osServerHub1, ipServerHub1);

TerminalOs osLaptopHub1 = new TerminalOs("Windows", "7", 10);
IPAddressV4 ipLaptopHub1 = new IPAddressV4(190,210, 2, 2);
Terminal LaptopHub1 = new Terminal(osLaptopHub1, ipLaptopHub1);

TerminalOs osDesktopHub1 = new TerminalOs("Windows", "10", 10);
IPAddressV4 ipDesktopHub1 = new IPAddressV4(190,210, 2, 3);
Terminal DesktopHub1 = new Terminal(osDesktopHub1, ipDesktopHub1);


hub1.associateEquipment(serverHub1);
hub1.associateEquipment(LaptopHub1);
hub1.associateEquipment(DesktopHub1);
public static void main(String[] args) throws Exception {

try{
IPAddressV4 ipHub1 = new IPAddressV4(190, 210, 2, 4);
Hub hub1 = new Hub(15, ipHub1);

TerminalOs osServerHub1 = new TerminalOs("Windows Server", "2012", 10);
IPAddressV4 ipServerHub1 = new IPAddressV4(190, 210, 2, 1);
Terminal serverHub1 = new Terminal(osServerHub1, ipServerHub1);

TerminalOs osLaptopHub1 = new TerminalOs("Windows", "7", 10);
IPAddressV4 ipLaptopHub1 = new IPAddressV4(190, 210, 2, 2);
Terminal LaptopHub1 = new Terminal(osLaptopHub1, ipLaptopHub1);

TerminalOs osDesktopHub1 = new TerminalOs("Windows", "10", 10);
IPAddressV4 ipDesktopHub1 = new IPAddressV4(190, 210, 2, 3);
Terminal DesktopHub1 = new Terminal(osDesktopHub1, ipDesktopHub1);

hub1.associateEquipment(serverHub1);
hub1.associateEquipment(LaptopHub1);
hub1.associateEquipment(DesktopHub1);

IPAddressV4 ipHub2 = new IPAddressV4(10, 10, 5, 4);
Hub hub2 = new Hub(15, ipHub2);

TerminalOs osServerHub2 = new TerminalOs("Linux", "Ubuntu 14.05", 10);
IPAddressV4 ipServerHub2 = new IPAddressV4(10, 10, 5, 1);
Terminal serverHub2 = new Terminal(osServerHub2, ipServerHub2);

TerminalOs osLaptopHub2 = new TerminalOs("Linux", "Mint", 10);
IPAddressV4 ipLaptopHub2 = new IPAddressV4(10, 10, 5, 2);
Terminal LaptopHub2 = new Terminal(osLaptopHub2, ipLaptopHub2);

TerminalOs osDesktopHub2 = new TerminalOs("Linux", "Debian", 10);
IPAddressV4 ipDesktopHub2 = new IPAddressV4(10, 10, 5, 3);
Terminal DesktopHub2 = new Terminal(osDesktopHub2, ipDesktopHub2);

hub2.associateEquipment(serverHub2);
hub2.associateEquipment(LaptopHub2);
hub2.associateEquipment(DesktopHub2);

IPAddressV4 ipHub3 = new IPAddressV4(192, 168, 100, 4);
Hub hub3 = new Hub(15, ipHub3);

TerminalOs osServerHub3 = new TerminalOs("OS X", "Server 5", 10);
IPAddressV4 ipServerHub3 = new IPAddressV4(192, 168, 100, 1);
Terminal serverHub3 = new Terminal(osServerHub3, ipServerHub3);

TerminalOs osLaptopHub3 = new TerminalOs("OS X", "10.9", 10);
IPAddressV4 ipLaptopHub3 = new IPAddressV4(192, 168, 100, 2);
Terminal LaptopHub3 = new Terminal(osLaptopHub3, ipLaptopHub3);

TerminalOs osDesktopHub3 = new TerminalOs("OS X", "10.8", 10);
IPAddressV4 ipDesktopHub3 = new IPAddressV4(192, 168, 100, 3);
Terminal DesktopHub3 = new Terminal(osDesktopHub3, ipDesktopHub3);

hub3.associateEquipment(serverHub3);
hub3.associateEquipment(LaptopHub3);
hub3.associateEquipment(DesktopHub3);


NetworkOs osRouter = new NetworkOs("Router SO", "1.0");
Hub defaultHub = new Hub(50, new IPAddressV4(192, 168, 100, 50));
Router router = new Router(defaultHub, osRouter);
router.setConnectionsNumber(15);
router.associateEquipment(hub1);
router.associateEquipment(hub2);
router.associateEquipment(hub3);


serverHub1.sendPacket(ipDesktopHub1, new Sendmsg());
}
catch(Exception ex){

System.out.println("Error " + ex.getMessage());
}

}

Expand Down

0 comments on commit 3e8bc19

Please sign in to comment.