Abstract Syntax Notation

Transcrição

Abstract Syntax Notation
Abstract Syntax Notation One
72
…
…
…
COMPUTERSIMULATION
NACHRICHTENTECHNISCHER
SYSTEME
…
Beschreibungssprache
h b
h zur Definition
f
von
Datenstrukturen, ohne auf die rechnerinterne
Darstellung einzugehen
Festlegungen zur Umsetzung von Datenstrukturen und
Elementen in ein netzeinheitliches Format
gemeinsamer Standard der ITU-T (International
Telecommunication Union – Telecommunication
Standardization Sector) und der ISO (Internationale
Organisation für Normung)
verbreitete Möglichkeit, die Nachrichtenelemente von
Kommunikationsprotokollen eindeutig zu beschreiben
4. Abstract Syntax Notation 1 ASN.1
Spezifikation von Kommunikationssystemen
Problem: Heterogenität
73
Konvertierung notwendig
74
…
B i i l (nach
Beispiel
( h Oli
Olivier
i Dubuisson):
D b i
)
…
Symmetrisch
† Sender
…
makes right
† Receiver makes right
…
Asymmetrisch
† Konvertierung
in ein
Zwischenformat
Unterschiede:
†
†
†
†
Ein String endet mit einem NULL byte in C, aber nicht in Objective
Caml;
Die Länge des Namens ist nicht begrenzt in Objective Caml;
Über die interne Repräsentation des Eintrags „age
„age“ ist nichts
ausgesagt;
Objective Caml kennt keine Vorgabewerte für Aufzähltypen;
Spezifikation von Kommunikationssystemen
ASN.1
Spezifikation von Kommunikationssystemen
Anwendung auf das Beispiel
75
Das Typ
Typ-Konzept
Konzept in ASN.1
76
…
…
…
Ein ASN.1-Typ
ASN
ist eine nicht-leere Menge
M
von
Werten, die kodiert werden können, um übertragen
zu werden.
d
Dieses Typ-Konzept ist daher vergleichbar mit dem
i bekannten
in
b k
P
Programmiersprachen,
i
h um dort
d
komplexe Datenstrukturen zu vereinbaren.
ASN 1 T
ASN.1-Typen
sind
d aber
b speziellll auff den
d
Datentransport hin zu vereinbaren
† Entsprechende
“OPTIONAL”)
Spezifikation von Kommunikationssystemen
Spezifikation von Kommunikationssystemen
Elementare Datentypen in ASN.1
77
78
…
…
…
…
…
…
…
…
…
…
BOOLEAN (true
(t
oder
d false)
f l )
NULL (mit nur einem Wert, nämlich NULL)
INTEGER (positive und negative Ganzzahlen)
REAL (Gleitkommazahlen)
ENUMERATED (Aufzählungstyp)
BIT STRING (binäre Zeichenfolge)
OCTET STRING ((Folge
g von Bytes)
y )
IA5String (nach IA5-Tabelle kodierte Zeichenfolge, siehe
ISO 646)
CHARACTER STRING
UTCTime, GeneralizedTime (Zeit- und Datumsangaben)
Spezifikation von Kommunikationssystemen
Funktionen sind vorzusehen (z.
( B.
Zusammengesetzte Datentypen in
ASN.1
…
…
…
…
…
…
SEQUENCE ((geordnete
d
Abfolge
Abf l verschiedener
h d
TTypen))
SEQUENCE OF <Typ> (geordnete Abfolge gleichen Typs)
S (ungeordnete
SET
(
d
Abfolge
Abf l verschiedener
h d
Typen))
SET OF <Typ> (ungeordnete Abfolge gleichen Typs)
CHOICE (Summentyp)
Beispiele:
†
†
†
C di
Coordinates
::= SET { x [1] INTEGER,
INTEGER
y [2] INTEGER,
z [3] INTEGER OPTIONAL }
Lottery-number ::= INTEGER (1..49)
Lottery-draw ::= SEQUENCE SIZE (6) OF Lottery-number
Spezifikation von Kommunikationssystemen
Spezielle Datentypen in ASN.1
79
Wertezugweisung in ASN.1
80
…
Spezielle Datentypen, z. B.
…
† OBJECT
IDENTIFIER (Weltweit eindeutige Kennung)
† RELATIVE-OID (Relative Objektkennung)
…
…
Wird beispielsweise im Netzmanagement benötigt:
† counter
Lottery
Lottery-number
number ::=
:: 45
† sextuple Lottery-draw ::= { 7, 12, 23, 31, 33, 41 }
† pair Coordinates ::= { x 5,
5 y -3
3}
† OBJECT
IDENTIFIER 1.3.6.1.2.1.1.1.0
† Objekt
Obj kt „sysDescr“,
D
“ also
l BBeschreibung
h ib
des
d Systems
S t
…
Spezifikation von Kommunikationssystemen
Es wird keine Aussage darüber gemacht, wie diese
W
Werte
zu kodieren
k di
sind
i d
Spezifikation von Kommunikationssystemen
Spezifikation mittels ASN.1
81
ASN.1 erlaubt die explizite Zuweisung von Werten
zu Typen
Beispiele:
Beispiel: SNMPv2
SNMPv2-PDUs
PDUs (I)
82
…
…
…
Sammlung von ASN.1 Datentypen
Zusammenfassung
g zu Modulen,, die eine eindeutige
g
Kennung bekommen
Schnittstelle des Moduls wird mit IMPORT und
EXPORT angegeben
Spezifikation von Kommunikationssystemen
PDUs ::= CHOICE
C OC {
get-request
get-next-request
get-bulk-request
response
q
set-request
inform-request
ssnmpV2-trap
pV ap
}
GetRequest-PDU,
GetNextRequest-PDU,
GetBulkRequest-PDU,
Response-PDU,
SetRequest-PDU,
q
InformRequest-PDU,
SNMPv2-Trap-PDU
SNM
v
ap U
Spezifikation von Kommunikationssystemen
Beispiel: SNMPv2
SNMPv2-PDUs
PDUs (I)
ASN.1: Kodierung / Dekodierung
83
84
PDU ::=
=
SEQUENCE {
request-id Integer32,
error-status
-- sometimes ignored
INTEGER {
noError(0),
tooBig(1),
noSuchName(2), -- for proxy compatibility
badValue(3), -- for proxy compatibility
readOnly(4),
dO l (4)
-- for
f proxy compatibility
ibili
genErr(5),
noAccess(6),
wrongType(7),
wrongLength(8),
wrongEncoding(9),
wrongValue(10),
noCreation(11),
inconsistentValue(12),
resourceUnavailable(13),
commitFailed(14),
undoFailed(15),
authorizationError(16),
notWritable(17),
i
inconsistentName(18)
i t tN
(18) },
}
…
error-index
-- sometimes ignored
INTEGER (0..max-bindings),
Basis-Kodierungsregeln (Basic Encoding Rules, BER):
variable-bindings -- values are sometimes ignored
VarBindList
Bezeichner
}
Bit
7
6
5
4
3
Inhalt
2
Datentyp
Typklasse
00: Universal
01: Application
02:Context Specific
03: Private
Spezifikation von Kommunikationssystemen
0: einfach
1: strukturiert
1
0
Tag-Nummer
0..30:
0
30: wie angegeben
31: nächstes Byte gibt Tag an
Spezifikation von Kommunikationssystemen
Einfaches Codierungsbeispiel
Komplizierteres Codierungsbeispiel
85
86
…
Integer-Wert 5
…
ASN 1 T
ASN.1-Typ:
†
0
Länge
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
Länge
Tag-Nummer = 2
Æ Datentyp INTEGER
Einfacher
Datentyp
UniversalKlasse
Spezifikation von Kommunikationssystemen
0
0
0
0
0
Wert
1
0
1
SEQUENCE {name IA5String, ok BOOLEAN}
…
ASN 1 Wert:
ASN.1-Wert:
…
Codierung:
†
†
{name "Smith", ok TRUE}
Sequence Länge
3016
0A16
Inhalt
IA5String
IA5St
i
Lä
Länge
I h lt
Inhalt
1616
0516
"Smith“
Boolean
Länge
Inhalt
0116
0116
FF16
(TRUE wird als Byte codiert, das mindestens eine 1
enthält…)
Spezifikation von Kommunikationssystemen
Literatur
87
…
…
…
…
JJ. Case,
C
K.
K McCloghrie,
M Cl h i M
M. Rose,
R
S.
S Waldbusser:
W ldb
P t l Operations
Protocol
O
ti
for version 2 of the Simple Network Management Protocol
(SNMPv2). Request for Comments 1448. April 1993.
ITU T X
ITU-T
X.690:
690 OSI networking
k and
d system aspects – Abstract
Ab
Syntax
S
Notation One (ASN.1) – Information technology – ASN.1 encoding
rules: Specification of Basic Encoding Rules (BER), Canonical
E di Rules
Encoding
R l (CER) and
d Distinguished
Di ti i h d Encoding
E di Rules
R l (DER)
(DER). JJulili
2002, SERIES X: DATA NETWORKS AND OPEN SYSTEM
COMMUNICATIONS.
S Legg:
S.
L
ASN.1
ASN 1 M
Module
d l D
Definition
fi i i ffor the
h LDAP and
dX
X.500
500
Component Matching Rules. Request for Comments 3727. Februar
2004, Standards Track.
O. Dubuisson: ASN.1 – Communication between Heterogeneous
Systems. http://asn1.elibel.tm.fr/en/book/, Juni 2000.
Spezifikation von Kommunikationssystemen