Luận văn Kiến trúc hệ thống quản trị mạng dựa trên XML
MỤC LỤC
Trang phụ bìa
Lời cam đoan
Lời cảm ơn
Mục lục . i
Danh mục các ký hiệu, các chữ viết tắt . iii
Danh mục các bảng . iv
Danh mục các hình .v
MỞ ĐẦU . i
CHƢƠNG 1 - TỔNG QUAN VỀ CÁC KIẾN TRÚC QUẢN TRỊ MẠNG. 2
1.1 Giới thiệu . 2
1.2 Kiến trúc mạng. 6
1.2.1 Mô hình OSI . 6
1.2.2 Mô hình TCP/IP . 9
1.3 Kiến trúc và mô hình quản trị mạng . 10
1.3.1 Kiến trúc và mô hình quản trị mạng OSI . 10
1.3.2 Kiến trúc và mô hình quản trị mạng SNMP . 14
1.3.3 Kiến trúc quản trị tích hợp OMP . 20
1.4 Kết luận chƣơng 1 . 23
CHƢƠNG 2 - KIẾN TRÚC HỆ THỐNG QUẢN TRỊ MẠNG DỰA TRÊN XML . 25
2.1 Giới thiệu . 25
2.2 Những kỹ thuật liên quan đến XML . 26
2.3 Kiến trúc quản trị mạng dựa trên XML . 27
2.4 Nghiên cứu về quản trị mạng dựa trên XML . 32
2.4.1 Mô hình quản trị mạng dựa trên XML . 32
2.4.2 Hoạt động của kiến trúc quản trị mạng dựa trên XML . 35
2.4.3 Tích hợp XML - SNMP . 37
2.4.4 Kiến trúc quản trị tích hợp dựa trên Web . 38
2.5 Phƣơng pháp để quản trị mạng tích hợp dựa trên XML . 41
2.5.1 Bốn phƣơng pháp cho tích hợp . 41
2.5.2 Sự so sánh giữa 4 phƣơng pháp . 43
2.6 Thiết kế hệ thống quản trị dựa trên XML . 44
2.6.1 Manager dựa trên XML . 44
2.6.2 Agent dựa trên XML . 46
2.6.3 Hệ thống quản trị XGEMS . 47
2.7 Kết luận chƣơng 2 . 52
CHƢƠNG 3 - PHÁT TRIỂN CHUYỂN ĐỔI CỔNG XML/SNMP CHO QUẢN
TRỊ MẠNG TÍCH HỢP DỰA TRÊN XML . 53
3.1 Giới thiệu . 53
3.2 Công việc liên quan và đề xuất giải pháp . 54
3.2.1 Các mặt hạn chế của quản trị mạng dựa trên SNMP . 54
3.2.2 Thuận lợi của XML cho quản trị mạng . 56
3.2.3 Quản trị mạng dựa trên XML. 58
3.3 Các phƣơng pháp trao đổi của cổng XML/SNMP . 60
3.3.1 Trao đổi dựa trên DOM . 61
3.3.2 Trao đổi dựa trên HTTP. 63
3.3.3 Trao đổi dựa trên SOAP . 65
3.3.4 Phân tích các phƣơng pháp đề xuất . 67
3.4 Nghiên cứu về chuyển đổi SNMP MIB thành XML . 68
3.4.1 Thuật toán chuyển đổi . 69
3.4.2 Thực hiện chuyển đổi . 79
3.4.3 Cổng XML/SNMP. 80
3.5 Kết luận chƣơng 3 . 82
KẾT LUẬN . 83
TÀI LIỆU THAM KHẢO . 85
characters(elements[1].toCharArray(),0,elements[1].length());
th.endElement("","","");
}
public void closeXML() throws SAXException {
th.endElement("","","xsd:complexType");
th.endElement("","","xsd:element");
th.endDocument();
System.out.println("");
System.out.println("");
}
}
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
4. ToXMLNotification.java
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;
public class ToXMLNotification {
BufferedReader in;
StreamResult out;
TransformerHandler th;
AttributesImpl atts;
Attributes d;
public static void main (String args[]) {
new ToXMLNotification().doit();
}
public void doit () {
try{
in = new BufferedReader(new FileReader("datanotification.txt"));
out = new StreamResult("datanotification.xml");
initXML();
String str;
while ((str = in.readLine()) != null) {
process(str);
}
in.close();
closeXML();
}
catch (Exception e) { e.printStackTrace(); }
}
public void initXML() throws ParserConfigurationException,
TransformerConfigurationException, SAXException {
SAXTransformerFactory tf =
(SAXTransformerFactory) SAXTransformerFactory.newInstance();
th = tf.newTransformerHandler();
Transformer serializer = th.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
// pretty XML output
serializer.setOutputProperty
("{}indent-amount", "4");
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
th.setResult(out);
th.startDocument();
atts = new AttributesImpl();
th.startElement("","","xsd:element name ='NodeName'",atts);
th.startElement("","","xsd:complexType",atts);
th.startElement("","","<xsd:attribute name = 'oid' type ='xsd:string' use = 'fixed'
value ='OidValue' / ",atts);
System.out.println("?xml version='1.0' encoding='ISO-8859-1'?");
System.out.println("");
System.out.println("");
System.out.println("<xsd:attribute name = 'oid' type ='xsd:string' use = 'fixed'
value ='OidValue' / >");
}
public void process (String s) throws SAXException {
String [] elements = s.split("\\ ");
atts.clear();
System.out.println("<xsd:attribute name = "+"'"+ elements[0]+"'"+" type =
'xsd:string' use = 'fixed' value =");
System.out.println(elements[1]+"/ >");
th.startElement("","","xsd:attribute name =",atts);
th.characters(elements[0].toCharArray(),0,elements[0].length());
th.startElement("","","type = 'xsd:string' use = 'fixed' value =",atts);
th.characters(elements[1].toCharArray(),0,elements[1].length());
th.endElement("","","");
}
public void closeXML() throws SAXException {
th.endElement("","","xsd:complexType");
th.endElement("","","xsd:element");
th.endDocument();
System.out.println("");
System.out.println("");
}
}
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
5. ToXMLObjectv1.java
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;
public class ToXMLObjectv1 {
BufferedReader in;
StreamResult out;
TransformerHandler th;
AttributesImpl atts;
public static void main (String args[]) {
new ToXMLObjectv1().doit();
}
public void doit () {
try{
in = new BufferedReader(new FileReader("dataobjectv1.txt"));
out = new StreamResult("dataobjectv1.xml");
initXML();
String str;
while ((str = in.readLine()) != null) {
process(str);
}
in.close();
closeXML();
}
catch (Exception e) { e.printStackTrace(); }
}
public void initXML() throws ParserConfigurationException,
TransformerConfigurationException, SAXException {
SAXTransformerFactory tf =
(SAXTransformerFactory) SAXTransformerFactory.newInstance();
th = tf.newTransformerHandler();
Transformer serializer = th.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
serializer.setOutputProperty
("{}indent-amount", "4");
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
th.setResult(out);
th.startDocument();
atts = new AttributesImpl();
th.startElement("","","xsd:element name ='NodeName'",atts);
th.startElement("","","xsd:complexType",atts);
th.startElement("","","xsd:simpleContent",atts);
th.startElement("","","xsd:restriction base = 'xsd:string'",atts);
th.startElement("","","xsd:sequence ",atts);
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
th.endElement("","","xsd:sequence");
th.startElement("","","<xsd:attribute name = 'oid' type ='xsd:string' use = 'fixed'
value ='OidValue' / ",atts);
System.out.println("?xml version='1.0' encoding='ISO-8859-1'?");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("(lower part node definition part)");
System.out.println("");
System.out.println("<xsd:attribute name = 'oid' type ='xsd:string' use = 'fixed'
value ='OidValue' / >");
}
public void process (String s) throws SAXException {
String [] elements = s.split("\\ ");
atts.clear();
System.out.println("<xsd:attribute name = "+"'"+ elements[0]+"'"+" type =
'xsd:string' use = 'fixed' value =");
System.out.println(elements[1]+"/ >");
th.startElement("","","xsd:attribute name =",atts);
th.characters(elements[0].toCharArray(),0,elements[0].length());
th.startElement("","","type = 'xsd:string' use = 'fixed' value =",atts);
th.characters(elements[1].toCharArray(),0,elements[1].length());
th.endElement("","","");
}
public void closeXML() throws SAXException {
th.endElement("","","xsd:restriction");
th.endElement("","","xsd:simpleContent");
th.endElement("","","xsd:complexType");
th.endElement("","","xsd:element");
th.endDocument();
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
}
}
6. IndentingParser.java
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
public class IndentingParser
{
static String displayStrings[] = new String[1000];
static int numberDisplayLines = 0;
public static void displayDocument(String uri)
{
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
try {
DOMParser parser = new DOMParser();
parser.parse(uri);
Document document = parser.getDocument();
display(document,"");
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
public static void display(Node node, String indent)
{
if (node == null){
return;
}
int type = node.getNodeType();
switch(type) {
case Node.DOCUMENT_NODE:{
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] += "<?xml version =
\"1.0\"encoding =\""+ "UTF-8"+"\"?";
numberDisplayLines ++;
display(((Document)node).getDocumentElement(),""); break; }
case Node.ELEMENT_NODE:{
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] +="<";
displayStrings[numberDisplayLines] += node.getNodeName();
int length = (node.getAttributes()!= null) ?
node.getAttributes().getLength() : 0;
Attr attributes[] = new Attr[length];
for (int loopIndex = 0; loopIndex <length; loopIndex ++){
attributes[loopIndex] =
(Attr)node.getAttributes().item(loopIndex); }
for (int loopIndex = 0; loopIndex < attributes.length;loopIndex ++){
Attr attribute = attributes[loopIndex];
displayStrings[numberDisplayLines] += " ";
displayStrings[numberDisplayLines] += attribute.getNodeName();
displayStrings[numberDisplayLines] +="=\"";
displayStrings[numberDisplayLines] += attribute.getNodeValue();
displayStrings[numberDisplayLines] +="=\"";
}
displayStrings[numberDisplayLines] +=">";
numberDisplayLines ++;
NodeList childNodes = node.getChildNodes();
if (childNodes != null) {
length = childNodes.getLength();
indent += " ";
for (int loopIndex = 0; loopIndex <length; loopIndex ++){
display(childNodes.item(loopIndex),indent);
Số hóa bởi Trung tâm Học liệu – Đại học Thái Nguyên
}
}
break;}
case Node.CDATA_SECTION_NODE:{
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] += "<![CDATA[";
displayStrings[numberDisplayLines] +=node.getNodeValue();
displayStrings[numberDisplayLines] +="]]>";
numberDisplayLines ++;
break;
}
case Node.TEXT_NODE: {
displayStrings[numberDisplayLines] = indent;
String newText =node.getNodeValue().trim();
if(newText.indexOf("\n")0) {
displayStrings[numberDisplayLines] +=newText;
numberDisplayLines ++;
}
break; }
case Node.PROCESSING_INSTRUCTION_NODE: {
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] += "<?";
displayStrings[numberDisplayLines] += node.getNodeName();
String text = node.getNodeValue();
if(text != null && text.length()>0) {
displayStrings[numberDisplayLines] +=text;
}
displayStrings[numberDisplayLines] += "?>";
numberDisplayLines ++;
break;
}
}
if (type == Node.ELEMENT_NODE){
displayStrings[numberDisplayLines] = indent.substring (0,indent.length() - 3);
displayStrings[numberDisplayLines] += "</";
displayStrings[numberDisplayLines] += node.getNodeName();
displayStrings[numberDisplayLines] += ">";
numberDisplayLines ++;
indent +=" "; }}
public static void main(String args[])
{
displayDocument(args[0]);
for (int loopIndex = 0; loopIndex < numberDisplayLines; loopIndex ++){
System.out.println(displayStrings[loopIndex]);
}
}
}
File đính kèm:
Luận văn Kiến trúc hệ thống quản trị mạng dựa trên XML.pdf

