Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2. [20 Marks] Write a program in Java/C/Python to simulate the bridge learning process. At the beginning, the application should ask the user to enter

Q2. [20 Marks] Write a program in Java/C/Python to simulate the bridge learning process. At the beginning, the application should ask the user to enter how many ports the bridge will have (max 8), and then assign a port number from 1 to N, where N is the number of ports entered by the user. Your program will then read the incoming frames (one per line) from a given input file (you may ask the user to enter the input file name). The following shows an example of some entries in the input file: 1a:23:4b:2c:df:c1 11:2b:3c:ac:df:12 2 1a:23:4b:22:11:34 12:aa:cc:df:ac:10 3 1a:23:4b:2c:df:c1 aa:bb:cc:df:ac:22 2 aa:bb:cc:df:ac:22 1a:23:4b:22:11:34 1

Each line of the input file will contain three values separated by one or more spaces. First two values represent the source and destination MAC addresses respectively, and then the third value indicates the incoming port number of the frame (i.e., at which port this frame arrived). Note that, the source and destination MAC addresses are dummy addresses (could be any strings), but incoming port must be an integer from 1 to N, where N is the number of ports entered by the user at the starting of the program. The input file may contain any number of lines. Your code should ignore an invalid entry. For example, if a line includes less than 3 values or the incoming port number is out of range.

Based on the frames in the input file, your program should learn and populate the forwarding database (FDB) for the bridge according to the bridge learning algorithm [you can ignore the frame error checking].

Your program should produce an output file (fdb.txt). For each frame (line) in the input file, your program should first print the appropriate action taken by the bridge for that frame followed by the current values of the FDB (see the example output format). For example, for the example input file, the output file should look like the following:

Action: add to FDB (index 1); forward to all out ports: 1, 3 ------------------------------------------------- | Indx | Host | Port | ------------------------------------------------- | 1 | 1a:23:4b:2c:df:c1 | 2 |

------------------------------------------------- Action: add to FDB (index 2); forward to all out ports: 1, 2 ------------------------------------------------- | Indx | Host | Port | ------------------------------------------------- | 1 | 1a:23:4b:2c:df:c1 | 2 | | 2 | 1a:23:4b:22:11:34 | 3 | ------------------------------------------------- Action: found at index 1(no update); forward to all out ports: 1, 3 ------------------------------------------------- | Indx | Host | Port | ------------------------------------------------- | 1 | 1a:23:4b:2c:df:c1 | 2 | | 2 | 1a:23:4b:22:11:34 | 3 |

------------------------------------------------- Action: add to FDB (index 3); forward to port: 3 ------------------------------------------------- | Indx | Host | Port | ------------------------------------------------- | 1 | 1a:23:4b:2c:df:c1 | 2 | | 2 | 1a:23:4b:22:11:34 | 3 | | 3 | aa:bb:cc:df:ac:22 | 1 | -------------------------------------------------

Your program should closely resemble the output format shown here with all possible actions taken by the bridge. Test your code thoroughly and handle exceptions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago