210 likes | 659 Views
Abstract Syntax Notation. Computer Networks courses Villanova University. Platform and language independence.
E N D
Abstract Syntax Notation Computer Networks courses Villanova University
Platform and language independence • The purpose of ASN.1 is to allow specification of an information exchange between cooperating parts of a distributed application, independent of the platform and language used for implementation
ASN.1 Shared Representation Site A Site B Abstract Specification ASN.1 Application Source Code C Application Source Code Java Compiler Compiler Compiler Compiler Application Process in System A Compatible information flow Application Process in System B
Abstract Syntax • Represent the data types and structures • Separate definition of the transfer syntax allows interaction
Modules and Assignments • Module is the fundamental unit • name a collection of type definitions and/or value definitions (assignments)
Example module (A type definition)InventoryList {1 2 0 0 6 1} DEFINITIONS ::= BEGIN { ItemId ::= SEQUENCE { partnumber IA5String, quantity INTEGER, wholesaleprice REAL, saleprice REAL } StoreLocation ::= ENUMERATED { Baltimore (0), Philadelphia (1), Washington (2), } } END The words Baltimore, Philadelphia, and Washington are used to represent the values 0, 1, 2 for this type.
Type Assignment • Type reference (name of the type) • ::= • type • comments begin with -- and end with EOL or --
Value Assignment • Value reference (name of the value) • ::= • valid value notation • value reference must begin with lower case letter
Simple types • BOOLEAN (true or false) • INTEGER (any positive or negative whole number or zero) • REAL (mantissa, base, exponent) • BIT STRING (ordered string of bits) • OCTET STRING (ordered string of octets) • NULL (null is the only allowed value) • OBJECT IDENTIFIER (identifies a place in a tree) • ENUMERATED (a list of names of values) • CHARACTER STRING (several are defined)
Structured Types • SEQUENCE/SEQUENCE OF • An ordered collection; “of” indicates all entries are the same type • SET/SET OF • an unordered collection; “of” indicates entries are the same type • CHOICE • collection of types from which one is chosen • SELECTION • references a CHOICE type
Tagging • When one of several types might be transmitted at a particular time, tagging allows the receiving system to decode correctly • UNIVERSAL (predefined and standard Example Integer is universal tag 1, etc.) • APPLICATION (defined within an application) • PRIVATE (defined within an organization) • CONTEXT-SPECIFIC (locally defined)
Basic Encoding Rules • ASN.1 definitions made concrete by specific rules for encoding. • Basic structure: Tag, Length, Value • Tag: Class, simple or constructed, code • Integer: 00000001 • Class universal = 00, simple type = 0, code for integer tag = 1 • Integer value 27, shown in hexadecimal: • 01011B • Nesting works to encode complex types tag length
Time • GeneralizedTime • Local: YYYYMMDDHHMMSS.fff • Universal:YYYYMMDDHHMMSS.fffZ • Difference: • YYYYMMDDHHMMSS.fff+-HHMM • (fractions of seconds are optional) • Time shift from UTCTime • UTCTime • same formats as above • no fff; seconds optional • So what time is it? Express the current time in the Generalized Time format
Coordinated Universal Time (UTC) Based on the second (SI). For most practical purposes UTC is equivalent to mean solar time at the prime meridian (0° longitude), formerly expressed in GMT. The second was formerly defined in terms of astronomical phenomena. The change to atomic resonance phenomena ("atomic time") to define the second more precisely.led to need for occasional adjustments in the "atomic" time scale to coordinate it with the workaday mean solar time scale, UT-1. Rotational irregularities usually result in a net decrease in the Earth's average rotational velocity, and ensuing lags of UT-1 with respect to UTC. Adjustments to the atomic, i.e., UTC, time scale consist of an occasional addition or deletion of one full second, which is called a leap second. Twice yearly, during the last minute of June 30 and December 31, Universal Time, adjustments may be made to ensure that the accumulated difference between UTC and UT-1 will not exceed 0.9 s before the next scheduled adjustment. The last minute of the UTC time scale, on the day when an adjustment is made, will have 59 or 61 seconds. Synonyms World Time, Z Time, Zulu Time. Source: http://www.its.bldrdoc.gov/fs-1037/dir-009/_1277.htm January 2001
Use of time standards UTC - Coordinated Universal Time Weather observations and forecasts are usually reported in UTC, which used to be known as Greenwich Mean Time (GMT), i.e. the local time at the Greenwich meridian (zero degrees longitude). This allows weather observations the world over to have the same time stamp. Since UTC is ahead of local time in the United States, sometimes weather data will have tomorrow's date, but it still represents today's data (we are not THAT good at forecasting the weather). UTC is 8 hours ahead of Pacific Standard Time (e.g. 0000 UTC is 4 p.m. PST the previous day, 1200 UTC is 4 a.m. PST the same day), 7 hours ahead of Pacific Daylight Time (e.g. 0000 UTC is 5 p.m. PDT the previous day, 1200 UTC is 5 a.m. PDT the same day). P.S. it is UTC instead of CUT to make the abbreviation language independent. Source: http://www.atmos.washington.edu/utc.html January 2001 What time is it here, as an offset from UTC?
If you really want to know what time it is • Check this site: http://www.greenwich2000.com/time/
SubtreeSpecification ::= SEQUENCE { base [0] LocalName DEFAULT { }, COMPONENTS OF ChopSpecification, specificationFilter [4] Refinement OPTIONAL } -- empty set specifies whole administrative area LocalName ::= RDNSequence ChopSpecification ::= SEQUENCE { specificExclusions [1] SET OF CHOICE { chopBefore [0] LocalName, chopAfter [1] LocalName } OPTIONAL, minimum [2] BaseDistance DEFAULT 0, maximum [3] BaseDistance OPTIONAL } BaseDistance ::= INTEGER (0 .. MAX) Refinement ::= CHOICE { item [0] OBJECT-CLASS.&id, and [1] SET OF Refinement , or [2] SET OF Refinement, not [3] Refinement } Source ( January 2001): ftp://ftp.bull.com/pub/OSIdirectory/2ndEditionSpecifications/ASN.1modules/compilableASN.1 Part of an example specification in ASN.1
Current uses of ASN.1 • Every call placed on a cellular telephone in North America, Europe, and Japan results in TCAP protocol messages. These messages, described using ASN.1 and encoded using one its predefined encoding rules (e.g., The Basic Encoding Rules (BER) • Also, routing of 800- number calls, reverse charging, other special phone services all are defined using ASN.1 messages See http://www.oss.com/asn1/overview.html for further information
Java classes for ASN.1 Class iaik.asn1.ASN java.lang.Object | +----iaik.asn1.ASN public class ASN extends java.lang.Object implements java.lang.Cloneable The ASN class represents the ASN.1 types. These types are represented at the Java level with ASN.XXX literals. This class also acts as an factory for creating ASN.1 OBJECT subclasses for various kinds of Java objects. Each new created ASN.1 type has to be registered in the factory by specifying the class that implements the particular ASN.1 type. Source: (January 2001) http://www.cs.utexas.edu/users/dragon/cs378/f98/resources/iaikdocs/iaik.asn1.ASN.html
Exercises • Chapter 3 of Cassel/Austing Computer Networks • page 103-104, # 10, 11