Part 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Introduction:

SnmpGetNext.java is an illustrative code snippet showcasing the


implementation of a basic SNMP operation using the AdventNetSNMP
API's com.adventnet.snmp.snmp2 package. Its primary purpose is to
demonstrate the GET NEXT operation. To execute this program, you can
provide command-line arguments such as the hostname and OID(s) of the
desired SNMP agent(s). Upon execution, the program utilizes the SNMP
API to connect to the specified agent(s) and retrieve the designated
information.

The code begins by importing necessary classes and packages from both
the Java language and the AdventNetSNMP API. The program's main
method accepts two arguments: the remote hostname of the SNMP agent
and the OID of the object to be fetched. Subsequently, the API is initiated,
and a new SNMP Session is established to facilitate communication with
the SNMP agent. The session is then opened, and the community is set to
the default value of "teaching labs," which corresponds to the host's
community.

Following that, the program initializes variables and sets up an ArrayList of


OIDs to be fetched from the agent. Within a loop, the program retrieves the
specified OIDs and performs calculations on the obtained values.
Specifically, it acquires information concerning TCP and IP traffic and
computes metrics such as the average throughput and UWMA (weighted
moving average) of the data. The calculated values are then printed to the
console.

The program continues to iterate and fetch the designated OIDs until the
user manually terminates it.
Program Design:
Program design is a critical phase in software development where careful
planning and structuring take place to create a well-organized and
functional computer program. It involves analyzing the problem or task at
hand, breaking it down into manageable components, and determining how
these components will interact to achieve the desired outcome.
During program design, thorough consideration is given to defining the
inputs, processing steps, and expected outputs. The program's architecture
is meticulously designed, outlining the modules or components and
establishing smooth data and control flow between them. Data structures
are carefully selected and designed to ensure efficient storage and
manipulation of information. In cases where user interaction is required,
user interface design focuses on creating an intuitive and user-friendly
experience.

The significance of program design lies in its ability to produce code that is
well-structured, efficient, and aligned with the intended requirements. This
approach enhances the readability, maintainability, and scalability of the
program, simplifying the development, debugging, and future enhancement
processes.

By diligently following the program design process, software developers


can create a solid blueprint that guides them towards successfully
implementing a reliable and functional software solution.

Outline of Program design in form pseudo code:


// Initialize variables
String agent = "192.168.0.1";
String community = "public";
String oid = "1.3.6.1.2.1.2.2.1.10";
// Create SnmpAPI instance
SnmpAPI api = new SnmpAPI();

// Start SnmpAPI
api.start();

// Create SnmpSession
SnmpSession session = new SnmpSession(api);

// Open session with agent


session.open(agent, community);

// Initialize ArrayList for retrieved values


ArrayList<Integer> values = new ArrayList<Integer>();

// Loop to retrieve and analyze SNMP data


while (true) {
// Retrieve next value of OID using GETNEXT operation
SnmpPDU pdu = session.snmpGetNext(oid);

// Check if error occurred


if (pdu.getErrstat() != 0) {
System.out.println("Error: " + pdu.getError());
break;
}
// Add retrieved value to ArrayList
values.add((Integer)pdu.getVariable().toValue());

// Perform calculations based on retrieved values


int throughput = calculateThroughput(values);
int uwma = calculateUwma(values);
int windowSize = calculateWindowSize(values);

// Print calculated values to console


System.out.println("Throughput: " + throughput);
System.out.println("UWMA: " + uwma);
System.out.println("Window Size: " + windowSize);
}

// Close session
session.close();

// Stop SnmpAPI
api.stop();

Outline of Program design in form of flow chart:


Screenshots of Output 1:
Validation:
When I first set out to validate the results of my network traffic
monitoring program, I knew that I needed to display the calculated
values of network parameters in a clear and concise way. That's why I
made sure to format the output of the program to display the values of
throughput, window size, and UWMA of TCP traffic on the console. By
doing this, I was able to easily see the values of these parameters in
real-time as the program retrieved new SNMP data from the specified
OID.

Of course, I also knew that the accuracy of the program's output


depended on the SNMP data available on the network device being
monitored. To ensure that I was getting the most accurate data possible,
I ran the program on a machine with all the necessary dependencies
and a properly configured SNMP device. This helped me to make sure
that the program was producing reliable and accurate results.

Once I had the program up and running, I turned my attention to


validating the results of the UWMA calculations. To do this, I compared
the UWMA values obtained from the program with the manually
calculated values. This involved using a mathematical formula to
calculate the UWMA manually, and then comparing the manually
calculated values with the values produced by the program.

The formula I used to calculate UWMA is:

UWMA_t = ((1 - α) * UWMA_t-1) + (α * Y_t)


Where UWMA_t is the current UWMA value at time t, α is the smoothing
factor (usually between 0 and 1), UWMA_t-1 is the previous UWMA
value at time t-1, and Y_t is the current value at time t.

By comparing the UWMA values produced by the program with the


manually calculated values, I was able to determine whether the
program was producing accurate results. If the values were the same or
similar, I could be confident that the program was working correctly.

To further ensure the accuracy and consistency of the program's results,


I repeated the validation process with different data sets and
parameters. This helped me to identify any potential issues or errors in
the program's calculations and to make any necessary adjustments.

Overall, by carefully validating the results of my network traffic


monitoring program, I was able to ensure that the calculated network
parameters were correct and reliable. This gave me confidence in the
accuracy of the program's output and helped me to make informed
decisions about network performance based on the data it provided.

You might also like