Snmp and programming implementation

First, the detailed explanation of snmp programming

SNMP is a remote monitoring application built on TCP/UDP. It monitors various information about hosts on the network, such as memory usage, CPU usage, and disk usage. It is mainly divided into two parts, which are installed on the SNMP server of the host to be monitored. It is used to collect the information of the host and organize it according to the tree. The SNMP client installed on the monitoring end sends a query command in real time to obtain the monitored host. Running information.

SNMP server: Organize host information in a tree, somewhat similar to the Windows registry, but much simpler. The tree structure is shown below.

Snmp and programming implementation

Where the root is empty, each child node is assigned a number, and the root node is connected to the leaf node by a dot (.)

The number on the path can be used to locate the information of the query. It can be accessed as shown in Fig. 1.3.6.1.2.1.2. Iso. Org. Dod. Internet. Mgmt. Mib-2. Information about interfaces.

SNMP client: Sends a query request to the SNMP server. There are two main types of requests. The GET request can get the specified information; GETNEXT gets the next message.

In another case, the SNMP server actively sends a TRAP message to the SNMP monitoring terminal when the abnormal event is detected. At this time, the SNMP client acts as a server and processes the abnormal information.

Second, SNMP installation

Generally linux comes with. You can check if it is installed by using the whereis snmpd query. If not, download the net-snmp installation. (self search)

Installation: 1) Source installation:. /configure;make;make install

2) Package Manager installation: centos:yum install net-snmp

Yum install net-snmp-devel (required for development environment)

Yum install net-snmp-uTIls (test environment required)

Third, SNMP configuration

SNMP server configuration: There is an EXAMPLE.conf in the source code, copy it to a configuration file directory of its choice (assuming /usr/local/etc/snmp/), and rename it to snmpd.conf.

Modify the configuration parameters inside:

1) Find the view systemonly included .1.3.6.1.2.1.1 and insert a line above view systemonly included .1

Indicates that all information below the root can be viewed

2) Change 127.0.0.1 in agentAddress udp:127.0.0.1:161 to the external IP address of the machine so that it can be accessed remotely.

Fourth, testing and problems

1) Run the service snmpd start installed with the package manager; run the source installation [snmpd absolute path] -c /usr/local/etc/snmp/snmpd.conf

2) Run snmpwalk -v 1 localhost -c public .1 on the monitored machine to see if there is output.

3) Run snmpwalk -v 1 on the monitoring host [IP address of the monitored machine] -c public .1 to see if there is output

If remote access is not possible, turn off the firewall of the monitored host: service iptables stop

Change the selinux mode: set enforce 0

Five, SNMP C programming

NET-SNMP provides a flexible interface. An external program can be added to the snmpd.conf file of the monitored host. When the monitoring host issues a query command, the program is executed once. This gives you the flexibility to develop various monitoring programs.

Such as adding a line in snmpd.conf

Extend .1.3.6.1.4.1.2021.50 monitor /bin/sh /tmp/monitor.sh

It is possible to monitor the host to execute the monitor.sh script each time the .1.3.6.1.4.1.2021.50 value of the monitored host is queried.

Monitor.sh can be written like this:

#! /bin/bash

Echo "my snmp test"

On the monitoring host side, the results of the query need to be processed. Programming in C language is as follows:

#include "net-snmp/net-snmp-config.h"

#include "net-snmp/net-snmp-includes.h"

#include 《string.h》

Int find_last_oid (netsnmp_session * ss, oid *base, int base_length){

Netsnmp_pdu *response;

Netsnmp_pdu *pdu;

Int running = 1;

Int status;

Int length=0;

Pdu = snmp_pdu_create (SNMP_MSG_GETNEXT);

Snmp_add_null_var (pdu, base, base_length);

While (running){

Status = snmp_synch_response (ss, pdu, &response);

If (status != STAT_SUCCESS || !response){

Snmp_sess_perror ("snmp_synch_response", ss);

Exit (1);

}

If (response-"errstat != SNMP_ERR_NOERROR){

Fprintf (stderr, "snmp: Error in packet: %s", snmp_errstring (response-"errstat));

Exit (1);

}

If (response &&snmp_oid_compare (response-"variables-"name, SNMP_MIN (base_length, response-"variables-"name_length), base, base_length) != 0)

Running = 0;

Else{

Memcpy(base,response-"variables-"name,response-"variables-"name_length*sizeof(oid));

Length=response-"variables-"name_length;

Pdu = snmp_pdu_create (SNMP_MSG_GETNEXT);

Snmp_add_null_var (pdu, response-"variables-"name, response-"variables-"name_length);

}

Snmp_free_pdu (response);

}

Return length;

}

Int main(){

Netsnmp_session session, *ss;

Netsnmp_pdu *pdu;

Netsnmp_pdu *response;

Struct variable_list *vars;

Oid base[128]={1,3,6,1,4,1,2021,50};

Size_t base_length=8;

Int status;

Init_snmp ("APC Check");

Snmp_sess_init (&session);

Session.version = SNMP_VERSION_1;

Session.community = (u_char*) "public";

Session.community_len = strlen ((const char*)session.community);

Session.peername = "10.0.1.3"; / / IP address of the monitored host

Ss = snmp_open (&session);

If (ss == NULL){

Snmp_sess_perror ("snmp_open", &session);

Exit (1);

}

Int new_length=find_last_oid (ss, base, base_length);

Pdu = snmp_pdu_create (SNMP_MSG_GET);

Snmp_add_null_var (pdu, base, new_length);

Status = snmp_synch_response (ss, pdu, &response);

If (status != STAT_SUCCESS || !response){

Snmp_sess_perror ("snmp_synch_response", ss);

Exit (1);

}

For(vars = response-"variables; vars; vars = vars-"next_variable){

Int i;

For(i=0;i"vars-"name_length;i++){

Printf("%d",vars-"name[i]);

}

Print_value(vars-"name, vars-"name_length, vars);

}

Snmp_free_pdu (response);

Snmp_close (ss);

Return 0;

}

8 Layer PCB

8 Layer PCB - Stackup & Cost & Prototype manufacture

What is 8 layer PCB?

The 8 layer PCB is a circuit board with 8 layers that are stacked firmly together with predefined and dependable mutual connections between the layers. Structure of eight layer PCB is more complicated. Nowadays, PCBs frequently have 8 to 12 layers or more, and electronics engineers know that designing for so many layers requires a well-configured layer stack.


8-layer printed circuit boards are usually installed in compact equipment with strict spacing requirements, such as notebook computer motherboard, communication backplane, wearable watches, etc. Because of its complexity and high manufacturing costs, your 8-layer PCB manufacturing should be made by reliable and experienced manufacturers. Jinghongyi PCB has been specially targeting high-end PCB manufacturing and assembly services for 8 years, providing high-quality products and services for various customers. Our advanced production line and fast response team will keep you comfortable and reassured, without any trouble, you can rest assured to place the order with us.


8L PCB



Typical 8-layer PCB stack up methods and guidelines


Standard stackup of 8 layer PCB looks as follows

  1. Signal1
  2. Ground
  3. Signal2
  4. Power
  5. Ground
  6. Signal3
  7. Power
  8. Signal4

Eight-layer PCB can be used to add two additional layers, or two planes can be added to improve EMC performance. Most eight-layer circuit boards are superimposed to improve EMC performance, rather than adding additional wiring layers. Compared with 6-layer circuit boards, the cost increase percentage of 8-layer PCB is less than that of 4-layer PCB to 6-layer PCB. Therefore, in order to improve EMC performance, the cost increase is reasonable. Therefore, most 8-layer boards consist of four wiring layers and four planes.

8 layer PCB stackup | JHYPCB

8 Layer PCB Stack up

8 Layer PCB Stack up

8 Layer PCB stackup


In short, 8 layer PCB are usually used to improve the EMC performance of circuit boards, rather than increasing the number of layers.

No matter how you decide on the stack layer, it is not recommended to use an 8-layer PCB board with six wiring layers. If you need six routing layers, you should use a 10 Layer PCB board. Therefore, the 8-layer board can be regarded as the six-layer board with the best EMC performance.



Basic Layer of Eight-Layer Circuit Board with Excellent EMC Performance


The basic stack-up of an eight-layer board with excellent EMC performance

All signal layers are adjacent to the plane, and all layers are tightly coupled. High-speed signals are buried between planes, so planes provide shielding to reduce the transmission of these signals. In addition, the circuit board uses multiple grounding layers to reduce the grounding impedance.



Other forms of 8-layer PCB stackup


A typical 8 Layer PCB Stackup

A typical 8 Layer PCB Stackup

0.062[8 layer PCB stackup

0.062[8 layer PCB stackup

0.093[ 8-Layer PCB Stackup

0.093[ 8-Layer PCB Stackup


Let's conclude that using more than eight layers of PCB has almost no EMC advantage. Usually only 8 layers are used when additional layers are needed for signal tracking routing. If six layers of wiring are needed, 10 layer PCB should be used.

So far, we have also clarified the cost and price differences between 6-layer PCB, 8-layer PCB and 10-layer PCB.



8 Layer PCB thickness

8 LAYER 1.6 MM STANDARD STACKUP AND THICKNESS

8 LAYER 1.6 MM STANDARD STACKUP AND THICKNESS

8 Layer Stackup - 1.6mm thickness

layer order layer name material type material description dielectric constant thickness copper weight
1 top copper signal 0.035mm 1 oz
2116 prepreg 4.5 0.12mm
2 inner 1 copper plane 1 oz
core 4.6 0.3mm
3 inner 2 copper plane 1 oz
7630 prepreg 4.7 0.2mm
4 inner 3 copper plane 1 oz
core 4.6 0.3mm
5 inner 4 copper plane 1 oz
7630 prepreg 4.7 0.2mm
6 inner 5 copper plane 1 oz
core 4.6 0.3mm
7 inner 5 copper plane 1 oz
2116 prepreg 4.5 0.12mm
8 bottom copper signal 0.035mm 1 oz
Final board thickness: 1.6mm±0.13mm




8-Layer Prototype PCB Manufacturing Service


The 8-layer prototype FR-4 PCB is an 8-layer circuit board, which is firmly stacked together with predefined and reliable interconnection between layers. The 8-layer FR-4 PCB has more complex structure. JHYPCB is a large enterprise located in Shenzhen, China, which can manufacture 8-layer prototype PCB.

JHYPCB can provide you with multi-layer PCB board in accordance with RoHS standard. With laminated material, it can match high temperature in assembly process. Importantly, some lead-free assembly processes will require laminated substrates to withstand temperatures exceeding 260 degrees Celsius or 500 degrees Fahrenheit over a longer period of time. To solve this problem, we have high temperature laminates in stock, so that our customers can meet the higher temperature cycle requirements of some lead-free assembly applications.


JHYPCB is one of the leading 8 layer PCB manufacturers. For more information, pls send email to us.

Eight Layer PCB


PCB Circuit Board,8 Layer PCB,Custom multilayer pcb,Custom 8 Layer PCB

JingHongYi PCB (HK) Co., Limited , https://www.pcbjhy.com

This entry was posted in on