html5-img
1 / 55

Outline for today

Outline for today. Standard Formal Notations for data structures and messages Motivation Abstract Syntax Notation One (ASN.1). Standard Formal Notations for Data Structures and Messages. Protocol Definition.

Télécharger la présentation

Outline for today

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline for today • Standard Formal Notations for data structures and messages • Motivation • Abstract Syntax Notation One (ASN.1) IHA præsentation

  2. Standard Formal Notations for Data Structures and Messages IHA præsentation

  3. Protocol Definition A well-defined set of messages (bit-patterns or - increasingly today - octet strings) each of which carries a defined meaning (semantics), together with the rules governing when a particular message can be sent. IHA præsentation

  4. Motivation Example – 4 layered protocol stack Windows CE, Intel, Protocol implemented in C# Linux, ARM11, Protocol implemented in C IHA præsentation

  5. a 00000011 00000001 a 00000001 00000011 The problem Q: Why not just specify the data in a C/C++ structure as below”? struct { char code; int x; } test; test.x = 256; test.code=‘a’ test.code test.x test.code test.x host 2 format host 1 format problem: different data format, storage conventions (endianess) IHA præsentation

  6. Solutions 1. Sender learns receiver’s format. Sender translates into receiver’s format. Sender sends. • real-world analogy? • pros and cons? 2. Sender sends. Receiver learns sender’s format. Receiver translate into receiver-local format • real-world-analogy • pros and cons? 3. Sender translates host-independent format. Sends. Receiver translates to receiver-local format. • real-world analogy? • pros and cons? IHA præsentation

  7. Protocol Specification • Goal/Motivation for specifying messages • To have a platform-independent Notation • To have language-independent Notation • Vendor-independent • Internationally-standardised IHA præsentation

  8. Protocol Specification • Protocols can be specified in many ways • One fundamental distinction is between text-based specifications and binary-based specification. • Text-based specification: • The "protocol" is defined as a series of lines of ASCII encoded text • Binary-based specification: • The “protocol” is defined as a string of octets or of bits IHA præsentation

  9. Abstract Syntax Notation One(ASN.1) IHA præsentation

  10. Abstract Syntax Notation One (ASN.1) • It is an internationally-standardized (ISO standard X.680), vendor-independent, platform-independent and language-independent notation for specifying data-structures at a high level of abstraction • It is supported by rules which determine the precise bit-patterns (again platform independent and language-independent) to represent values of these data-structures when they have to be transferred over a computer network, using encodings that are not unnecessarily verbose • It is supported by tools available for most platforms and several programming languages that map the ASN.1 notation into data-structure definitions in a computer programming language of choice, and which support the automatic conversion between values of those data-structures in memory and the defined bit-patterns for transfer over a communications line. IHA præsentation

  11. Abstract Syntax Notation One (ASN.1) • The design of some form of data-structure (at about the level of generality of a high-level programming language, and using a defined notation) which is capable of carrying the required semantics. The set of values of this data-structure are called the abstract syntax of the messages or application. We call the notation we use to define this data structure or set of values we the abstract syntax notation for our messages. ASN.1 is just one of many possible abstract syntax notations, but is probably the one most commonly used. IHA præsentation

  12. Abstract Syntax Notation One (ASN.1) • The crafting of a set of rules for encoding messages such that, given any message defined using the abstract syntax notation, the actual bits on the line to carry the semantics of that message are determined by an algorithm specified once and once only (independent of the application). We call such rules encoding rules, and we say that the result of applying them to the set of (abstract syntax) messages for a given application defines a transfer syntax for that application. A transfer syntax is the set of bit-patterns to be used to represent the abstract values in the abstract syntax, with each bit-pattern representing just one abstract value. (In ASN.1, the bit-patterns in a transfer syntax are always a multiple of 8 bits, for easy carriage in a wide range of carrier protocols) IHA præsentation

  13. Abstract Syntax Notation One (ASN.1) IHA præsentation

  14. Abstract Syntax Notation One (ASN.1) ASN.1 Specification Machine A (C#) Machine B (C++) Step 1. We need a ASN.1 compiler ASN.1 -> C# + ASN.1 -> C++ Step 2. Agree on encoding rules (BER or PER?) ASN.1 TOOLS ARE AVAILABLE IHA præsentation

  15. Abstract Syntax Notation One (ASN.1) ASN.1 Specification A top-level type definition, supported by other type and value definitions The Abstract Syntax Apply a specific ASN.1 Encoding Rule Abstract values ASN.1 Encoding Rules All possible values of this top-level type ASN.1 Encoding Rules Values Bit pattern Bit pattern Transfer Syntaxes IHA præsentation

  16. Abstract Syntax Notation One (ASN.1) • ASN.1 is for: • Representing data types and structures (abstract syntax) • Encoding rules (transfer syntax) • ASN.1 is not • another programming language • No control flow (if-else, while etc.) • No pointers • Bitwise operators Let us look at ASN.1 in more details! IHA præsentation

  17. ASN.1 - Modules -- ASN1START EUTRA-RRC-Def DEFINITIONS AUTOMATIC TAGS ::= BEGIN …. …. …. …. END --ASN!STOP • Fundamental unit of ASN.1 • Module • Sole purpose to name a collection of type definitions and/or value definitions (assignments) • The module constitutes a data specification Type & value definitions (assignments) IHA præsentation

  18. ASN.1 - Basics • How do we define types and assign values to them ? • The main concept of ASN.1 is that of type • Two main ASN.1 build-in types: • Basic types • Constructed types IHA præsentation

  19. ASN.1 – Basic Types IHA præsentation

  20. ASN.1 – Constructed Types IHA præsentation

  21. ASN.1 – Type & Value Assignment All ASN.1 assignments use the symbol ”::=”; so do the type assignment: Married ::= BOOLEAN Cancel ::= BOOLEAN DEFAULT FALSE Age ::= INTEGER ColorType ::= INTEGER { red (0) white (1) blue (2) } Picture ::= BIT STRING Occupation ::= BIT STRING { clerk (1) editor (2) } myMarried Married ::= TRUE myAge Age ::= 25 myColor ColorType ::= red myColor ColorType ::= 35 myPicture Picture ::= ’0101011011110’B myWork Occupation ::= { clerk, editor } Positions in string IHA præsentation

  22. ASN.1 – Type & Value Assignment f FORM ::= { name ”Peter”, age 25, married TRUE } c Coordinates ::= { z 10, x 5, y 30 } c Coordinates ::= { x 5, y 30 } Form ::= SEQUENCE { name PrintableString, age Age, married Married } Coordinates ::= SET { x [1] INTEGER, y [2] INTEGER, z [3] INTEGER OPTIONAL } Maybe present IHA præsentation

  23. ASN.1 – Type & Value Assignment RAT-Type ::= ENUMERATED { eutra, utra, geran-cs, geran-ps, cdma2000-1XRTT, spare3, spare2, spare1, ...} rat RAT-Type ::= geran-cs car CarType ::= audi myAfter Afters ::= dessert ”ice” CarType ::= ENUMERATED { audi (0), bmw (1) scoda (2), citroen(3), ...} How can the received decode this? Cheese or dessert string received? Afters ::= CHOICE{ cheese IA5String, dessert IA5String } SOLUTION: TAGGING IHA præsentation

  24. ASN.1 – Type Assignment MeasIdToAddModList ::= SEQUENCE OF MeasIdToAddMod MeasIdToAddMod ::= SEQUENCE { measId MeasId, measObjectId MeasObjectId, reportConfigId ReportConfigId } IHA præsentation

  25. ASN.1 – Subtyping Allows us to customise our types to just the precise values we need – it can reduce the number of bits-on-the-line and gives clear guidance to implementors for memory allocation decisions • Usage: • reduce the range of an integer • specify a minimum and/or maximum length of a string • specify a min and/or max number of iterations in a SEQUENCE OF or SET OF HOW? IHA præsentation

  26. ASN.1 – Subtyping Reducing the range of an integer: RRC-TransactionIdentifier ::= INTEGER (0..3) restricting the range of the integer field to the values 0 to 3 Length of a string: My-string ::= PrintableString (SIZE (1..10)) FROM (”A”..”Z”)) restict the size of the string between 1 and 10 characters string can only contain the characters ”A” to ”Z” IHA præsentation

  27. ASN.1 – Subtyping Number of iterations in a SEQUENCE OF or SET OF: UE-CapabilityRAT-ContainerList ::=SEQUENCE (SIZE (0..2)) OF UE-CapRAT-Container UE-CapRAT-Container ::= SEQUENCE { rat-Type RAT-Type, ueCapabilityRAT-Container OCTET STRING } Minimum number of iterations is 0 – maximum is 2 IHA præsentation

  28. ASN.1 – Extensions Versioning ASN.1 Specification Ver.1 Type ::= SEQUENCE { comp1 INTEGER, comp2 BOOLEAN, } ASN.1 Specification Ver.2 Type ::= SEQUENCE { comp1 INTEGER, comp2 BOOLEAN, comp3 REAL } ??? IHA præsentation

  29. ASN.1 – Extensions & Versioning ASN.1 Specification Ver.1 Type ::= SEQUENCE { comp1 INTEGER, comp2 BOOLEAN … } ASN.1 Specification Ver.2 Type ::= SEQUENCE { comp1 INTEGER, comp2 BOOLEAN, [[ comp3 REAL]], … } extension marker (ellipsis) version brackets IHA præsentation

  30. Abstract Syntax Notation One (ASN.1) ASN.1 Encoding Rules • Basic Encoding Rule (BER) • Packet Encoding Rules (PER) • XML Encoding Rules (XER) IHA præsentation

  31. ASN.1 – Basic Encoding Rules The BER transfer syntax always has the format of a triplet TLV L V T L T L V T L T Recursive principle IHA præsentation

  32. ASN.1 – Basic Encoding Rules Two formats of the Tag Octets (Primitive or Constructed) IHA præsentation

  33. Abstract Syntax Notation One (ASN.1) Example: age INTEGER ::= 5 + + Primitive INTEGER UNIVERSAL IHA præsentation

  34. ASN.1 – Basic Encoding Rules The length octet represents the length of the value (V) • The three formats of the length octets • Short definite length • Long definite length • Indefinite length IHA præsentation

  35. ASN.1 Basic Encoding Rules Short definite length 0 • can be used if V part is less than 127 octets • V part can be primitive or constructed type • short form is identified by encoding bit 8 as zero IHA præsentation

  36. ASN.1 Basic Encoding Rules Bit 8 set to one Long definite length Following N octets is Length fields 1 IHA præsentation

  37. ASN.1 – Basic Encoding Rules Short form Length of length N = 2 Long form Options for encoding a length of 5 (1 0 1) IHA præsentation

  38. ASN.1 – Basic Encoding Rules Encoding of the V part of the main types Encoding a BOOLEAN value The values of b1 BOOLEAN ::= TRUE b2 BOOLEAN ::= FALSE are encoded as T L V b1: 01 01 FF b2: 01 01 00 Encoding an INTEGER value The values of i1 INTEGER ::= 72 i2 INTEGER ::= 127 i3 INTEGER ::= 128 are encoded as T L V i1: 02 01 4B i2: 02 01 80 i3: 02 02 0080 IHA præsentation

  39. ASN.1 – Basic Encoding Rules seq SEQUENCE { age INTEGER, single BOOLEAN } ::= {age 24, single TRUE } is encodes as: IHA præsentation

  40. ASN.1 Tagging • Why do we need tagging? • All ASN.1 types are assigned a default ”tag” (for the ”T” part of encoding) • Sometimes use of the default tag would produce ambiguous encoding, for example: IA5String in both cases Identification ::= CHOICE { security_no INTEGER, work_no INTEGER } Afters ::= CHOICE { cheese IA5String, dessert IA5String } IHA præsentation

  41. ASN.1 Tagging • A tag is a number between square brackets before a type Coordinates ::= SET { x [1] INTEGER, y [2] INTEGER, z [3] INTEGER OPTIONAL } Afters ::= CHOICE { cheese [0] IA5String, dessert [1] IA5String } IHA præsentation

  42. ASN.1 Tagging • When we tag, we can • Override the current tag (called IMPLICIT tagging) • Add a new tag on the front (called EXPLICIT tagging) giving a ”TL TLV” encoding • Sometimes explicit tagging is needed to avoid ambiguity, but implicit tagging is more common IHA præsentation

  43. ASN.1 Tagging • We can add as many new tags as we like t a type! • We say that each value of that type (any type) has associated with it a tag-list • Usually the tag-list contains only one or two tags, but … there is no limit • In almost all cases, every value in a type has the same tag list IHA præsentation

  44. ASN.1 Tagging Research-division ::= [1] CHOICE { product-based [0] NULL, basic [1] NULL } ”product-based” value ”Research-division” type [1][0][null] O ”basic” value [1][1][null] O IHA præsentation

  45. ASN.1 Tagging • Tag classes • UNIVERSAL (not for users) • APPLICATION e.g. [APPLICATION 6] • PRIVATE e.g. [PRIVATE 3] • Context specific e.g. [2] IHA præsentation

  46. ASN.1 Tagging • Tag rules • Numbers are non-negative • Context specific most common • APPLICATION normally used for global types or for top-level messages • PRIVATE rarely used • UNIVERSAL assigned only by ASN.1 IHA præsentation

  47. ASN.1 Tagging Syntax: tag type definition tag IMPLICIT type definition tag EXPLICIT type definition Examples: SpecialEncoding ::= [PRIVATE 8] EXPLICIT BIT STRING BinaryFile ::= [APPLICATION 3] IMPLICIT OCTET STRING IHA præsentation

  48. ASN.1 – Packet Encoding Rules (PER) • ”Obtain the most compact encoding using encoding rules as simple as possible” • 40% - 60% gain compared to BER • Appropriate for protocols that need to transfer data at a high rate • VoIP • Videophone • Multimedia HOW? IHA præsentation

  49. ASN.1 – Packet Encoding Rules Motivation Encoding a BOOLEAN value in BER The values of b1 BOOLEAN ::= TRUE b2 BOOLEAN ::= FALSE are encoded as T L V b1: 01 01 FF b2: 01 01 00 3 octets to send a BOOLEAN ONLY 1 bit needed IHA præsentation

  50. ASN.1 – Packet Encoding Rules • PER-visible constraints • Used by PER to produce less verbose encodings Example: INTEGER (0..7) encodes into just three bits because the (0..7) constraint is PER-visible • No ”T”, no ”L” => efficient coding • Same ASN.1 type definition used, same specification IHA præsentation

More Related