Ex. No. 14 B) - Applications Using TCP and UDP - SNMP
Ex. No. 14 B) - Applications Using TCP and UDP - SNMP
PROBLEM STATEMENT:
To write a program to implement a Simple Network Management Protocol (SNMP) server and client
using Twisted framework to enable communication between network devices for managing and
monitoring purposes.
PROBLEM DESCRIPTION:
Simple Network Management Protocol (SNMP) is an application-layer protocol for monitoring and
managing network devices on a local area network (LAN) or wide area network (WAN).
The purpose of SNMP is to provide network devices, such as routers, servers and printers, with a
common language for sharing information with a network management system (NMS).
1. an SNMP manager;
The SNMP manager acts as the client, the SNMP agent acts as the server and the MIB acts as the
server's database. When the SNMP manager asks the agent a question, the agent uses the MIB to
supply the answer.
Components of SNMP
There are four main components in an SNMP-managed network.
• SNMP agent
• Agent software runs on the hardware or service being monitored, collecting data about
disk space, bandwidth use and other important network performance metrics.
• SNMP-managed network nodes
• These are the network devices and services upon which the agents run.
• SNMP manager
• The NMS is a software platform that functions as a centralized console to which agents
feed information. The NMS will actively request agents to send updates at regular
intervals.
• Management information base
• This MIB database is a text file (.mib) that itemizes and describes all objects on a
particular device that can be queried or controlled using SNMP. Each MIB item is
assigned an object identifier (OID).
ALGORITHM:
Server Side
Step 1: Create a SNMP server using the Twisted framework.
Step 2: Listen for incoming SNMP requests on a specific port.
Step 3: When a request is received, extract the data from the request.
Step 4: Process the SNMP request data to determine the appropriate response.
Step 5: Prepare the response message based on the processed request data.
Step 6: Send the response message back to the client that made the request.
Client Side
Step 1: Create a SNMP client using the Twisted framework.
Step 2: Establish a connection with the SNMP server by specifying the server's IP addressand port
number.
Step 3: Construct an SNMP request message.
Step 4: Send the SNMP request message to the server.
Step 5: Wait for the response from the server.
Step 6: Upon receiving the response, extract and process the response data as needed.
CODE:
SENDER SIDE:
zrom twisted.internet import reactor
from twisted.internet.protocol import DatagramProtocol
class SNMPProtocol(DatagramProtocol): def data-
gramReceived(self, data, addr):
print("Received data from {}: {}".format(addr, data))
# Process the SNMP request here and prepare the responseresponse =
"SNMP response"
self.transport.write(response.encode(), addr)
def run_server():
reactor.listenUDP(161, SNMPProtocol())reactor.run()
run_server
RECEIVER SIDE:
from twisted.internet import reactor
from twisted.internet.protocol import DatagramProtocol
class SNMPClientProtocol(DatagramProtocol):def
startProtocol(self):
self.transport.connect('127.0.0.1', 161)self.sendRe-
quest()
def sendRequest(self):
request = "SNMP request"
self.transport.write(request.encode())
def run_client():
reactor.listenUDP(0, SNMPClientProtocol())reac-
tor.run()
run_client()
SAMPLE INPUT/OUTPUT:
SERVER SIDE
CLIENT SIDE
RESULT: Thus, the Simple Network Management Protocol (SNMP) using Twisted Python was
implemented and tested successfully.