Top Banner
Bachelor of Electronic Engineering (Honours) Academic Year 2015/2016 Department of Electronic Engineering Project Title: A Simple Network of Routers and PC’s using EIGRP Student Name: Adam Carroll Student I.D.: X00104026 Submission Date: 25/01/2016 Supervisors: Dr. Andrew Donnellan & Mr. John Sexton
103

AdamCarroll_Semester8Report_X00104026

Apr 06, 2017

Download

Documents

Adam Carroll
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AdamCarroll_Semester8Report_X00104026

Bachelor of Electronic Engineering (Honours)

Academic Year 2015/2016

Department of Electronic Engineering

Project Title:A Simple Network of Routers and PC’s using EIGRP

Student Name: Adam Carroll

Student I.D.: X00104026

Submission Date: 25/01/2016

Supervisors: Dr. Andrew Donnellan & Mr. John Sexton

Page 2: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Declaration

This project entitled “A Simple Network of Routers and PCs using EIGRP” is my original work and has not been submitted for any other purpose to any other institute.

Full Name: ....................................................................

Student No: ....................................................................

Signed: ....................................................................

Acknowledgements

I would like to thank both Andrew Donnellan & John Sexton, my supervisors for project this year. Both of whom have given me their time, expertise and experience during the duration of this project.

24th Year Electronic Engineering

Page 3: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Table of Contents

Declaration............................................................................................................................................2

Acknowledgements...............................................................................................................................2

Table of Figures.....................................................................................................................................5

Project Plan...........................................................................................................................................6

Abstract.................................................................................................................................................7

Chapter 1 – Introduction.......................................................................................................................8

Chapter 2 – Background......................................................................................................................10

Networking:.....................................................................................................................................10

OSI Layer (Open System Interconnection Model):.......................................................................10

Function of each OSI Layer:.........................................................................................................10

IP Addresses................................................................................................................................12

MAC Address...............................................................................................................................12

Subnet Mask................................................................................................................................12

Logical AND..................................................................................................................................13

Network.......................................................................................................................................13

PC.................................................................................................................................................14

Default Gateway..........................................................................................................................14

Router..........................................................................................................................................14

EIGRP (Enhanced Interior Gateway Routing Protocol):................................................................21

Java..................................................................................................................................................24

High – Level / Low – Level Languages..........................................................................................24

Alternatives programming languages to Java..............................................................................24

Class Relationships.......................................................................................................................26

NetBeans.....................................................................................................................................30

Programming Terminology:.........................................................................................................32

Chapter 3 – Design..............................................................................................................................33

Device Information......................................................................................................................33

Step 1...........................................................................................................................................33

Step 2...........................................................................................................................................35

Step 3...........................................................................................................................................39

Step 4...........................................................................................................................................42

Step 5...........................................................................................................................................44

34th Year Electronic Engineering

Page 4: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Step 6...........................................................................................................................................47

Chapter 4 - Implementation................................................................................................................50

Logical AND..................................................................................................................................51

Static Routing...............................................................................................................................53

EIGRP...........................................................................................................................................55

Swing...........................................................................................................................................60

Problems Encountered................................................................................................................61

Summary of Implementation and Testing...................................................................................62

Chapter 5 – Conclusion........................................................................................................................63

Bibliography.........................................................................................................................................64

Appendices..........................................................................................................................................65

Appendix A..................................................................................................................................65

Appendix B...................................................................................................................................67

Appendix C...................................................................................................................................70

Appendix D..................................................................................................................................71

Appendix E...................................................................................................................................72

Appendix F...................................................................................................................................73

Appendix G..................................................................................................................................74

Appendix H..................................................................................................................................76

44th Year Electronic Engineering

Page 5: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Table of Figures

Figure 1 - Gantt chart of project for academic year 2015/2016............................................................7Figure 2 - Network Simulation of EIGRP using two Routers...................................................................9Figure 3 - Network Simulation of EIGRP using three Routers................................................................9Figure 4 - Ethernet Frame [1]..............................................................................................................15Figure 5 - Example of a routing table taken from the simulation........................................................16Figure 6 - List of different codes in a routing table..............................................................................17Figure 7 - Empty ARP Table from the Simulation.................................................................................19Figure 8 - ARP Request from R1 to R2.................................................................................................19Figure 9 - ARP Reply from R2 to R1......................................................................................................20Figure 10 - R1 updates its ARP Table after ARP Reply..........................................................................20Figure 11 - Echo Request from Router R1 to Router R2 in the simulation...........................................21Figure 12 - Echo Reply from Router R2 to Router R1 in the simulation...............................................21Figure 13 - Hello Packet travelling across a network. [2].....................................................................22Figure 14 - Administrative Distance Table taken from CCNA 1 and 2 Companion Guide. [3]..............23Figure 15 - Example of an Autonomous Network in EIGRP.[4]............................................................24Figure 16 - Example of a person class showing what objects it may have...........................................27Figure 17 - Typical UML class diagram.................................................................................................27Figure 18 - UML class diagram using an example of Inheritance.........................................................28Figure 19 - UML class diagram using an example of Composition.......................................................29Figure 20 - UML class diagram using an example of Association.........................................................30Figure 21 - UML class diagram using an example of Dependency.......................................................30Figure 22 - Shows how to create a JLabel in NetBeans........................................................................32Figure 23 - First UML class Diagram of PC...........................................................................................35Figure 24 - Network of 2 PC's..............................................................................................................35Figure 25 - Flowchart for PC1 to PC2 Ping Process..............................................................................36Figure 26 - First draft UML class Diagram of PC & Router....................................................................38Figure 27 - Network of 2 PC's & 1 Router............................................................................................38Figure 28 - Flowchart of 2 PC's & 1 Router Echo/ARP Request & ARP Reply Process..........................39Figure 29 - Echo Reply Process............................................................................................................40Figure 30 - First draft UML class Diagram of PC & Router with Static Route included.........................41Figure 31 - Network Diagram of 2 PC's & 2 Routers............................................................................41Figure 32 - Flowchart of 2 PC's & 2 Router's Echo/ARP Request Process............................................42Figure 33 - Network of 2 PC's and 3 Routers.......................................................................................43Figure 34 - Flowchart for 2 PC's and 3 Routers....................................................................................44Figure 35 - Redesigned UML Class Diagram for Simulation.................................................................48Figure 36 - Route to Destination using 2 PC's and 2 Routers...............................................................49Figure 37 - Two Routes available to Destination with 2 PC's and 3 Routers........................................49Figure 38 - Simulation main menu.......................................................................................................51Figure 39 - Logical AND diagram..........................................................................................................53Figure 40 - Logical AND Result in the Simulation.................................................................................53Figure 41 - Echo Request Frame from Router R1 to Router R2............................................................54

54th Year Electronic Engineering

Page 6: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 42 - Router R1 routing table before and after static routing process.......................................55Figure 43 – Router R1 Static Route entry before and after static routing process...............................55Figure 44 - Router R1 ARP table before and after static routing..........................................................55Figure 45 - EIGRP Cost Menu showing which route has been taken....................................................57Figure 46 - Router R1 routing table before and after EIRGP................................................................58Figure 47 - Simulation option to retrieve all MAC Addresses at once or seperately............................59Figure 48 - Simulation output after retrieving PC1 MAC Address........................................................60Figure 49 - Icon menu in JLabel selection pane...................................................................................61Figure 50 - Output of JLabel when called in code................................................................................61

64th Year Electronic Engineering

Page 7: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Project Plan

Project Plan

Task Name Duration Start FinishPC Class 6 days Mon 28/09/15 Mon 05/10/15

Revise IP Addressing 6 days Mon 05/10/15 Mon 12/10/15Attempted Ping 6 days Mon 12/10/15 Mon 19/10/15

Ping Implemented with Issues 6 days Mon 02/11/15 Mon 09/11/15Introduce Router between two PC's 6 days Mon 09/11/15 Mon 16/11/15

Ping between two PC's and one Router attempted

6 days Mon 16/11/15 Mon 23/11/15

PC's on Same Network 6 days Mon 23/11/15 Mon 30/11/15Implement Full Ping 6 days Mon 30/11/15 Mon 07/12/15

Introduce a second Router 6 days Mon 07/12/15 Mon 14/12/15Progress with 2 Routers 6 days Mon 14/12/15 Mon 21/12/15

Interim Report 26 days Mon 21/12/15 Mon 25/01/16

Gantt Chart

Figure 1 - Gantt chart of project for academic year 2015/2016

74th Year Electronic Engineering

Page 8: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Abstract

The aim of the project was to design and implement a network simulation of Routers and PC’s using the dynamic routing protocol EIGRP. This project was implemented entirely using the software programming language, Java. This language was created by Oracle. In order to complete this project extensive research had to be carried out on the programming language Java. Other research carried out in this project was revision in relation to Networking, how Routers, PC’s and the protocol EIGRP behave.

The programming software in which this project was designed and implemented is called NetBeans IDE (Integrated Development Environment), version 8.0.2. The reason why NetBeans was chosen as the software program for this project was due to its GUI Building tool. A GUI would allow the user to click components such as Routers or PC’s and drag them onto the screen. Using the Swing application these components would then be modified to model their real life behaviour (the way EIGRP behaves when enabled in a router).

This project arrives at the stage just before a GUI (Graphical User Interface). Using the command prompt there are several different options that allow the user to enable/disable EIGRP and watch how the network behaves when the protocol is implemented and when it is not implemented. Instead of a GUI, there a pictorial representations of the simulated network along with a description of how they behave in the command prompt. It offers a step by step description as to how the dynamic routing protocol EIGRP behaves.

This project could be further improved by moving onto the next step of the design and implementation process, adding a GUI. This would allow the user to see the protocol fully functioning by clicking into a router and viewing their corresponding ARP Tables, Routing Tables and witness how packets behave as they progress to a destination via different paths.

84th Year Electronic Engineering

Page 9: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Chapter 1 – Introduction

This project is titled “a simple network of Routers and PC’s using EIGRP”. The aim of this project was to create a simulated network of PC’s and a maximum of three routers, using Ethernet as the only connection. Figure 2 and Figure 3 below show a network diagram of the networks simulated in this project.

Figure 2 - Network Simulation of EIGRP using two Routers.

Figure 3 - Network Simulation of EIGRP using three Routers.

Each of the main components, the PC and the Router, both behave in a particular way. The design allows the user to navigate through each of these devices separately. A PC will have a MAC Address, IP Address, subnet mask and a default gateway. A Router will also have a MAC Address, IP Address and subnet mask, but will also have an ARP Table, Static Route entry and a Protocol. Through the software, each of the details listed above will be allowed to be viewed, and also modified.

9

Page 10: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Both the PC’s and the routers have an ARP Protocol implemented, with each device containing ARP Tables inside of them. ARP Tables store which store MAC Address and IP Address information of devices directly connected to them in memory.

Routers contain information on how to route packets over the network. Routers are capable of telling each other about the networks directly connected to them. With EIGRP enabled, the routers share/promote information about all networks connected to them. This allows PC’s on different networks to communicate with one another.

The programme allows the user to access all of the of the all of the features listed above using the command prompt in the NetBeans software. This is a textual representation of the protocol EIGRP. The interface itself is user friendly, using numbers to switch between the different options in the main menu. There are pictorial representations of the Network available to the user once EIGRP has been enabled, which were designed in the JFrame Swing Controls menu. The user can then navigate around the network investigating what impact different scenarios have on the devices in the network.

This report details all of the steps involved from the very beginning of the project to its completion. These steps include the different decisions made in the design process such as weighing up different options, analysing their pros and cons, and the difficulties in implementing these designs. There will also be a section of the report listing further recommendations for students wishing to choose this project next year. Lastly, there will be a concluding chapter documenting thoughts on this project.

10

Page 11: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Chapter 2 – Background

Networking:

OSI Layer (Open System Interconnection Model):

7. Application6. Presentation5. Session4. Transport3. Network 2. Data Link1. Physical

The International Standards proposed an architecture model in 1983 which was a 7-layer model. This is called the Open Systems Interconnection or OSI Model. It proposed that:

- Layers should have defined functions.- There should be boundaries between each layer.- These boundaries minimise information flow between other layers.- Enough layers so that there are not too many functions combined together, but not too

many to over complicated it. Advantages of the OSI Model:

1. Assists in Protocol Design.2. Promote competition.3. Modifications in one layer do not affect any other layers.4. Common language / reference tool.

Function of each OSI Layer:

1. Physical Layer:

- This layer describes transition of data over a network using 1’s and 0’s, these 1’s or 0’s representing voltage levels on a particular line. Used in line coding. E.g. An example of this could be switching a lamp on and off. Representing a 1 and 0 bit stream.

- Physical cables used include RJ-45, RS232, Fibre, Twisted Pair.

2. Data Link:

- This layer deals with a securing a stable connection between your port and the next route, no data will be sent until a connection is secured.

11

Page 12: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

- It gives structure to the binary bit stream by assigning start and stop bytes, which is a special sequence 1’s and 0’s.

- This guarantee’s that the data sent out is received on the other end without any errors. There will be an acknowledgement sent to the source device to say if the data received is good or bad.

- Examples: LLC, MAC, SwitchesLogical Link Control (LLC):

- Creates the frame.- Handles communication between the upper and lower network layers.- Takes the network protocol data and adds control information to help deliver the

packet to its specified destination.Media Access Control (MAC):

- Gets the frame safely on and off the wire.- It is part of the lower sublayer of the data link layer (1-4)- It is implemented by hardware, typically the in the computer NIC.

3. Network:

- This layer is responsible for the routing of packets through the network.- It will look for the most efficient route that a packet should take to a destination.- Uses logical addressing to find the destination of a packet.- Controls traffic flow, prevents congestion on a network.- Monitors how much data is being sent at any one time.- Examples: RIP, EIRRP, OSPF

4. Transport:

- This layer breaks up the data it receives from the session layer into smaller chunks to prepare it for the Network layer.

- The data that has been broken up and sent has to be reassembled into its original order once received. E.g. If ten courier vans leave a docking bay and 10 ten arrive at the destination, you know this is good. If only nine arrive, there is a problem.

- This layer can multiplex several connections on the same network.- Monitors traffic both leaving and entering a host.- Uses both wired/connection and wireless/connectionless interfaces -

Transmission Control Protocol (TCP) – WiredUser Datagram Protocol (UDP) – Wireless

5. Session

- Keeps different application data separate.- It establishes, manages and terminates sessions (connections) among applications.

12

Page 13: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

- Coordinates communications systems and organises them by using three methods: Simplex (One way), Half-Duplex (Transmit and Receive alternately) and Full – Duplex (Tx and Rx both ways).

- If there is a large file transfer, it assigns waypoints at different intervals in case of an error. Therefore, if there is an error rather starting from the beginning you can begin from the last waypoint.

6. Presentation:

- This layer determines the way in which particular data formatted and presented on screen. Examples: ASCII, JPEG, Word Documents etc.

7. Application:

- This layer differentiates between the different file types and their structure. Both devices need to know which file types are being used so they can both make sense of a file. Example: A person who speaks English and French has written an email to their friend, their friend speaks English only, therefore they will write the email in English not French. This way their friend will be able to read the email.

- E.g. HTTP (port 80), Telnet (Port 23).

IP Addresses

In every packet header there is both a source IP (sender) and a destination IP (receiver) addresses, these addresses identify which device has sent the packet and where the packet is destined for. Found in layer three of OSI Model.

An IPv4 address is 32 bits long and written in dotted decimal.

Example:192.168.1.010 = 11000000.00000100.00000010.000000002

MAC Address

Media Access Control (MAC) is a hexadecimal address from the layer two link in the OSI Model. Every device that has a port on it will have its own unique MAC address. The other devices in the network can use this address to locate and communicate with that specific port in the network. A MAC address is 6 bytes long and look like the following:

aa:bb:cc:dd:ee:ff

Subnet Mask

13

Page 14: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Similar to an IP address a subnet mask is also 32 bits long and written in dotted decimal. The bits that are 1’s are the network bits and the bits that are 0’s are the host bits. Example if a subnet mask is /25 it can also be written as:

255.255.255.12810

↓11111111.11111111.11111111.100000002

↓NNNNNNNN.NNNNNNNN.NNNNNNN.NHHHHHHH

There are three different types of subnet masks:

- Class A → NNNNNNNN. HHHHHHHH.HHHHHHHH.HHHHHHHH → 1 to 126.- Class B → NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH →128 to 191- Class C → NNNNNNNN.NNNNNNNN.NNNNNNN.HHHHHHHH → 192 to 223

If there are two devices on a network and their subnet masks are the same, they are both on the same network and can exchange information. If their subnet masks are not the same they are usually separated by a router and will be able to communicate this way.

Logical AND

A logical AND in networking is where a device AND’s or it’ host address with the area subnet mask to retrieve that devices Network Address. Here is an example:

PC1 = 192.168.1.2 255.255.255.252

PC2 = 192.168.1.3 255.255.255.252

Logically AND your own subnet mask to the host IP Address:

11111111.11111111.11111111.00000010 //192.168.1.2

11111111.11111111.11111111.11111100 // 255.255.255.252_________________________________ 192 . 168 . 1 . 0

11111111.11111111.11111111.00000011 //192.168.1.311111111.11111111.11111111.11111100 // 255.255.255.252_________________________________ 192 . 168 . 1 . 0

The result from this is that the two addresses have the same network Address, therefore they are on the same network as one another.

14

Page 15: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Network

What is a network? A network can be described as two or more devices in the same area or region (local area network), an example of this is an office building. Each of these devices can communicate with one another through their ports. In order to communicate with one another they both have to an IP Address (Network Address), MAC Address (Physical) and Subnet Mask (Area). This way they can communicate with one another as they know each other’s details. They exchange details with one another by sending packets of information. The packets used in this network are Ethernet.

Figure 4 - Ethernet Frame [1]

Ethernet

Ethernet is the most popular physical layer LAN technology as it offers an even balance between speed, cost and ease of installation. It supports almost all network protocols and is widely accepted in the computer networking world. It can support speeds up to 10 Mbps. However now with small modifications to the Ethernet cable, Fast Ethernet has been introduced and speed increases by ten times producing 100 Mbps speeds.

PC

Personal computers are devices which have both layer 2 and layer 3 addresses. This means that they can have both IP Addresses and MAC Addresses. Furthermore, this allows them to communicate on a physical and networking level. They are capable of sending both ARP Requests/Replies and Echo Request/Replies. Because of this they will be able to exchange data with other devices on a network.

Default Gateway

A default gateway is the IP Address of the interface on the router to which a PC device is connected. It connects the network to the host. The default gateway IP Address must be on the same network as the host. Example:

PC1 is connected to router R1, where R1 is the Default Gateway. The IP address of PC1 is 192.168.1.1/30. This means that R1 will take the last host address available as the previous 30 bits are network bits. R1 IP Address = 192.168.1.2/30 = Default Gateway. This abides by the rule that the default gateway must be on the same network as the host.

15

Page 16: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Router

A router is a device that connects two or more different networks together. Their job is to direct a packet to its destination. The process is as follows. The router examines the incoming packet, the Router then looks in its routing table, if it finds a match the packet will be sent out on the corresponding interface/next-hop address. If not, the packet may time out and be dropped unless a static route/default route has been enabled. A real life example is a traffic warden. They direct and advise traffic to the best route available to them. The same logic applies with a router, the packet will be sent out on the interface/next-hop address which costs the least to a destination.

Routing Table

A routing table contains all routes in a network. It has three main features:

- Destination Network.- Next- Hop.- Metric (Will not be used in this project).- Protocol (If any)

When a packet arrives at a router, the router looks inside the packet header to identify the destination IP of the packet. From there the router logically ANDs the destination IP with the subnet mask of each entry in the routing table until it finds a match. Once a match is found the packet is sent out on the interface/next hop address.

In a way, a routing table is a map, but the router is your tour guide showing/directing you where to go.

Figure 5 - Example of a routing table taken from the simulation

Static Routing

Remote networks (not in your subnet mask/area) are added manually by entering them into the router. When a router learns about a new remote network it will store its network address, subnet mask, interface/next hope address of that network into the routing table with a ‘S’ leading the information, representing that the network is static. An example of this can be seen in Figure 5, where the last entry in R1 routing table is a static entry.

Static Routes are used:

16

Page 17: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

- In small networks where there are only a couple of routers.- To back up a dynamic routing protocol.- As a gateway of last resort, e.g. if the router does not know where to send a packet, it will

forward it out on this interface in hope of finding a destination.

Dynamic Routing

Remote networks are added to the routing table automatically by a dynamic routing protocol. These protocols are a set of rules in which routers exchange routing information with one another. Through this exchange of information routers can then determine the best route a particular destination.Therefore, the main difference between Dynamic and Static routing protocols are that dynamic routing updates routing tables automatically. Static routing updates the routing tables manually.

Similar to static routing, when a router learns about a new remote network it will store its network address, subnet mask, interface/next hop address of that network into the routing table. However, instead of a ‘S’ leading the information, the letter leading the information may vary depending on the dynamic routing protocol. The following are typical dynamic routing protocols:

- RIP (Routing Information Protocol)- EIGRP (Enhanced Interior Gateway Routing Protocol).- OSPF (Open Shortest Path First).

As you can see from figure 6 below, RIP is represented by R, EIGRP is represented by D and OSPF is represented by O. Therefore, these letters would lead the information in the routing table to symbolise that they have been enabled.

Figure 6 - List of different codes in a routing table

RIP, EIGRP & OSPF – The difference between them.

Although all of these carry out the same task they do it in different ways. Where RIP may be the most basic version of dynamic routing up to EIGRP or OSPF which use different algorithms to decide best path to a destination.

17

Page 18: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

RIP

There are two versions of RIP. RIP version 1 and RIP version 2. They are distance vector protocols. RIP calculates the best route to a destination based on the number of hops it takes to reach that destination.

EIGRP

Will be explained in more detail below but is known as a hybrid protocol. It has features of both link state and distance vector. Using Bandwidth and Delay as it’s metric, all of these variables are put into a cost equation and this equation determines the best route to a destination. It also offers an alternative if that link was to go down. EIGRP is a cisco proprietary protocol. Will only work inside of an autonomous network, meaning all routers will have to enable EIGRP for it to work.

OSPF

Uses link state routing protocol. Bandwidth as its main metric, uses delay also. In order to calculate the cost of a link for OSPF, the following formula is used:

OSPFCost= Reference BandwidthInterfaceBandwidth

Example, for Ethernet:

Cost=100Mbps10Mbps

=10

The cost of a link/interface is inversely proportional to the bandwidth on that link/interface. If the interface bandwidth is high (increases), the cost of a link will be low (decreases) and vice versa. OSPF is industry standard, where EIGRP is exclusively for Cisco Routers only. Similar to EIGRP, OSPF will only work inside of an autonomous network, meaning all routers will have to have OSPF enabled for it to work. E.g. Router EIGRP 100. 100 being the autonomous network.

www.Cisco.com describes the shortest path algorithm as each router placed at the root/foot of a tree. The algorithm will then find the shortest path to a particular destination, or branch of a tree. The router will take that shortest route/path it will also know about other ways to get to that particular destination/branch.

Link State

Link State algorithm, also known as shortest path first has a topology for the whole network in its router. The information is passed to the topology tables through link state advertisements. With a network topology routers are able to calculate the shortest path to a destination inside the autonomous network.

Link State Advertisements

Small packets of routing information exchange between link state routers.

18

Page 19: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Topology

A collection of the information gathered from link state advertisements.

Shortest Path

An algorithm carried out that determines the shortest way to a particular destination in the network.

Distance Vector

Distance

Distance is described as how far away a device is from a destination. This is based on the number of hosts the packet passes until it reaches its end point.

Vector

A Vector is described as the link/interface the packet will be sent out on to reach a destination. This route is chosen as the packet has given feedback to the router telling it that source address it came from has the shortest distance to that particular destination or end point.

The two of these elements combined together describe the Distance Vector protocol.

ARP Table

An ARP Table is a table inside of the router interface which stores both the IP Address and MAC Addresses of the links connected to it. Initially when a router has just been powered on, a routing table will be empty. It may have IP Addresses inside it, these will be the IP addresses of the networks directly connected. However, there will be no MAC Addresses for these networks in the ARP Table. This is at layer three level, for layer two level, switches will have an ARP Table that is completely empty.

Figure 7 - Empty ARP Table from the Simulation

ARP Request / ARP Reply

As you can see from router R1’s ARP table in Figure. 5 above, it has a PC called PC1 and a router called R2 connected to it. However, R1 does not have physical addresses (MAC) for the either devices connected. In this circumstance an ARP Request has to be send to both of those devices in order to obtain their respective MAC Addresses. This is the function of an ARP Request.

19

Page 20: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 8 - ARP Request from R1 to R2

The picture seen in Figure. 6 is an ARP Request frame. In this frame there are the following:

1. Destination MAC – MAC address of device sending the frame to. Will be a broadcast (all F’s, sends to all devices) if the source device wants to find MAC Address of an entry in the ARP Table.

2. Source MAC - MAC Address of device to where the request came from.3. Protocol Type – 0806 for ARP.4. ICMP Type – N/A for layer 2.5. Source IP – IP Address of device to where the request came from.6. Destination IP – IP Address of device sending the frame to.

If the destination IP address in the frame matches that of the device which has read the ARP Request, then a reply will be sent back to R1 with the MAC address of that particular device. In this case router R2’s IP address matches that in the ARP Request frame, so it will send its MAC Address back to router R1 in an ARP Reply frame.

Figure 9 - ARP Reply from R2 to R1

When an ARP Request/Reply frame has been accepted by the device, the first thing the device will do is update its ARP Table with the IP Address and MAC Address of the device it just accepted the request/reply from. Figure 8 below shows this, as you can see from the R1’s ARP Table it has the MAC address of PC1 also. The procedure would be the very same in this circumstance.

Figure 10 - R1 updates its ARP Table after ARP Reply

With its ARP Table full, router R1 would be now able to Ping PC PC1 & router R2.

Ping – In This Simulation

20

Page 21: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

A ping is an ICMP message which determines whether a device can communicate with another device over a network. Ping is also used as a debugging feature to see if the device you are communicating with is still available or not.

There are two types of frames at layer three level that make up the Ping.

1. IMCP Echo Request - Sender2. IMCP Echo Reply - Receiver

An Internet Control Message Protocol (ICMP) Request and Reply process is really quite simplistic. An Echo request is created by the sending device and the contents in the header frame are the following:

1. Destination MAC – MAC address of device sending the frame to. 2. Source MAC - MAC Address of device to where the request came from.3. Protocol Type – 0800 for ICMP.4. ICMP Type – 00 for Echo Request, 08 for Echo Reply.5. Source IP – IP Address of device to where the request came from.6. Destination IP – IP Address of device sending the frame to.

Therefore, to reiterate using an example. An echo request is created from the source device wishing to Ping a destination device. A typical header frame for an ICMP Echo Request may look like the following:

Figure 11 - Echo Request from Router R1 to Router R2 in the simulation.

This packet will arrive at router R2, and R2 will check to see if the destination IP matches his IP Address. R2 will see that it does and will send an Echo Reply back to router R1.

Figure 12 - Echo Reply from Router R2 to Router R1 in the simulation.

Router R1 now knows Router R2 is up and running on the other side of the link as it receives the Echo Reply from there.

It is important to note that during the sending of an Echo Request/Reply the source IP and destination IP always will remain the same. However, the destination and source MAC in the header frame will change as it passes through different ports on a network.

21

Page 22: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Pinging a PC – Real Life

- The source IP address of the device sends an ICMP Echo Request message to the destination IP address.

- Ping sets a sequence identifier that gets incremented by 1 with every echo-request message. It also sets a Time to Live (TTL) period which is set by the person sending the request, has a maximum value of 255.

- Ping insets a sending time in the data section, usually in milliseconds.- If the PC you want to Ping is responding, it will send back an ICMP Echo Reply message to

the source IP Address of the device.- Ping calculates the Round Trip Time (in milliseconds) using the time of arrival and sending

time of the message.- If the device, you want to Ping is not responding. The Echo Request message will usually wait

about 4 seconds per message, if there has been no reply the TTL will time out and the request will be dumped. A new Echo Request message will be sent out once again.

- All of the data is summarised and displayed showing: Packets transmitted and received. Percentage of packets lost. Total time taken. Minimum, maximum & average round trip.

As mentioned in the Ping – In This Simulation sub-chapter this project will incorporate no timing aspects and no round trip calculation. It does however show packets transmitted ad received.

EIGRP (Enhanced Interior Gateway Routing Protocol):

Enhanced Interior Gateway Routing Protocol (EIGRP) is a dynamic routing protocol developed by Cisco Systems which was released in the early 1990’s. Up to 2013, it was a Cisco proprietary protocol.

EIGRP advertises its routing table to all of its neighbours as distance-vector protocols would, it also uses hello packets to discover its neighbours. It uses a multicast address of 224.0.0.10 which is a group address used to send routing information to all EIGRP routers. EIGRP uses bandwidth and delay as its metric. Updates only happen in the network if a change has occurred to the network, rather than periodic updates. The information exchanged includes route changes, a new link or an old link shutting down or becoming unavailable. As mentioned in the paragraph above, a hello packet can be described as discovering and maintaining neighbours.

22

Page 23: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 13 - Hello Packet travelling across a network. [2]

There are four other packet types also:

1. Update – Informs neighbours of changes to the network.2. Acknowledgement – Confirms receiving an update.3. Query Packets – Compare routing tables of a neighbour.4. Reply Packets – Responds to query packets.

Administrative Distance (AD)

Is a feature that routers use in order to select the best path to a destination when there are two or more protocol options to reach the destination. AD defines the reliability of a protocol on a rating from 0 → 255. A protocol rating of 0 would be the best, an example of this would be a wired connection. A protocol rating of 255 would be the worst, an example of this does not exist but the closest thing is Internal BGP which has a rating of 200.

EIGRP has a rating of 90 and its close competitor OSPF has a rating of 110. If this scenario were to present itself to a router, EIGRP would be the protocol picked as its closer to 0 than OSPF. The router will then add the EIGRP route to the destination into the routing table, which would be the best possible route.

Figure 14 - Administrative Distance Table taken from CCNA 1 and 2 Companion Guide. [3]

23

Page 24: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Metric Cost / Feasible Distance

Metric Cost / Feasible Distance is the lowest cost of a path to get to another network. The formula below describes how to calculate this:

Cost ¿Feasible Distance=[256( 107

BWSlowestLink (kb ¿ ))+256(∑ of Delays (µs )

10)]

If the answer calculated for this equation contains a decmical point the rule of thumb here is to round down to the next number or integer. The answer to this equation is usually stored in the routing tables in the format of:

D 10.0.0.0/8 {90/ 30720} via 172. 16. 0. 254 / 01:21:37/ Fa0/1

This tells us that the route has an EIGRP entry in the routing table for a class A network. It has an administrative distance of 90 as its EIGRP and its metric cost is 30720 via the next hop address 172.16.0.254.

Topology Table

As mentioned in the Routing Table sub-chapter on page 12, a routing table stores the best possible route to a destination. The question now is where are all the other routes to that destination stored?

A topology table stores all other possible loop free paths to a network/destination. The reason for having a topology table is in the case where the fastest entry in the routing table goes down, therefore it will have to be replaced by the next best route. This is known as the Successor to the main route. All of these routes are auto-summarised.

Diffusing Update Algorithim (DUAL)

DUAL is a software algorithm used by EIGRP to manage what entries go into both the routing table and the topology table. Information about the Routing Table can be found on page 10, while information about the Topology Table can be found above on page 17. Basically, the best destination to a particular network will go into the routing table, whereas the alternative loop free routes to this particular destination will go into the topology table.

The algorithm that DUAL has to calculate is the best route to a destination. All routers are exchanging information with one another. Feasible Distance (FD) is when the router calculates the shortest distance to a network. This router then tells the other routers in the network, or his neighbour about his feasible distance, this is called Reported Distance (RD). If a router were then to have two routes to a destination the DUAL algorithm would calculate the most efficient route using their parameters.

24

Page 25: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Routing loops are avoided by making sure that the routes entered into the topology meet this condition:

Neighbours RD to network < Shortest Feasible Distance to network

If this condition were false, this would mean the shortest feasible distance is greater than reported distance. Therefore, the reported distance is slower than the shortest feasible distance, there would be no entry in the routing table for this scenario.

Autonomous Network

EIGRP uses a Autonomous System ID for numbering the area. The process ID has a range of 1 → 65,5535, however all routers using EIGRP that wish to communicate with each other using the protocol will have to have the same process ID, otherwise the network is not autonomous. Figure. 15 below shows an Autonomous network of routers using EIGRP with a process ID of 100.

Figure 15 - Example of an Autonomous Network in EIGRP. [4]

25

Page 26: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Java

Java is an object orientated programming language created by Sun Microsystems back in the mid 1990’s, which is now owned by Oracle. Programming is defined as to create or develop software which carries out a particular function or job. Therefore, an object orientated programming language is one that describes certain data structures. Data structures contain data inside of them that are known as attributes. An attribute describes a certain characteristic that something or someone has e.g. a circle is an object, a person is an object.

High – Level / Low – Level Languages

Java is a high-level language. This means the language used to write code is similar to the English language, this helps obtain a better understanding (compared to machine code). The instructions that high-level languages carry out are called statements. An example of a high-level code would be the following:

int AreaOfSquare;int Side; //One side of square

AreaOfSquare = Side * Side;

The piece of code above is a formula for calculating the area of a square, which is high-level. A compiler is needed to check this code for errors. Low-level languages are the complete opposite. They make it difficult for the user to comprehend as it lies between machine code (1’s and 0’s) and a high-level language. Assembly language uses a mnemonic which describes a machine code instruction. An example of low-level code would be the following:

add 2, 3, result

The piece of code above would add the numbers 2 and 3 together and store the answer in a variable called result. Assembly language is most commonly seen in microprocessor design.

Alternatives programming languages to Java

C

C is a hybrid of both assembly language and high-level language.

C++

Is object orientated similar to Java. The language is based on C and is popular for mathematical applications.

26

Page 27: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Pascal

Pascal” is a simple, structured, general-purpose language primarily for teaching programming”. [5](Yang, 2007, p. 31)

Python

Python” is a simple general-purpose scripting language good for writing short programs”. [6] (Yang, 2007, p. 31)From the list of alternatives above Java is most commonly compared with C++. The reason being that Java overtook C++ and also, the two languages are similar in terms of the way they are written:

- Comments are the same → //Comment in both Java and C++- Their primitive’s types are almost identical, the way they are written differs slightly (e.g.

Boolean → Java, bool → C++)- Integral Types – integers, doubles, strings etc.- Control constructs – if, for, while loops.- Function calls.- Passing variables into functions.

However, both languages differ also:

- As mentioned in the High – Level / Low – Level Languages sub-chapter on page 26, when compiled Java will transfer the source code into byte code, executes it and displays an output. C++ will transfer the source code into machine code and display an output this way.

- C++ has pointers. A pointer is a variable that is used to store the memory address of another variable. Pointers don’t exist in Java as memory management is included.

- C++ can pass parameters into functions by value (copy of the original variable, original parameter will not be modified) and by reference (memory address of a variable is passed into function, allowing for indirect modifying. This method of parameter passing will modify original parameter). Java only uses pass by reference.

- C++ uses structures (public – accessible to everyone) and classes (private – only accessible inside that class). Java uses classes only.

27

Page 28: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Class Relationships

Java is an object orientated language, meaning all data is described as an object. What an object describes depends on the title or the content of that particular class. Objects consist of attributes and behaviours. An object is the instance of a class. Therefore, a class is where you place the attributes of what you are trying to code. Example:

Figure 16 - Example of a person class showing what objects it may have.

UML Class Diagrams

Class diagrams provide an overview as to how a particular system interacts with other systems. It does this by showing classes and the relationships they share with other classes.A basic UML class diagram looks like the following:

Figure 17 - Typical UML class diagram

Each UML class diagram has three basic parameters:

- Class Name- Attributes / Objects of that class- Operations – What functions are inside that class.

In Java there are 4 main types of class relationships, which are the following:

1. Inheritance2. Composition3. Association4. Dependency

28

Page 29: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Inheritance

Inheritance is known as a “is a” relationship. It describes the process where one class acquires the objects from other classes into their own class. Meaning the class that acquires or ‘inherits’ these objects is known as a sub-class.

Figure 18 - UML class diagram using an example of Inheritance

Looking at the class diagram in Figure 18 above there is a class known as a person. The objects inside the person class are name, age and gender. Looking at the other two classes in the diagram called student and lecturer, they both have name, age and gender also. Therefore, they can inherit the attributes of the person class into their own, while having addition attribute too.

Here is an example in code:

int StudentNumber;String Course;

public Student(int StudNo, String Crs){ super(Name, Age, Gender);

StudentNumber = StudNo;Course = Crs;}

29

Page 30: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Composition

Composition is known as a “has a” relationship. It describes how one object inside its class may be a listed as a separate class itself.

Figure 19 - UML class diagram using an example of Composition

Looking at Figure 19 above. One of the objects from the person class above is called date of birth. A date of birth has another class branching from it as seen above with objects of date, month and year inside of it. This is composition.

Here is an example in code:

public class DateOfBirth extends Person {

}

30

Page 31: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Association

Association is known as a “know about” relationship. It describes an ‘association’ or an activity between two classes. Example, a student undertaking a module is an association between a student class and a module class. The person teaching the class, a lecturer, has an association with a module class also.

Figure 20 - UML class diagram using an example of Association.

Looking at Figure 20 above, the class diagram shows that a student class may partake in N number of modules, while a module can have from 10-60 students in it. Whereas with a lecturer, a lecturer may teach up to 4 modules and only one lecturer can teach one module.

Dependency

Dependency is known as a “uses” relationship. It describes a “dependency” that one class may have on another class. If one class, called class1 had a dependency on another class, class2 then class1 will be unable to carry out its function without class2.

Figure 21 - UML class diagram using an example of Dependency.

Figure 21 above shows two classes, a module and a student. To keep this example simple, a module cannot run if there are no students to participate in it. Therefore, the class Module has a dependency on a student class.

31

Page 32: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

NetBeans

NetBeans is a software program that provides an IDE, integrated development environment for developing all types of Java programs. It provides an editing, compiling, building and debugging environment. The process is as follows:

Create a project → build a project → add functions → run program.

If the program you are trying to run has compiling errors, NetBeans will pinpoint the error(s) in the exact line of code.

Alternative programmes to NetBeans

- Eclipse- Visual Studio

The reason NetBeans was chosen as the software to develop this project was for its GUI builder. This GUI builder enables the programmer to develop their own graphical user interface by using click and dragging components around the screen.

Swing

Swing is a graphical user interface (GUI) package created in Java. This interface allows the programmer to click and drag items onto a canvas and interact with them. Examples being buttons, scroll bars and text boxes for entering information. From there they can be developed into applications to carry out specific jobs. Every day examples of GUI’s are:

- iOS and Android operating systems running on Apple and Samsung phones.- Phone applications such as Facebook or Spotify are GUI’s.- Cisco Packet Tracer simulation teaching tool.

The list is endless.

The very first GUI developed was created using a package called AWT. Abstract Window Toolkit Event Package is a robust piece of software that allowed the programmer developing a GUI to have a whole range of different options to them including:

- Set of user interface components.- Event handling (input from a mouse or keyboard).- Graphic and imaging tools - shape, colour, font.- Native Screen – GUI will resemble a look of the Operating System being used.

32

Page 33: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

AWT was then later replaced by Swing. Swing has all the features of AWT but has it its own features such as:

- Icons for components.- Pop-up tools for components. - No native screen – GUI can be altered to look the way the programmer wishes.- Faster and robust (error-free) than AWT.

JLabel

A JLabel is an object that can display text and also images. By clicking and dragging the object onto a canvas there is the option to display an image, display text or display both an image and text. This is how to set one up:

Source Packages > JFrame Form > Class Name > Drag JLabel onto canvas > Icon/Text

Figure 22 - Shows how to create a JLabel in NetBeans

Figure 22 above shows this process pictorially. From the JLabel menu there is an option to add text or an image using the JLabel – Properties window.

The piece of code below calls the JLabel in the main.

JFrame frame = new Module();frame.setTitle("Module layout for this Semester");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);

33

Page 34: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Programming Terminology:

Below is a list of programming terminology used in this project:

toString(): It returns a string representation of the object. This method returns a string that explains the object through text.Object:

Objects have states and behaviours, another example being a sandwich class. E.g. Meat, salad, sauce would be objects.An object is an instance of a class.Class Definition:

Classes are defined by the state/behaviour that objects inside of them have.Private Class Members:

Private member classes can only be seen within its own class.Public Class Members:

Public member classes are available to everyone.Public State void main (string args[]):

Entry point for the code, this is where all methods are called and processing is complete. Default Constructor:

Default constructors have no parameters, if it does have parameters they are all default values.Overloading Constructor:

Overloading Constructors are multiple constructors of the same type that have different statements, variables inside of them.Getters and Setters:

Are used in private members because data is encapsulated and the programmer wishes to access it.Array Lists:

Carry out the same function as an array, however they have no size limitations. To add a value use, .add(variable), and to get a value use, .get(variable). These functions are helpful when the size of the array can be several possible sizes.Arrays.toString()

Prints out all values inside of array..ReplaceAll(“x”, “y”)

When printing out variables inside of an array the .replaceall can replace any characters from the outputted data. Leaving just the data inside of them.Object objectX = new Object();

Student Student1 = new Student();

Creates a new variable of type student called Student1. Will have default parameters unless set elsewhere. The new is the keyword in this line of code as it tells memory it wants a new student with all of the objects inside the student class.

34

Page 35: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Scanner Scanner1 = new Scanner(System.in);

Creates a variable called Scanner1 which allows the user to input a number..nextInt();Stores the scanner input if an integer..nextLine();Stores the scanner input if a string.

Chapter 3 – Design

The objective for this section of the project was to design a simulation of PC’s and routers using EIGRP. From carrying out research on both a networking and programming aspect this chapter will describe the design decisions chosen, and why they were chosen

This software had to be design in a way that was both user friendly and closely followed the EIGRP simulation in terms of its behaviour. In order to get to that stage, a foundation had to be built to develop on.

Device Information

Device NameInterfac

e IP Address Subnet Mask MAC Address

PC1 Fa0/0 192.168.1.2255.255.255.22

4 00:04:9a:c5:8e:15

PC2 Fa0/0 10.0.0.2255.255.255.22

4 00:d0:ff:93:cb:46

Router 1 Fa0/0 192.168.1.1255.255.255.22

4 00:e0:f7:94:8c:bb

Fa0/1 172.16.0.253255.255.255.25

200:60:70:92:07:e

5

Eth0/1/0 192.168.1.130255.255.255.25

2 00:d0:97:ca:a7:ad

Router 2 Fa0/0 10.0.0.1255.255.255.22

4 00:e0:8f:4d:6d:11

Fa0/1 172.16.0.254255.255.255.25

2 00:05:5e:11:5a:5a

Eth0/1/0 192.168.1.194255.255.255.25

2 00:09:7c:93:39:aa

Router 3 Fa0/0 192.168.1.129255.255.255.25

2 00:d0:ba:5c:49:01

Fa0/1 192.18.1.193255.255.255.25

2 00:e0:ca:5b:89:50

Step 1

In order to do this a class called PC was created which featured a list of objects inside of it:

35

Page 36: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Code

public String pcName; // PC Name public String NetworkInterfaceCard; // PC NIC public String MAC_Address; // MAC Address PC public String Connection; // Connection Type public String Interface; // Interface public int FirstPart_IP; // 1st part of Network Address PC public int SecondPart_IP; // 2nd part of Network Address PC public int ThirdPart_IP; // 3rd part of Network Address PC public int FourthPart_IP; // 4th part of Network Address PC public int FirstPart_Sub; // 1st part of Subnet Maslk public int SecondPart_Sub; // 2nd part of Subnet Mask public int ThirdPart_Sub; // 3rd part of Subnet Mask public int FourthPart_Sub; // 4th part of Subnet Mask public int Default_Gateway_Prt1; //Default gateway public int Default_Gateway_Prt2; public int Default_Gateway_Prt3; public int Default_Gateway_Prt4;

These objects combined describe that of a PC. Two PC’s would be created using the new object function and their attributes would be assigned inside that function. From the research, these are the objects that most PC’s have inside of them, therefore this is why they were chosen. Now that these two devices were set up, the next step in the design was to set up a ping.

UML Class Diagram

Figure 23 - First UML class Diagram of PC

The first draft UML Class diagram for a PC is shown above.

Network Diagram

36

Page 37: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 24 - Network of 2 PC's

Ethernet was the connection type chosen between the two devices, and also the whole design. The reason Ethernet was chosen over Serial is because with Serial connections, there are no arp requests sent out on the line. The requirements of this design stated arp protocol had to be implemented therefore Ethernet had to be used. The process would start off with both arp table entries in both PC’s being empty otherwise the arp protocol would have no use here. The packets that were exchanged between two devices would simply include the header frame, no preamble, no data, no frame check sequence.

37

Page 38: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Flowchart for PC1 → PC2 Ping

Figure 25 - Flowchart for PC1 to PC2 Ping Process

The flowchart above describes the process in which the PC Ping function goes through in order ping another PC.

Step 2

The next process in the design involved the two PC’s being broke up into separate networks. In order to do this a router was required, a router splits devices not on the same network. A switch could have been used as a switch decides where to send a ping based on the destination MAC address of a device. However, this project is only concerned with both layer 3 and layer 2, not just layer 2. Thus, a router had to be chosen. There was no need for a protocol implementation in this step as Router1

38

Page 39: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

is the only router in the simulation and it knows about the two networks connected to it. Therefore, it can forward Echo packets between the two devices.

Code

public String RouterName; // Router Namepublic String NetworkInterfaceCard; // Router NICpublic String MAC_AddressInt1; // MAC Address of Routerpublic String MAC_AddressInt2;public String Interface1Name; // Interfacepublic String Interface2Name;public String Connection; // Connection Typepublic int Interface1_Prt1; // 1st part of Network Address Router int Fa0/0public int Interface1_Prt2; // 2nd part of Network Address Router int Fa0/0 public int Interface1_Prt3; // 3rd part of Network Address Router int Fa0/0public int Interface1_Prt4; // 4th part of Network Address Router int Fa0/0public int Interface2_Prt1; // 1st part of Network Address Router int Fa0/1public int Interface2_Prt2; // 2nd part of Network Address Router int Fa0/1public int Interface2_Prt3; // 3rd part of Network Address Router int Fa0/1public int Interface2_Prt4; // 4th part of Network Address Router int Fa0/1public int Interface1_SubMaskPrt1; // 1st part of Subnet Mask Fa0/0public int Interface1_SubMaskPrt2; // 2nd part of Subnet Mask Fa0/0public int Interface1_SubMaskPrt3; // 3rd part of Subnet Mask Fa0/0public int Interface1_SubMaskPrt4; // 4th part of Subnet Mask Fa0/0 public int Interface2_SubMaskPrt1; // 1st part of Subnet Mask Fa0/1public int Interface2_SubMaskPrt2; // 2nd part of Subnet Mask Fa0/1public int Interface2_SubMaskPrt3; // 3rd part of Subnet Mask Fa0/1public int Interface2_SubMaskPrt4; // 4th part of Subnet Mask Fa0/1

These objects combined describe that of a Router. One router would be created using the new object function again, while also keeping the two PC’s created in the Step 1. From research, these are the most common objects that Routers have inside of them, this is why they were chosen. As you can see, the first draft of this code is missing a Static Route variable. This was introudced in the next step where there are two routers. Now that these two devices were configured, the next step was to set up a ping.

39

Page 40: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

UML Class Diagram

Figure 26 - First draft UML class Diagram of PC & Router

Figure 26 above shows the class relationship between the PC and the Router classes in the first draft of code.

Network Diagram

Figure 27 - Network of 2 PC's & 1 Router

40

Page 41: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Flowchart for PC1 → R1 → PC2 Ping

Note, that all of the flowcharts seen in the chapter will be Echo Request flowcharts. The reason being that all of the MAC addressing and ARP protocols are carried out in the request stage. Figure 28 below shows the ARP Request and Echo Request stage of Ping.

Figure 28 - Flowchart of 2 PC's & 1 Router Echo/ARP Request & ARP Reply Process

41

Page 42: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Echo Reply Process / Echo Reply Stage

When an Echo reply is being sent the routers arp table is full, however the logical and process will still occur at every interval to send a packet out on the correct interface. The section of the flowchart denoted Echo Reply Stage is what this paragraph has just described, the flowchart in Figure 29 below represents this also.

Figure 29 - Echo Reply Process

Step 3

The step involves a network of two PC’s and two routers. Here it possible to implement EIGRP because if an Echo Request arrived at R1, R1 will logically AND the destination IP Address with the entries in the routing table. It will see that PC2 is not there as it is not directly connected to R1. It is however connected to R2. Instead of implementing EIGRP for such a small network a static route can be entered into each router. This way if the Echo request arrives at R1, it will see that PC2 is there via R2 as a static route entry. The Echo Request will then be sent out on the Interface Fa0/1.

Code

42

Page 43: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Same code as in steps 1 and 2. Only difference in this step is that another router has been added. This means the new object function has been used again.UML Class Diagram

Static route entry now exists in this step.

Figure 30 - First draft UML class Diagram of PC & Router with Static Route included.

Network Diagram

Figure 31 - Network Diagram of 2 PC's & 2 Routers

43

Page 44: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Flowchart for PC1 → R1→ R2 → PC2 Ping

44

Page 45: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 32 - Flowchart of 2 PC's & 2 Router's Echo/ARP Request Process

45

Page 46: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Step 4

The step involves a network of two PC’s and three routers. Here it possible to implement EIGRP because if an Echo Request arrived at R1, R1 will logically AND the destination IP Address with the entries in the routing table it will see that PC2 is not there as it is not directly connected to R1. It is however connected to R2 and R3. EIGRP was implemented in this case but a function was written which allowed a static route to be entered into R3 and R2. Therefore, the simulation allowed for both Static Routing and EIGRP as means of pinging PC1 → PC2 via R3. The process for PC1 pinging PC2 via R2 with three routers would be the exact same as in Step 3. The only thing that would change in this scenario is that the ARP Table would be larger than in Step 3 as there is an extra connection to both R1 and R2.

UML Class Diagram

Same as in step 3.

Network Diagram

Figure 33 - Network of 2 PC's and 3 Routers

46

Page 47: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Flowchart for PC1 → R1 → R3 → R2 → PC2

Figure 34 - Flowchart for 2 PC's and 3 Routers

47

Page 48: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Step 5

At this stage of the design there was a network simulation of two routers and two PC’s that were able to ping one another without a protocol being implement. However, there was an underlying issue upon review. As seen in steps 1, 2 and 3 the class diagrams for each step were all incorrect. There was no relationship between any of the classes whatsoever, so instead of moving onto implementing EIGRP the decision was made to develop class relationships in the code.

As mentioned above, there was a network of two routers and two PC’s. However, when both devices are examined further in the UML class diagrams, it was apparent that the objects listed inside could be broken down even further. Similar to that of a function partition in Digital Design.

Class relationships are very important in programming as they give structure to the code that has been written whilst also giving a visual representation of how classes interact with one another through their relationships. This is important when code has to be analysed by someone other than the author of the code. The original code did not have this, therefore that’s why the decision was made to do it.

Upon research, the two class relationships that seemed relevant to this project were both Inheritance and Composition. From having just two classes called PC and Router, the project was redesigned with the following class titles:

1. Basic Port2. PC Port & Router Port3. PC & Router4. ARP Table Entry

Basic Port

From research, the basic port class contains the main attributes of most ports at layer 3. This was the class in which the code was built off of. This class had the following objects inside it:

- IP Address – now an array.- Subnet Mask – now an array also.- MAC Address- Interface

Code for Basic Port

public class Basic_Port { public int IPAddress[] = {0,0,0,0}; public int SubnetMask[] = {0,0,0,0}; public String MACAddress; public String Interface;

48

Page 49: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

PC Port & Router Port

These two ports have the same characteristics as the basic port but also had their own characteristics too. A PC Port “is a” Basic Port with additional features. A Router Port “is a” Basic Port with additional features also. This “is a” relationship is Inheritance and this is why this relationship was chosen in the design.

PC Port

- IP Address – now an array.- Subnet Mask – array also.- MAC Address- Interface

Plus,- Name- Default Gateway – array

Code

public class PC_Port extends Basic_Port { public String Name; public int DefaultGateway[] = {0,0,0,0};

Router Port

- IP Address – array.- Subnet Mask – array.- MAC Address- Interface

Plus,- Name- Protocol

Code

public class Router_Port extends Basic_Port { public String Name; public String Protocol;

49

Page 50: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

PC & Router

A PC “has a” PC Port with the attributes listed above but a PC Port also “has an” ARP Table. Same applies for the Router. A Router has a Router Port and it also “has an” ARP Table. This “has a” relationship is composition and this is why it was chosen in this design.

PC

Code

public PC_Port Port = new PC_Port("",0,0,0,0,0,0,0,0,0,0,0,0,"",0,""); public ArrayList <ARPTableEntry> ARPTable = new ArrayList<>(); public ARPTableEntry Entry1 = new ARPTableEntry(0,0,0,0,""); public String Name;

The variable types shown above PC_Port & ARPTableEntry show examples of composition. As they have their own objects inside of them.

Router

Code

public String Name; public Router_Port PortA = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public Router_Port PortB = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public Router_Port PortC = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public ARPTableEntry EntryA = new ARPTableEntry(0,0,0,0,""); public ARPTableEntry EntryB = new ARPTableEntry(0,0,0,0,""); public ARPTableEntry EntryC = new ARPTableEntry(0,0,0,0,""); public ArrayList <ARPTableEntry> ARPTable = new ArrayList<>(); public String RoutingTable[] = {"", "\n", "\n", "\n"}; public int StaticRoute[] = {0,0,0,0};

The variable types show above Router_Port & ARPTableEntry show examples of composition. As they have their own objects inside of them.

ARP Table Entry

This class was a composition class. The two variables in the class were a MAC Address and an IP Address. They could be created in both the PC and Router devices. The word entry in the class title suggests that this is not an ARP Table. This is true. As seen in the lines of code about an Array list was created to store these entries into. Now making an ARP Table with an unlimited number of entries for large networks.

public class ARPTableEntry { public int IPAddress[] = {0,0,0,0};

50

Page 51: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

public String MACAddress;

51

Page 52: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

New UML Class Diagram

Figure 35 - Redesigned UML Class Diagram for Simulation.

Step 6

After redesigning the whole simulation class relationship in the design., the next and final step in the design was to create EIGRP.

After reviewing the original objectives for this design. It required at minimum two PC’s and three routers. At the stage when the review was carried out there were only two PC’s and two Routers in the network. Therefore, before EIGRP could be implemented another router had to be added to the network. After that task had been carried out the simulation would have 6 scenarios:

1. Two PC’s and two Routers with EIGRP – all addressing included.2. Two PC’s and three Routers with EIGRP – all addressing included.3. Two PC’s and two Routers with EIGRP – no addressing included.4. Two PC’s and three Routers with EIGRP – no addressing included.5. Static Routing option with two PC’s and two Routers.6. Static Routing option with two PC’s and three Routers.

52

Page 53: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

EIRGP

As mentioned in the background chapter describing EIGRP. It carries out these main functions:- Calculates Cost of link based on bandwidth of link and sum of delays on route to destination.- Updates routing table with best link.- Updates topology table with alternative routes to destination.

For this simulation the cost would be calculated in a much simpler way. An option will pop up in the menu where the user will be asked to enter in a cost, which is of type integer. The cost can have any size and the algorithm is quite simple.

In the case of two routers and two PC’s there will only be one route to the destination regardless of the cost.

Figure 36 - Route to Destination using 2 PC's and 2 Routers.

In the case of three routers and two PC’s there will be two possible routes to the destination.

Figure 37 - Two Routes available to Destination with 2 PC's and 3 Routers.

The way in which the algorithm works is that it there are two possible routes as seen above. For the lower route. There are two connections as seen. A manual cost is entered into both and which one of the two links that has a higher cost is chosen as the cost of the lower link. With the top link there is only one cost. The two are compared and if:

1. Top Link > Lower Link → Lower Link will be used.2. Top Link < Lower Link → Top Link will be used.

53

Page 54: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Depending on which route is taken the routing tables will be updated accordingly. There is no topology table in this design. This is to keep the design as simplistic as possible while following the rules of EIGRP also.

Once this was coded an Interface was developed. Due to time constraints an interface using the command prompt would be the one chosen. It lists several different options about EIGRP and Static Routing. Depending on which scenario is picked in the simulation there will be a photo of the network diagram of the simulation the user has picked. There are also options to view device information and also edit it, perform a logical AND, plus use some small features of EIGRP. Such as best route using the actual formula and hello packets.

54

Page 55: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Chapter 4 - Implementation

As mentioned in the design chapter. The simulation in this project was implemented using a command line user interface rather than a GUI. The different options in the main menu are shown below:

Figure 38 - Simulation main menu.

The software for this menu was designed using one large while loop condition which contained all of the functions inside of it. The condition would keep looping inside the function until the user presses exit or closes the software using NetBeans itself.

public static void main(String[] args) {

int i = 1; while(i==1) {

/// /// ///

}

The next stage of implementation was writing the select options for the menu. The way the code was written was using a system.out.print() function which would ask a question inside of it and using the scanner function, mentioned on page 35 would allow the user to select one of the options. Numbered answers to these questions were chosen instead of text because text is case sensitive and if not entered correctly would give an error, with numbers this is all avoided as they have no cases etc. Example of the menu option:

System.out.println("\nWhich Device information would you like to see?\n(1) PC1 \n(2) PC2 \n(3) Router 1 \n(4) Router 2 \n(5) Router 3\n(6) All Devices\n(7) Main Menu\nEnter: ");Scanner A = new Scanner(System.in);int B = A.nextInt();if (B==1){

System.out.print(PC1);}

55

Page 56: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

The piece of code addresses a question about viewing device information. The question is asked inside the system.out.println() method, a Scanner is called A, and the input from this method will be stored in an integer called B. From there whatever answered is inputted by the user, the code will carry out the function of that selection. In the example above if (B==1) this will display the information of PC1.

Logical AND

The logical AND function was written as it Is a very important step in the routing process. The function does a logical AND for all of the addresses in the network and is selected when the integer (Num ==2):

else if (Num ==2) { int x = 1; while(x == 1) { LogicalAND(); Scanner A = new Scanner(System.in); System.out.println("\nWould you like to go back to the Main Menu or see Logical AND Result again? \n(1) Logical AND\n(2) Main Menu\nEnter: "); int B = A.nextInt(); if (B == 1) { x = 1; } else if (B == 2) { x = 0; } } }

The code above shows how the condition is called in the main. If the condition is met the code will enter an if loop and then into a while loop. From here there is a function call for the Logical AND which calls it from its location just under the main argument. There is an option to see the result again or an option to go back to the main menu.

How the code for the logical AND is written is shown below:

int z=0;System.out.print("R1 Fa0/1 Logical AND Result: ");if (z==0) { for (z=0;z<3;z++) { int r1 = ((R1.PortA.IPAddress[z]) & (R1.PortA.SubnetMask[z])); System.out.print(r1 + "."); } int r1f00 = (R1.PortA.IPAddress[3]) & (R1.PortA.SubnetMask[3]); System.out.print(r1f00); } System.out.print("\n");

56

Page 57: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

As seen from the code above there is a text output revealing which that the logical AND below is for Router 1 interface Fa0/1. The code then enters a for loop which loops around three times (z=0 → z=1→ z=2, when z = 3, z == 3, ∴ z is not <3) and adds a full stop after each number has been AND in the array locations z number of times. A full stop is then added to resemble what an IP Address looks like. Finally, the last location in the array ANDs the last remaining locations [3] & [3] together and outputs a result. They were not included in the for loop as they would have added a full stop to the last number. Which was not required. The diagram below shows how this is done.

Figure 39 - Logical AND diagram

There is an alternative method to carry out a Logical And function:

int l1, l2, l3, l4, m1, m2, m3, m4 = 0;l1 = R1.PortC.IPAddress[0] & R1.PortC.SubnetMask[0]; l2 = R1.PortC.IPAddress[1] & R1.PortC.SubnetMask[1];l3 = R1.PortC.IPAddress[2] & R1.PortC.SubnetMask[2]; l4 = R1.PortC.IPAddress[3] & R1.PortC.SubnetMask[3];

These lines of code do the same thing the function above does, however the function above is more challenging to write, which was the preferred option. The output result from the simulation is shown below:

Figure 40 - Logical AND Result in the Simulation

57

Page 58: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Static Routing

This process involves PC1 pinging PC2. In this code there are two possible scenarios:

1. Static Routing option with two PC’s and two Routers.2. Static Routing option with two PC’s and three Routers.

In both scenarios PC1 is the source and PC2 is the destination. The flowcharts for PC1 → PC2 with 2 Routers on page 44 and PC1 → PC2 with 3 Routers on page 47 were the base on which this design was implemented. The code was written in a way in which the user could view the packet information change as it hopped from device to device on its way to its destination in the command prompt. As mentioned in the static route background information sub-chapter on page 16, when an ARP frame is being sent, both the MAC Address and IP address will vary depending on where the ARP Request/Reply is going to/coming from. With the Echo Request/Reply frame, the source IP and destination IP will remain the same but the MAC Address information will vary from device to device. This is how the frame format was written in code:

System.out.println("\n\t\t\t\tEcho Request from R1 to R2\t\t\t\t\n____________________________________________________________________________________________________________");System.out.println("Destination MAC | Source MAC | Protocol Type | ICMP Type | Source IP | Destination IP");EchoRequest = R2.PortA.MACAddress + " " + R1.PortA.MACAddress + " " + Protocol_Type + " " + ICMP_Type + " " + PC1IP + " " + PC2IP;System.out.println(EchoRequest);

The piece of code above was created to resemble the appearance of a packet header. This was done by using particular characters, formatting them in the correct order and inputting the correct details into each header frame. The code above produces the imagine below in the simulation:

Figure 41 - Echo Request Frame from Router R1 to Router R2.

Another thing that the static route function does in this simulation is update the routing tables, ARP tables and Static Route entry after the protocol has been used. The user should now find upon viewing the routing tables before and afterwards that the prior to the function call, all tables will be empty, but afterwards will be full. Scenario 1 at the top of the page was the scenario picked in this example. Router 1 will be used as an example of this working.

58

Page 59: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Routing Table – Router 1 – Before & After

Figure 42 - Router R1 routing table before and after static routing process.

Code

R1.RoutingTable[0] = ("\n\nS "+ X1+"."+ X2+"."+ X3+"."+ X4+"/8 is directly connected - "+R1.PortA.Interface +"\nC "+ m1+"."+ m2+"."+ m3+"."+ m4+"/30 is directly connected - " + R1.PortA.Interface +"\nC "+ i1+"."+ i2+"."+ i3+"."+ i4+"/27 is directly connected - "+ R2.PortA.Interface);

As seen above, the details or Network Addresses of the networks are passed into R1’s Routing Table when the static routing function is called.

Static Route Entry – Router 1 – Before & After

Figure 43 – Router R1 Static Route entry before and after static routing process.

Code

R1.StaticRoute[0] = R1.PortA.IPAddress[0];R1.StaticRoute[1] = R1.PortA.IPAddress[1];R1.StaticRoute[2] = R1.PortA.IPAddress[2];R1.StaticRoute[3] = R1.PortA.IPAddress[3];

The code above shows the Static route entry in Router 1 being updated after the static route function as been complete. It has been assign R1 Fa0/1 IP Address.

59

Page 60: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

ARP Table – Router 1 – Before & After

Figure 44 - Router R1 ARP table before and after static routing.

Code

R1.EntryA.IPAddress[0] = 172; R1.EntryA.IPAddress[1] = 16; R1.EntryA.IPAddress[2] = 0; R1.EntryA.IPAddress[3] = 254;R1.EntryA.MACAddress = R2.PortA.MACAddress;R1.EntryB.IPAddress[0] = 192; R1.EntryB.IPAddress[1] = 168; R1.EntryB.IPAddress[2] = 1; R1.EntryB.IPAddress[3] = 2;R1.EntryB.MACAddress = PC1.Port.MACAddress;

Entry A listed in this code is from the ARPTableEntry class that was mentioned in the design chapter. It represents a MAC Address and IP Address. This entry will be added to the ARPTable arraylist and stored there, where it will be used to display ARP Table information like in the example above.

The other scenario in this section, where there are 2 PC’s and 3 Routers will assign the information in the very same way as in the example above. Every routers Routing Table, ARP Table and Static Route entries will be updated if they are involved in the static routing process.

EIGRP

This process involves PC1 pinging PC2. In this code there are four possible scenarios:

1. Two PC’s and two Routers with EIGRP – all addressing included.2. Two PC’s and three Routers with EIGRP – all addressing included.3. Two PC’s and two Routers with EIGRP – no addressing included.4. Two PC’s and three Routers with EIGRP – no addressing included.

In all scenarios PC1 is the source and PC2 is the destination. These scenarios give an insight as to the workings of EIGRP. As mentioned in the design chapter of this report on EIGRP (page 53) this simulation will be a simplistic version of EIGRP in that it does these main things:

- Decides cost based on lowest cost of a link, which is entered manually.- Routing tables will be updated with best path to destination.

Cost

The cost algorithm explained in the design section of EIGRP on page 43 states the lowest cost will go into the routing table. This is done by offering different scenarios, a two router and three router EIGRP option. Each of the routers will share each other’s routing table information within one

60

Page 61: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

network. The route in which the packet will take from PC1 to PC2 depends on the cost, as already stated. If the two router option is selected there is only one possible, route to PC2 and that would be via R2. Therefore, this section will skip this and explain how the three router option was implemented as it was more complex than the two router option.

Figure 37 on page 53 shows the two possible routes to PC2 when at Router R1. It also shows that there are five connections altogether in the network. Each one of these must have a cost and is assigned by the user. The figure below shows the option to enter a cost of a network in the simulation:

Figure 45 - EIGRP Cost Menu showing which route has been taken.

While returning a summary with the details about which route it took to the destination and why.

CodeSystem.out.println("Please enter the cost of each link in the network");Scanner P1 = new Scanner(System.in);System.out.println("\nLink 1 : PC1 -> R1\nEnter: ");int Rp1 = P1.nextInt();Scanner Rb = new Scanner(System.in);System.out.println("\nLink 2: R1 -> R2\nEnter: ");int Br = Rb.nextInt();Scanner ER = new Scanner(System.in);System.out.println("\nLink 3: R2 -> PC2\nEnter: ");int Re = ER.nextInt();Scanner RJ = new Scanner(System.in);System.out.println("\nLink 4: R1 -> R3\nEnter: ");int JR = RJ.nextInt();Scanner CM = new Scanner(System.in);System.out.println("\nLink 5: R3 -> R2\nEnter: ");int MC = CM.nextInt();int Cost1 = Br; //Via R2int Cost2 = 0;if (JR > MC){

Cost2 = JR;}else if (JR< MC){

Cost2 = MC;

61

Page 62: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

}

if (Cost1 < Cost2) {

//R2 costs less than R3, use R2}

else if (Cost1 > Cost2) {

//R3 costs less than R2, use R3}

The code above describes the algorithm that was used in order to discover the fastest link to the destination. The variable integer Br (which is Cost1) is the cost of the link between R1 and R2. Depending on the cost of either integer JR or MC (Cost 2) which is the link between R1 and R2 only via R3. The larger integer of JR or MC will be used as the cost of the link for Cost 2. They will then be compared against Cost 1 to see which link is the fastest to the destination. This is a simplistic and scaled down version of the real life protocol, however the premise is the same.

The ARP Table will update its table in the very same way as it did in the static route option. Therefore, another explanation is not needed here. Also, there will be no static route entries in this scenario, just EIGRP.

Routing Tables – Before & After

Figure 46 - Router R1 routing table before and after EIRGP.

The figure above shows the routing table of router R1 before and after EIGRP has been implemented. The scenario that was run was scenario 2 – two PC’s and two Routers using the lower link of 100 cost as the fastest link to destination PC2. After implementation it can be seen that the routing tables have been updated with EIGRP information, denoted by the D at the beginning of the routing entry. This simulation also prints the cost that the user inputted to get the best route to the destination.

The code below describes how R1 routing table was updated:

R1.RoutingTable[0] = ("\n\nD "+ X1+"."+ X2+"."+ X3+"."+ X4+"/8 {90/" + Cost2 + "} via "+(Arrays.toString(R3.PortB.IPAddress)).replaceAll(",",

62

Page 63: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

".").replaceAll("\\[", "").replaceAll("]", " ")+"/ 00:05:44/ "+ R2.PortC.Interface +"\nD "+ m1+"."+ m2+"."+ m3+"."+ m4+"/30 {90/" + Cost2 + "} via "+(Arrays.toString(R3.PortB.IPAddress)).replaceAll(",", ".").replaceAll("\\[", "").replaceAll("]", " ")+"/ 00:05:48/ "+R2.PortC.Interface +"\nC "+ x1+"."+ x2+"."+ x3+"."+ x4+"/27 is directly connected via " + R1.PortB.Interface +"\nC "+ n1+"."+ n2+"."+ n3+"."+ n4+"/30 is directly connected via " + R2.PortC.Interface);

As seen above, the details or Network Addresses of the networks are passed into R1’s Routing Table when the EIGRP function was called. Updating the routing table about the network PC2 → 10.0.0.0 and the network between R2 and R3 → 192.168.192.

The EIGRP in this simulation shows ICMP messages as they move from device to device until it reaches the destination. The hope here was to create an EIGRP frame and input the sufficient details that it has and also add to the hello frame created, by adding an update and acknowledgement packet. However due to time constraints this did not develop further.

Note, the simulation with no addresses inside of them. They both work in the same way EIGRP does when implemented, however they must get MAC addresses of surrounding devices in order for the protocol to work. In the simulation menu it looks like the following:

Figure 47 - Simulation option to retrieve all MAC Addresses at once or seperately.

It gives the user an option to get all the MAC Addresses for all devices in the network or get each device MAC Address separately. This procedure does the very same thing the ARP Request process does, however this is carried out behind the scenes and the MAC address(es) the device requires will go straight into it the ARP Table.

The advised option is to retrieve all MAC addresses at once therefore the user will not have to go back again to the menu. A snippet of code shows how this process was implemented:

Scanner KKW = new Scanner(System.in);int KW = KKW.nextInt();if (KW == 1){GETARPMACPC1();GETARPMACPC2();GETARPMACR1();GETARPMACR2();Entry7.MACAddress = "";Entry8.MACAddress = ""; System.out.print("\nPC1 ARP Table:" + PC1.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", "

63

Page 64: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

").replaceAll("]", " "));System.out.print("\n\nPC2 ARP Table:" + PC2.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", " "));System.out.print("\n\nR1 ARP Table:" + R1.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", " "));System.out.print("\n\nR2 ARP Table:" + R2.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", " ")); }else if (KW ==2){

int h = 1;while(h==1){System.out.print("Would you like to get the MAC Address for:\n(1)

PC1\n(2) PC2\n(3) R1\n(4) R2\nEnter: \n");Scanner NWK = new Scanner(System.in);int RW = NWK.nextInt();

if (RW == 1){

GETARPMACPC1();System.out.print("\nPC1 ARP Table:" +

PC1.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", " "));

}else if (RW == 2){

GETARPMACPC2();System.out.print("\n\nPC2 ARP Table:" +

PC2.ARPTable.toString().replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", " "));

}}

The lines of code above show how the arp tables are filled with the valid MAC Address and IP address information. For example, look at when the integer R1 is equal to 1. It enters the if loop and calls the function PC1 and prints its details. The .replaceall method is used to remove the square brackets of the array list holding the arp table information for PC1.

public static void GETARPMACPC1() { if (PC1.Entry1.MACAddress == "") { PC1.Entry1.MACAddress = "00:e0:f7:94:8c:bb"; } }

64

Page 65: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Figure 48 - Simulation output after retrieving PC1 MAC Address.

The output in the simulation is shown in Figure 48, where ARP Table for PC1 is full.

Swing

The swing package was used in this simulation to display the pictures representing the network that the user has chosen to simulate. It is created in the Swing controls menu, by using the JLabel option and clicking icon the icon menu, there is an option to add a picture to your design, as shown below:

Click and Drag JLabel → Icon → External Imagine → Choose file to be displayed.

Figure 49 - Icon menu in JLabel selection pane.

Once created the piece of code below shows how the class is called in the main:

JFrame frame = new ThreeRouters_TwoPCs();frame.setTitle("Simulation of 3 Routers & 2 PC's");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);

This piece of code creates a new JFrame and retrieves the image matching the class title. It will give errors unless name is correct as is case sensitive. The next line of code allows the author to add a

65

Page 66: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

title to the imagine if they like. The next line is for the user closes the picture and the last line allows the user to view see the picture setting .setVisible(true) does this. The JFrame looks like the following when complete:

Figure 50 - Output of JLabel when called in code.

Problems Encountered

All of the problems encountered and how they were overcome are explained in the Background Design and Implementation chapters.

1. For the majority of the first semester all time and research was put into how a Ping works between certain devices. At first there was a ping from PC1 → PC2, which was the easiest to implement of all the scenarios. Next was the router in between two PC’s which was another step up. This required knowledge about how the router decides on which path to send the packet out on. These details had not been covered since 2nd year so more research and questions had to be done. Until a solution was found where the router logically ANDs the destination IP in the routing table.The next step up again was 2 Routers in between 2 PCs. This required a static route entry and took the most amount of time to write. Upon reflection the process is quite simple in theory but placing the correct addresses into the correct frames headers when coding the simulation got more challenging as the code increased in size.

2. The ARP Process and Echo Process. When carrying out networking labs in college you knew once two devices were able to ping one another, this was good. Unless stated otherwise. However, with packet tracer you don’t see all the processes happening in the background unless you enter the simulation and click the step by step process.When it came to ARP Requests and Echo Request message, a real understanding was only gathered once the frames for them had to be displayed in the simulation. Such as, what protocol does ARP use → 0806 and ICMP → 0800. What information goes into the frame header? Does it change once it arrives at each device? These steps are the ones that took most of the time.

3. As mentioned in the class relationships sub-chapter in the background chapter. These relationships were ones that were completely unfamiliar. Questions were asked as whether

66

Page 67: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

it would be a good idea or not to do this but it was. Class relationships are vital to any code as it shows the link that each class has to one another. Look to the example below:

Router1.IPAddress[0] = 0; //BeforeR1.PortA.IPAddress[0] = 0; //After

The first line shows no class relationship. It just simply states that Router 1 as an IP address entry for location 0. Whereas with second line, there is a class relationship. It shows that Router R1 has a port, and on that port there is an IP Address for location 0. Which is technically correct. With the first line, this is not correct.

4. This develops on the problem of class relationships. Once an understanding with both Inheritance and Composition were gathered the next step that caused problems was re-writing the code. As you can see in the appendices A and b below, they show the first draft of a class for a PC and a Router, but also show the updated correct version (C → H). Trying to write these parameters in code was quite challenging and to print out the correct information at each step is why the process nearly took a month to code correctly. This was very challenging and demanding.

5. This is an odd but a problem that kept arising quite often. When printing out information it’s hard to know what way it will appear on the display. Therefore, niggly changes had to be made each time something was displayed to make it match the correct format. An example of this is using the .replaceall method when removing characters from an array or the wrong IP Address appearing in an Ethernet Frame or routing table entry.

6. 2nd Year of Networking was the last time EIGRP was studied by the author of this simulation. Therefore, going back over and learning how the process worked again took a small amount of time, no real issues there. However, trying to implement something in code did. The main issues encountered were trying to figure out how to calculate cost in the simplest and efficient way.The cost algorithm took some time due to the fact that different conditions had to be written for different scenarios. There was some confusion as to how the algorithm worked by comparing the two highest links and choosing the smaller of the two.Also, how to update all the sufficient tables after the protocol was implemented was difficult too e.g. Routing Table, ARP Table, Static Route entries. It was solved by placing all the information into one location of the array at a time.

R1.RoutingTable[0] = ("\n\nD "+ X1+"."+ X2+"."+ X3+"."+ X4+"/8 {90/" + Br + "} via "+(Arrays.toString(R2.PortA.IPAddress)).replaceAll(",", ".").replaceAll("\\[", "").replaceAll("]", " ")+"/ 01:21:37/ "+R1.PortA.Interface +"\nC "+ y1+"."+ y2+"."+ y3+"."+ y4+"/30 is directly connected via " + R1.PortA.Interface);

Where Y1 and X1 etc. are integer values from the logical AND process.

67

Page 68: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

7. Array lists are an extremely handy function but trying to write them in code was tricky. The locations for them were created in the PC class and Router class but for some reason, the author created them in the main also therefore doubling the size of the ARP Table array when there was no need. This was discovered when the getsize() method of the array list revealed this. The error was corrected and the table returned to the correct size.

ARPTable.add(EA);ARPTable.add(EB);ARPTable.add(EC);

Three ARP Table entries were stored in the ARP Table and they would hold one IP Address and one MAC Address.

8. JLabels. Due to the fact that this simulation has no GUI interface pictures would represent what the network look like when chosen. There was an issue in trying to get a pop picture as several different methods had to be used. JOptionPane was used but had an okay button which as not needed. The simulation would then halt until the okay button was pressed meaning the network diagram disappeared. The Jlabel option worked perfectly because once it was called in popped up separately in a different window and did not interfere in the simulation whatsoever.

Summary of Implementation and Testing

The testing of each scenario in the simulation proves that the code works. When the EIGRP protocol is implemented all of the routers in the network get all of their entries updated with the correct information and are able to ping their neighbours. Once as all the addressing information is correct the code will route the packet to the correct destination and show the process along the way.

The one thing the simulation does lack from is more error handling capabilities and a smoother menu interface. More error handling capabilities would remove niggly bugs such as when an invalid number or character is entered, the simulation just ends the process rather than stating there is an error and allowing to re-enter the value. A smoother menu for the EIGRP section of the simulation would allow the user to exit back to where they last were or somewhere else rather than going back to the main menu or EIGRP menu.

68

Page 69: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Chapter 5 – Conclusion

This project simulation was able to run a network of two routers and two PC’s and a network of three routers and two PC’s. Whichever network has been chosen will display a network diagram. One the protocol was implemented there was a step by step process how the IMCP packet travels to and forth destinations. The destinations the packet travels are based on a cost parameter which is entered by the user. Which link costs the least will be the link chosen to reach the destination. This destination will then be entered into the routing tables of the routers in uses to reach this destination, denoted by a D at the being to represent EIGRP.

EIGRP protocol in this simulation also informs its neighbours about all routes in the network. Therefore, devices that are not connected to one another will know about each other. There is a cost equation option in the menu too which works out the cost of a link using the real life EIGRP cost formula, there is an option to send hello packets to a destination and also view all the entries that EIGRP updates to see if they have been updated correctly.

There were also other options in this simulation such as the Static Route option which would carrying out the pinging process like EIGRP except statically. There was an option to perform a logical AND for all the networks in the simulation. Finally, there was an option to view routing information and also edit it.

From this project I have learned and developed a lot of new skills. Before the semester began I knew very little about java programming apart from the beginner module I completed in 2nd year. I found the java language similar to that of C++, in terms out writing, but apart from that could find no other comparisons. It is a very powerful language which allows you the opportunity to do almost anything you please. Through research I learned a lot about this language such as classes, objects inside of them, how classes can interact with other classes by developing relationships, of which there a four different types.

I feel as though I know a lot more now about the basics of networking, more than I did previously. How packets are routed, different types of tables etc. I also became familiar with EIGRP again, in more detail this time than I had previously. This is an obvious statement but having to code the protocol means you have to know as many facts as you can about the protocol, to ensure the simulation is technically correct.

In order to develop the project to the next level, a GUI interface could have been implemented rather than a command line interface. This would have been much more user friendly and would have showed the packets actually travelling from hop to hop in the network. I hope this simulation could be used as a tool for learning students interested in networking about EIGRP.

69

Page 70: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Bibliography

Academy, C. N., 2003. CCNA 1 and 2 Companion Guide, third edition.. Indianapolis, Indiana 46290 USA: Cisco Press.

Cisco Networking Academy - Mark A. Dye, R. M. A. W. R., 2008. Computer Network Fundamentals, Section 2. Indianapolis, Indiana 46240 USA: Cisco Press.

Darker, A., 2015. ICND 2 200-101, Tallaght: IT Tallaght.

John Sexton, B. K. A. D., 2015. Introduction to the Network Layer, (IPv4), Tallaght: IT Tallagt.

John Sexton, B. K. A. D., 2015. Routers and Switches - Section 3 Routing Fundamentals, Tallaght: IT Tallaght.

John Sexton, M. C. J. B. D. M. A. D., 2013. Network Management, Tallaght: IT Tallaght.

Sexton, J., 2013. Enhanced Exterior Gateway Routing Protocol - EIGRP, Tallaght: IT Tallaght.

Sexton, J., 2016. Network Architectures and the OSI Model, Tallaght: IT Tallaght.

Yang, Y. D., 2007. Introduction to Java Programming, Comprehensive Version, 10th Edition.. In: Upper Saddle RIver, NJ: Pearson / Prentice Hall, p. 31. [5] [6]

Lynda.com - A LinkedIn Company. (2016). Lynda.com: Online Video Tutorials & Training. Available at: http://www.lynda.com

Liang, Y. (2007). Introduction to JAVA programming. Upper Saddle River, NJ: Pearson/Prentice Hall.

NetBeans. (2016). Oracle Corporation.

Packet Tracer. (2016). Cisco Networking Academy.

Visio. (2016). Microsoft.

[1] Sexton, J. (2016). Assigning Different Frame Types. Page 8

[2] EIGRP Hello Packet. (2010). [image] Available at: http://www.9tut.com/eigrp-routing-protocol-tutorial [Accessed 18 Apr. 2016].

[3] Cisco Networking Academy Program. (2005). Indianapolis, Ind.: Cisco Press. Page 756

[4] Cisco CCNA - Routing Protocols - EIGRP. (2016). Slide No. 8

70

Page 71: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendices

Appendix A

References package pc;//import static pc.Test_PC_Class.PC1_Info;//import static pc.Test_PC_Class.PC2_Info;

/** * * @author Adam */class PC{ ///////////////// PC //////////////////// public String pcName; // PC Name public String NetworkInterfaceCard; // PC NIC public String MAC_Address; // MAC Address PC public String Connection; // Connection Type public String Interface; // Interface public String Default_Gateway_MAC; public int FirstPart_IP; // 1st part of Network Address PC public int SecondPart_IP; // 2nd part of Network Address PC public int ThirdPart_IP; // 3rd part of Network Address PC public int FourthPart_IP; // 4th part of Network Address PC public int FirstPart_Sub; // 1st part of Subnet Maslk public int SecondPart_Sub; // 2nd part of Subnet Mask public int ThirdPart_Sub; // 3rd part of Subnet Mask public int FourthPart_Sub; // 4th part of Subnet Mask public int Default_Gateway_Prt1; public int Default_Gateway_Prt2; public int Default_Gateway_Prt3; public int Default_Gateway_Prt4; // Default Gateway public PC(String PCName, String NIC, String MAC, String CX, String Int1, int Part1_IP, int Part2_IP, int Part3_IP, int Part4_IP, int Part1_Sub, int Part2_Sub, int Part3_Sub, int Part4_Sub, int Def_Gate_Part1, int Def_Gate_Part2, int Def_Gate_Part3, int Def_Gate_Part4, String Def_Gate_MAC){// // ///////// PC1 ////////// this.pcName = PCName; this.NetworkInterfaceCard = NIC; this.MAC_Address = MAC; this.Connection = CX; this.Interface = Int1; this.FirstPart_IP = Part1_IP; this.SecondPart_IP = Part2_IP; this.ThirdPart_IP = Part3_IP; this.FourthPart_IP = Part4_IP; this.Default_Gateway_Prt1 = Def_Gate_Part1; this.Default_Gateway_Prt2 = Def_Gate_Part2; this.Default_Gateway_Prt3 = Def_Gate_Part3;

71

Page 72: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

this.Default_Gateway_Prt4 = Def_Gate_Part4; this.Default_Gateway_MAC = Def_Gate_MAC; ////////Network Subnet Mask////////// this.FirstPart_Sub = Part1_Sub; this.SecondPart_Sub = Part2_Sub; this.ThirdPart_Sub = Part3_Sub; this.FourthPart_Sub = Part4_Sub; }

public String toString(){ int x1 = 0; int x2 = 0; int x3 = 0; int x4 = 0; x1 = (FirstPart_IP & FirstPart_Sub); x2 = (SecondPart_IP & SecondPart_Sub); x3 = (ThirdPart_IP & ThirdPart_Sub); x4 = (FourthPart_IP & FourthPart_Sub); int y1 = 0; int y2 = 0; int y3 = 0; int y4 = 0; y1 = (FirstPart_IP & FirstPart_Sub); y2 = (SecondPart_IP & SecondPart_Sub); y3 = (ThirdPart_IP & ThirdPart_Sub); y4 = (FourthPart_IP & FourthPart_Sub); return "PC Name: " + pcName + "\nNIC Model: "+ NetworkInterfaceCard + "\nMAC Address: "+ MAC_Address + "\nConnection Type: "+ Connection + "\nInterface: " + Interface + "\n" + pcName + " Default Gateway: "+ Default_Gateway_Prt1 + "." + Default_Gateway_Prt2 + "." + Default_Gateway_Prt3 + "." + Default_Gateway_Prt4 + "\n" + pcName + " IP Address: " + FirstPart_IP + "." + SecondPart_IP + "." + ThirdPart_IP + "." + FourthPart_IP + "\n" + pcName + " Subnet Mask: " + FirstPart_Sub + "." + SecondPart_Sub + "." + ThirdPart_Sub + "." + FourthPart_Sub + "\n" + pcName + " Logical AND Result with area Subnet Mask: " + x1 + "." + x2 + "." + x3 + "." + x4 + "\n"; }}

72

Page 73: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix B

package pc;

import static pc.Test_PC_Class.PC1_Info;import static pc.Test_PC_Class.PC2_Info;import static pc.Test_PC_Class.R1_Info;import static pc.Test_PC_Class.R2_Info;

/** * * @author Adam */public class Router { ///////////////// Router 1 + 2 //////////////////// public String RouterName; // Router Name public String NetworkInterfaceCard; // Router NIC public String MAC_AddressInt1; // MAC Address of Router public String MAC_AddressInt2; public String Interface1Name; // Interface public String Interface2Name; public String Connection; // Connection Type public int Interface1_Prt1; // 1st part of Network Address Router int Fa0/0 public int Interface1_Prt2; // 2nd part of Network Address Router int Fa0/0 public int Interface1_Prt3; // 3rd part of Network Address Router int Fa0/0 public int Interface1_Prt4; // 4th part of Network Address Router int Fa0/0 public int Interface2_Prt1; // 1st part of Network Address Router int Fa0/1 public int Interface2_Prt2; // 2nd part of Network Address Router int Fa0/1 public int Interface2_Prt3; // 3rd part of Network Address Router int Fa0/1 public int Interface2_Prt4; // 4th part of Network Address Router int Fa0/1 public int Interface1_SubMaskPrt1; // 1st part of Subnet Mask Fa0/0 public int Interface1_SubMaskPrt2; // 2nd part of Subnet Mask Fa0/0 public int Interface1_SubMaskPrt3; // 3rd part of Subnet Mask Fa0/0 public int Interface1_SubMaskPrt4; // 4th part of Subnet Mask Fa0/0 public int Interface2_SubMaskPrt1; // 1st part of Subnet Mask Fa0/1 public int Interface2_SubMaskPrt2; // 2nd part of Subnet Mask Fa0/1 public int Interface2_SubMaskPrt3; // 3rd part of Subnet Mask Fa0/1 public int Interface2_SubMaskPrt4; // 4th part of Subnet Mask Fa0/1 public int Default_Gateway_RPrt1; public int Default_Gateway_RPrt2; public int Default_Gateway_RPrt3; public int Default_Gateway_RPrt4; // Default Gateway

73

Page 74: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

public Router(String RouterName, String R_NIC, String MAC_Int1, String MAC_Int2 ,String R_CX, String R_Inter1,String R_Inter2 , int Int1_Part1, int Int1_Part2, int Int1_Part3, int Int1_Part4, int Int2_Part1,int Int2_Part2, int Int2_Part3, int Int2_Part4, int Int1_SubPart1, int Int1_SubPart2, int Int1_SubPart3, int Int1_SubPart4,int Int2_SubPart1, int Int2_SubPart2, int Int2_SubPart3, int Int2_SubPart4, int Def_Gate_RPart1, int Def_Gate_RPart2, int Def_Gate_RPart3, int Def_Gate_RPart4) { ///////// Router 1 + 2 ////////// this.RouterName = RouterName; this.NetworkInterfaceCard = R_NIC; this.MAC_AddressInt1 = MAC_Int1; this.MAC_AddressInt2 = MAC_Int2; this.Interface1 = R_Inter1; this.Interface2 = R_Inter2; this.Connection = R_CX; this.Interface1_Prt1 = Int1_Part1; this.Interface1_Prt2 = Int1_Part2; this.Interface1_Prt3 = Int1_Part3; this.Interface1_Prt4 = Int1_Part4; this.Interface2_Prt1 = Int2_Part1; this.Interface2_Prt2 = Int2_Part2; this.Interface2_Prt3 = Int2_Part3; this.Interface2_Prt4 = Int2_Part4; this.Default_Gateway_RPrt1 = Def_Gate_RPart1; this.Default_Gateway_RPrt2 = Def_Gate_RPart2; this.Default_Gateway_RPrt3 = Def_Gate_RPart3; this.Default_Gateway_RPrt4 = Def_Gate_RPart4; ////////Network Subnet Mask////////// this.Interface1_SubMaskPrt1 = Int1_SubPart1; this.Interface1_SubMaskPrt2 = Int1_SubPart2; this.Interface1_SubMaskPrt3 = Int1_SubPart3; this.Interface1_SubMaskPrt4 = Int1_SubPart4; this.Interface2_SubMaskPrt1 = Int2_SubPart1; this.Interface2_SubMaskPrt2 = Int2_SubPart2; this.Interface2_SubMaskPrt3 = Int2_SubPart3; this.Interface2_SubMaskPrt4 = Int2_SubPart4; } public String toString(){ int z1=0; int z2=0; int z3=0; int z4=0; z1 = ((Interface1_Prt1) & (Interface1_SubMaskPrt1)); z2 = ((Interface1_Prt2) & (Interface1_SubMaskPrt2)); z3 = ((Interface1_Prt3) & (Interface1_SubMaskPrt3)); z4 = ((Interface1_Prt4) & (Interface1_SubMaskPrt4)); int a1=0; int a2=0; int a3=0; int a4=0; a1 = ((Interface2_Prt1) & (Interface2_SubMaskPrt1)); a2 = ((Interface2_Prt2) & (Interface2_SubMaskPrt2)); a3 = ((Interface2_Prt3) & (Interface2_SubMaskPrt3)); a4 = ((Interface2_Prt4) & (Interface2_SubMaskPrt4)); return "Router Name: "+ RouterName + "\nNIC Model: "+ NetworkInterfaceCard + "\nConnection Type: "+ Connection

74

Page 75: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

+ "\nInterface: " + Interface1 + "\nInterface: " + Interface2 + "\nMAC Address for Interface Fa0/0: "+ MAC_AddressInt1 + "\nFa0/0 IP Address: " + Interface1_Prt1 + "." + Interface1_Prt2 + "." + Interface1_Prt3 + "." + Interface1_Prt4 + "\nFa0/0 Subnet Mask: " + Interface1_SubMaskPrt1 + "." + Interface1_SubMaskPrt2 + "." + Interface1_SubMaskPrt3 + "." + Interface1_SubMaskPrt4 + "\nMAC Address for Interface Fa0/1: "+ MAC_AddressInt2 + "\nFa0/1 IP Address: " + Interface2_Prt1 + "." + Interface2_Prt2 + "." + Interface2_Prt3 + "." + Interface2_Prt4 + "\nFa0/1 Subnet Mask: " + Interface2_SubMaskPrt1 + "." + Interface2_SubMaskPrt2 + "." + Interface2_SubMaskPrt3 + "." + Interface2_SubMaskPrt4 + "\n" + RouterName + " Logical AND Result Interface " + Interface1 + "with area Subnet Mask: " + z1 + "." + z2 + "." + z3 + "." + z4 + "\n" + RouterName + " Logical AND Result Interface " + Interface2 + + a1 + "." + a2 + "." + a3 + "." + a4 + "\n"; }}

75

Page 76: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix C

package pc_class;/** * * @author Adam */public class Basic_Port { public int IPAddress[] = {0,0,0,0}; public int SubnetMask[] = {0,0,0,0}; public String MACAddress; public String Interface;

public Basic_Port(int IPAdd0, int IPAdd1, int IPAdd2, int IPAdd3, int SubMask0, int SubMask1, int SubMask2, int SubMask3, String MACAdd, String Int){ IPAddress[0] = IPAdd0; IPAddress[1] = IPAdd1; IPAddress[2] = IPAdd2; IPAddress[3] = IPAdd3; SubnetMask[0] = SubMask0; SubnetMask[1] = SubMask1; SubnetMask[2] = SubMask2; SubnetMask[3] = SubMask3; MACAddress = MACAdd; Interface = Int; } public String toString(){ return String.format("IP Address: %d.%d.%d.%d\nSubnet Mask: %d.%d.%d.%d\nMAC Address: %s\n\nInterface: %s", IPAddress[0], IPAddress[1] ,IPAddress[2] ,IPAddress[3], SubnetMask[0], SubnetMask[1], SubnetMask[2], SubnetMask[3], MACAddress, Interface); } }

76

Page 77: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix D

package pc_class;import pc_class.Basic_Port;/** * * @author Adam */public class PC_Port extends Basic_Port { public String Name; public int DefaultGateway[] = {0,0,0,0};

public PC_Port(String pcName,int IPAdd0, int IPAdd1, int IPAdd2, int IPAdd3, int DefGate0, int DefGate1, int DefGate2, int DefGate3, int SubMask0, int SubMask1, int SubMask2, int SubMask3, String MACAdd,int cost, String Int){ super(IPAdd0, IPAdd1, IPAdd2, IPAdd3, SubMask0, SubMask1, SubMask2, SubMask3, MACAdd, Int); Name = pcName; DefaultGateway[0] = DefGate0; DefaultGateway[1] = DefGate1; DefaultGateway[2] = DefGate2; DefaultGateway[3] = DefGate3; //PC_Class PC1 = new PC_Class("PC1", "192", 192, 168, 1, 2, Port2, Cxn1Detail); }

public String toString(){ return String.format("\nPort Name: %s\nInterface: %s\nIP Address: %d.%d.%d.%d\nDefault Gateway: %d.%d.%d.%d\nSubnet Mask: %d.%d.%d.%d\nMAC Address: %s", Name,Interface,IPAddress[0], IPAddress[1] ,IPAddress[2] ,IPAddress[3], DefaultGateway[0], DefaultGateway[1], DefaultGateway[2], DefaultGateway[3], SubnetMask[0], SubnetMask[1], SubnetMask[2], SubnetMask[3], MACAddress); } }

77

Page 78: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix E

package pc_class;/** * * @author Adam */public class Router_Port extends Basic_Port { public String Name; public String Protocol; public Router_Port(String RName, String RTable, String Int,int IPAdd0, int IPAdd1, int IPAdd2, int IPAdd3,int SubMask0, int SubMask1, int SubMask2, int SubMask3, String MACAdd){ super(IPAdd0, IPAdd1, IPAdd2, IPAdd3, SubMask0, SubMask1, SubMask2, SubMask3, MACAdd, Int); Name = RName; Protocol = RTable; } public String toString(){ return String.format("\nPort Name : %s\nProtocol: %s\nInterface: %s\nIP Address: %d.%d.%d.%d\nSubnet Mask: %d.%d.%d.%d\nMAC Address: %s\nS", Name, Protocol, Interface, IPAddress[0], IPAddress[1] ,IPAddress[2] ,IPAddress[3], SubnetMask[0], SubnetMask[1], SubnetMask[2], SubnetMask[3], MACAddress); } }

78

Page 79: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix F

package pc_class;

import java.util.ArrayList;

/** * * @author Adam */public class PC { public PC_Port Port = new PC_Port("",0,0,0,0,0,0,0,0,0,0,0,0,"",0,""); public ArrayList <ARPTableEntry> ARPTable = new ArrayList<>(); public ARPTableEntry Entry1 = new ARPTableEntry(0,0,0,0,""); public String Name;

public PC(String name, PC_Port Pt, ARPTableEntry T) { Name = name; Port = Pt; Entry1 = T; ARPTable.add(T); }

@Override public String toString() { return "\n\tName: " + Name + "\n" + Port+ "\n\nARP Table Information:" + ARPTable.get(0); }

}

79

Page 80: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix G

package pc_class;

import java.util.ArrayList;import java.util.Arrays;

/** * * @author Adam */public class Router { public String Name; public Router_Port PortA = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public Router_Port PortB = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public Router_Port PortC = new Router_Port("","","",0,0,0,0,0,0,0,0,""); public ARPTableEntry EntryA = new ARPTableEntry(0,0,0,0,""); public ARPTableEntry EntryB = new ARPTableEntry(0,0,0,0,""); public ARPTableEntry EntryC = new ARPTableEntry(0,0,0,0,""); public ArrayList <ARPTableEntry> ARPTable = new ArrayList<>(); public String RoutingTable[] = {"", "\n", "\n", "\n"}; public int StaticRoute[] = {0,0,0,0}; public Router(String name, String RT0, String RT1, String RT2, String RT3, Router_Port PA, Router_Port PB, Router_Port PC, ARPTableEntry EA, ARPTableEntry EB, ARPTableEntry EC, int SR0, int SR1, int SR2, int SR3) { Name = name; RoutingTable[0] = RT0; RoutingTable[1] = RT1; RoutingTable[2] = RT2; RoutingTable[3] = RT3; PortA = PA; PortB = PB; PortC = PC; EntryA = EA; EntryB = EB; EntryC = EC; StaticRoute[0] = SR0; StaticRoute[1] = SR1; StaticRoute[2] = SR2; StaticRoute[3] = SR3; ARPTable.add(EA); //[0] ARPTable.add(EB); //[1] ARPTable.add(EC); //[2] }

@Override public String toString() { return "\n\tName: " + Name + "\n" + "Static Route :" + StaticRoute[0] + "." + StaticRoute[1] + "." + StaticRoute[2]+ "." + StaticRoute[3] + PortA + "\n\nARP Table Information:" + ARPTable.get(0) +

80

Page 81: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

"\n" + PortB + "\n\nARP Table Information:" + ARPTable.get(1)+ "\n" + PortC + "\n\nARP Table Information:" + ARPTable.get(2) + "\n\nRouting Table: \n" + Arrays.toString(RoutingTable).replaceAll(",", "").replaceAll("\\[", " ").replaceAll("]", "\n"); } //Arrays.toString(RoutingTable) //"\n\tName: " + Name + "\n" + PortA + "\n\nARP Table Information:" + ARPTable.toString() + "\n" + PortB + "\n\nRouting Table: \n" + Arrays.toString(RoutingTable);}

81

Page 82: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

Appendix H

package pc_class;import java.util.ArrayList;

/** * * @author Adam */public class ARPTableEntry { public int IPAddress[] = {0,0,0,0}; public String MACAddress;// ArrayList<ARPTable>

public ARPTableEntry(int IP0, int IP1, int IP2, int IP3, String MACAdd) { IPAddress[0] = IP0; IPAddress[1] = IP1; IPAddress[2] = IP2; IPAddress[3] = IP3; MACAddress = MACAdd; }

public String toString(){ return String.format("\nInternet Address: %d.%d.%d.%d\nPhysical Address: %s", IPAddress[0],IPAddress[1],IPAddress[2],IPAddress[3],MACAddress ); }}

82

Page 83: AdamCarroll_Semester8Report_X00104026

Adam Carroll X00104026

83