SlideShare a Scribd company logo
1 of 18
Download to read offline
ASN.1
Abstract Syntax Notation One
What is ASN.1
● Way of representing objects
● Used for abstraction in OSI model
● Can represent simple atomic (Integer,
String etc.) and complex data structures
Why not JSON or XML
● ASN.1 is chosen for efficiency. Not
babysitting the codec writers
● JSON / XML takes up too much
overhead in transmitting
● ASN.1 can do it with way less. Thus, less
bandwidth / lesser resources
● But encoding / decoding / debugging is
hard.
Compare XML / JSON
{ “vehicle”: {
“wheelCount”: 4,
“registration”: “3421”
}}
73 bytes
<vehicle>
<wheelCount>4</wheelCount>
<registration>3421<registration>
</vehicle>
81 bytes
A0 07 02 01 04 16 02 43 12
8 bytes!
Note that in both cases, both the encoding and decoding entities
MUST have prior knowledge of the data structure
Encoding / Decoding
● Done using encoding rules.
● BER (Basic Encoding Rules) is the most
popular method
○ Used in TCAP, MAP, CAP
● CER, DER and some others are present
Encoding / Decoding
Basic Encoding Rules
Primitive
Types
Constructed Types
Definite
Length
Infinite
Length
Data Structure
Encoded as
● Tag and Length are one or multiple
bytes
● Content is zero or multiple bytes
LENGTH CONTENTTAG
Data Structure
● The TAG identifies the data structure
● LENGTH specifies the number of trailing
bytes in the CONTENT to follow
● CONTENT...well...what do you think?
LENGTH CONTENTTAG
TAG Octets
● TAG consists of three parts in BER
○ Class
○ Indication of whether the structure is
primitive or compound
○ Tag value
7 6 5 4 3 2 1 0
Class P/C Tag
00 : Universal | 01: Application | 10: Context specific | 11: Private
TAG
TAG Octets
● In our car example:
{ “vehicle”: {
“wheelCount”: 4,
“registration”: “3421”
}}
The wheel count is an integer.
ASN is of class UNIVERSAL (0x00), a PRIMITIVE (0) and
INTEGER (Tag 2)
Thus 0x02:
0 0 0 0 0 0 1 0
TAG
TAG Octets
● What happens when the tag value cannot
be represented in the given 5 bits. i.e.
Tags > 31
● If the tag is greater than 30, The TAG
octet will become TAG octets.
● The first byte’s tag part will have five 1’s
● Then the other tailing bytes will
represent the value. in 7 bits each. with
MSB as 1.
● The end is shown with MSB 0.
TAG
Confused?
Good! Then lets try it out.
LENGTH Octets
● Definite lengths from 0 to 127 will be
represented in the length byte.
● If the length is greater than 127, the long
form takes over (just like in TAG octets)
● The MSB is made 1. The rest of the LSBs
represent the number of trailing bytes
which really gives out the length.
LENGTH
Confused again?
Oh you poor souls!
LENGTH Octets
The indefinite length is noted with a length
octet being 0x80. i.e. MSB 1 and rest zero
1 0 0 0 0 0 0 0
The contents in this case will be terminated
with a special ASN tag with TAG 0 and
LENGTH 0
i.e. 0x00 0x00
Food for thought: What happens if your data in one
of the containers has two consecutive 0s?
LENGTH
CONTENT Octets
● Contents can be a primitive data type like
INTEGER or String
● Or it can be another Tag|Length|Content
structure or multiples of it.
● As long as there are LENGTH bytes
trailing, there is no issue, whatever it is.
CONTENT
Let’s look at TCAP with Wireshark
References
ITU specification document
http://goo.gl/PBXEup
Laymen’s guide to ASN
http://goo.gl/XJqL4s

More Related Content

What's hot

csdl - buoi2-3-4
csdl - buoi2-3-4csdl - buoi2-3-4
csdl - buoi2-3-4kikihoho
 
Lập trình chương trình chat room sử dụng giao thức tcp socket
Lập trình chương trình chat room sử dụng giao thức tcp socketLập trình chương trình chat room sử dụng giao thức tcp socket
Lập trình chương trình chat room sử dụng giao thức tcp socketjackjohn45
 
Introduction to parallel processing
Introduction to parallel processingIntroduction to parallel processing
Introduction to parallel processingPage Maker
 
Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#An Nguyen
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and SegmentationMadhur Gupta
 
Unit 2: Programming Language Tools
Unit 2:  Programming Language ToolsUnit 2:  Programming Language Tools
Unit 2: Programming Language ToolsDr Piyush Charan
 
Input output systems ppt - cs2411
Input output systems ppt - cs2411Input output systems ppt - cs2411
Input output systems ppt - cs2411Geerthik Varun
 
Transport layer (computer networks)
Transport layer (computer networks)Transport layer (computer networks)
Transport layer (computer networks)Fatbardh Hysa
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptxLECO9
 
Polar-NRZ & Polar-RZ encoding schemes
Polar-NRZ & Polar-RZ encoding schemesPolar-NRZ & Polar-RZ encoding schemes
Polar-NRZ & Polar-RZ encoding schemesArunabha Saha
 

What's hot (20)

csdl - buoi2-3-4
csdl - buoi2-3-4csdl - buoi2-3-4
csdl - buoi2-3-4
 
95511389 visual-foxpro-trucos
95511389 visual-foxpro-trucos95511389 visual-foxpro-trucos
95511389 visual-foxpro-trucos
 
Sequere socket Layer
Sequere socket LayerSequere socket Layer
Sequere socket Layer
 
Lập trình chương trình chat room sử dụng giao thức tcp socket
Lập trình chương trình chat room sử dụng giao thức tcp socketLập trình chương trình chat room sử dụng giao thức tcp socket
Lập trình chương trình chat room sử dụng giao thức tcp socket
 
Introduction to parallel processing
Introduction to parallel processingIntroduction to parallel processing
Introduction to parallel processing
 
Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#Quy tắc thiết kế giao diện và viết code C#
Quy tắc thiết kế giao diện và viết code C#
 
Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
Unit 2: Programming Language Tools
Unit 2:  Programming Language ToolsUnit 2:  Programming Language Tools
Unit 2: Programming Language Tools
 
Input output systems ppt - cs2411
Input output systems ppt - cs2411Input output systems ppt - cs2411
Input output systems ppt - cs2411
 
DMA operation
DMA operationDMA operation
DMA operation
 
Transport layer (computer networks)
Transport layer (computer networks)Transport layer (computer networks)
Transport layer (computer networks)
 
TCP Vs UDP
TCP Vs UDP TCP Vs UDP
TCP Vs UDP
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptx
 
OsI reference model
OsI reference modelOsI reference model
OsI reference model
 
Transport layer
Transport layerTransport layer
Transport layer
 
PEMOGRAMAN WEB & PERANGKAT BERGERAK
PEMOGRAMAN WEB & PERANGKAT BERGERAKPEMOGRAMAN WEB & PERANGKAT BERGERAK
PEMOGRAMAN WEB & PERANGKAT BERGERAK
 
Polar-NRZ & Polar-RZ encoding schemes
Polar-NRZ & Polar-RZ encoding schemesPolar-NRZ & Polar-RZ encoding schemes
Polar-NRZ & Polar-RZ encoding schemes
 
Chapter 7
Chapter 7Chapter 7
Chapter 7
 

Similar to ASN.1 Basics

Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...Magnus Sedlacek
 
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Erlang Solutions
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesDr Rajiv Srivastava
 
TokuDB vs RocksDB
TokuDB vs RocksDBTokuDB vs RocksDB
TokuDB vs RocksDBVlad Lesin
 
Module 00 Bitwise Operators in C
Module 00 Bitwise Operators in CModule 00 Bitwise Operators in C
Module 00 Bitwise Operators in CTushar B Kute
 
Bits and the organization of memory
Bits and the organization of memoryBits and the organization of memory
Bits and the organization of memorydmendonsa
 
CISSP Week 18
CISSP Week 18CISSP Week 18
CISSP Week 18jemtallon
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Kshitij Singh
 
8051 data type and directives
8051 data type and directives8051 data type and directives
8051 data type and directivesSARITHA REDDY
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directivesSARITHA REDDY
 
Avito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggleAvito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggleAlexey Grigorev
 
License Plate Recognition
License Plate RecognitionLicense Plate Recognition
License Plate RecognitionGilbert
 
初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務Amazon Web Services
 

Similar to ASN.1 Basics (20)

Cache mapping
Cache mappingCache mapping
Cache mapping
 
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
 
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data Types
 
Atc..
Atc..Atc..
Atc..
 
TokuDB vs RocksDB
TokuDB vs RocksDBTokuDB vs RocksDB
TokuDB vs RocksDB
 
Module 00 Bitwise Operators in C
Module 00 Bitwise Operators in CModule 00 Bitwise Operators in C
Module 00 Bitwise Operators in C
 
Bits and the organization of memory
Bits and the organization of memoryBits and the organization of memory
Bits and the organization of memory
 
What character is that
What character is thatWhat character is that
What character is that
 
CISSP Week 18
CISSP Week 18CISSP Week 18
CISSP Week 18
 
Chapter 7 memory & i/o
Chapter 7  memory & i/oChapter 7  memory & i/o
Chapter 7 memory & i/o
 
Compression ii
Compression iiCompression ii
Compression ii
 
Introduction Data Compression/ Data compression, modelling and coding,Image C...
Introduction Data Compression/ Data compression, modelling and coding,Image C...Introduction Data Compression/ Data compression, modelling and coding,Image C...
Introduction Data Compression/ Data compression, modelling and coding,Image C...
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1
 
8051 data type and directives
8051 data type and directives8051 data type and directives
8051 data type and directives
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
 
Avito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggleAvito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggle
 
Quick 3GPP RRC ASN.1
Quick 3GPP RRC ASN.1Quick 3GPP RRC ASN.1
Quick 3GPP RRC ASN.1
 
License Plate Recognition
License Plate RecognitionLicense Plate Recognition
License Plate Recognition
 
初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務
 

More from Tharaka Devinda

Artificial Neural Networks - An Introduction.pptx
Artificial Neural Networks - An Introduction.pptxArtificial Neural Networks - An Introduction.pptx
Artificial Neural Networks - An Introduction.pptxTharaka Devinda
 
Firebase Basics - Dialog Demo for Group Tech Staff
Firebase Basics - Dialog Demo for Group Tech StaffFirebase Basics - Dialog Demo for Group Tech Staff
Firebase Basics - Dialog Demo for Group Tech StaffTharaka Devinda
 
Timetrek internals - Firebase with Google Cloud for a web based game
Timetrek internals - Firebase with Google Cloud for a web based gameTimetrek internals - Firebase with Google Cloud for a web based game
Timetrek internals - Firebase with Google Cloud for a web based gameTharaka Devinda
 
Introduction to Android - Session 3
Introduction to Android - Session 3Introduction to Android - Session 3
Introduction to Android - Session 3Tharaka Devinda
 

More from Tharaka Devinda (6)

Artificial Neural Networks - An Introduction.pptx
Artificial Neural Networks - An Introduction.pptxArtificial Neural Networks - An Introduction.pptx
Artificial Neural Networks - An Introduction.pptx
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Firebase Basics - Dialog Demo for Group Tech Staff
Firebase Basics - Dialog Demo for Group Tech StaffFirebase Basics - Dialog Demo for Group Tech Staff
Firebase Basics - Dialog Demo for Group Tech Staff
 
Timetrek internals - Firebase with Google Cloud for a web based game
Timetrek internals - Firebase with Google Cloud for a web based gameTimetrek internals - Firebase with Google Cloud for a web based game
Timetrek internals - Firebase with Google Cloud for a web based game
 
Introduction to Android - Session 3
Introduction to Android - Session 3Introduction to Android - Session 3
Introduction to Android - Session 3
 
Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to Android
 

Recently uploaded

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

ASN.1 Basics

  • 2. What is ASN.1 ● Way of representing objects ● Used for abstraction in OSI model ● Can represent simple atomic (Integer, String etc.) and complex data structures
  • 3. Why not JSON or XML ● ASN.1 is chosen for efficiency. Not babysitting the codec writers ● JSON / XML takes up too much overhead in transmitting ● ASN.1 can do it with way less. Thus, less bandwidth / lesser resources ● But encoding / decoding / debugging is hard.
  • 4. Compare XML / JSON { “vehicle”: { “wheelCount”: 4, “registration”: “3421” }} 73 bytes <vehicle> <wheelCount>4</wheelCount> <registration>3421<registration> </vehicle> 81 bytes A0 07 02 01 04 16 02 43 12 8 bytes! Note that in both cases, both the encoding and decoding entities MUST have prior knowledge of the data structure
  • 5. Encoding / Decoding ● Done using encoding rules. ● BER (Basic Encoding Rules) is the most popular method ○ Used in TCAP, MAP, CAP ● CER, DER and some others are present
  • 6. Encoding / Decoding Basic Encoding Rules Primitive Types Constructed Types Definite Length Infinite Length
  • 7. Data Structure Encoded as ● Tag and Length are one or multiple bytes ● Content is zero or multiple bytes LENGTH CONTENTTAG
  • 8. Data Structure ● The TAG identifies the data structure ● LENGTH specifies the number of trailing bytes in the CONTENT to follow ● CONTENT...well...what do you think? LENGTH CONTENTTAG
  • 9. TAG Octets ● TAG consists of three parts in BER ○ Class ○ Indication of whether the structure is primitive or compound ○ Tag value 7 6 5 4 3 2 1 0 Class P/C Tag 00 : Universal | 01: Application | 10: Context specific | 11: Private TAG
  • 10. TAG Octets ● In our car example: { “vehicle”: { “wheelCount”: 4, “registration”: “3421” }} The wheel count is an integer. ASN is of class UNIVERSAL (0x00), a PRIMITIVE (0) and INTEGER (Tag 2) Thus 0x02: 0 0 0 0 0 0 1 0 TAG
  • 11. TAG Octets ● What happens when the tag value cannot be represented in the given 5 bits. i.e. Tags > 31 ● If the tag is greater than 30, The TAG octet will become TAG octets. ● The first byte’s tag part will have five 1’s ● Then the other tailing bytes will represent the value. in 7 bits each. with MSB as 1. ● The end is shown with MSB 0. TAG
  • 13. LENGTH Octets ● Definite lengths from 0 to 127 will be represented in the length byte. ● If the length is greater than 127, the long form takes over (just like in TAG octets) ● The MSB is made 1. The rest of the LSBs represent the number of trailing bytes which really gives out the length. LENGTH
  • 14. Confused again? Oh you poor souls!
  • 15. LENGTH Octets The indefinite length is noted with a length octet being 0x80. i.e. MSB 1 and rest zero 1 0 0 0 0 0 0 0 The contents in this case will be terminated with a special ASN tag with TAG 0 and LENGTH 0 i.e. 0x00 0x00 Food for thought: What happens if your data in one of the containers has two consecutive 0s? LENGTH
  • 16. CONTENT Octets ● Contents can be a primitive data type like INTEGER or String ● Or it can be another Tag|Length|Content structure or multiples of it. ● As long as there are LENGTH bytes trailing, there is no issue, whatever it is. CONTENT
  • 17. Let’s look at TCAP with Wireshark