COLLECT STATS is not getting the real values - teradata
I have this table in Teradata (15.00)
CREATE MULTISET TABLE STG_DB.TB_LINES (
COD_ORDER VARCHAR(60) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
NUM_LINE DECIMAL(4,0) NOT NULL
) PRIMARY INDEX TB_LINES_NUPI ( COD_ORDER );
And this is how I collect stats:
COLLECT STATISTICS
COLUMN ( COD_ORDER ) ,
COLUMN ( COD_ORDER,NUM_LINE )
ON STG_DB.TB_LINES ;
But when I do a HELP STATS ON STG_DB.TB_LINES; I get the following results:
Unique Values, Column Names
5,531,048, *
3,403,375, COD_ORDER
72,097, COD_ORDER,NUM_LINE
Why am I getting 72,097 in the (COD_ORDER,NUM_LINE) pair?
The unique value for COD_ORDER,NUM_LINE should be 5,531,048 because NUM_LINE is a sequence I give starting at 1 for every COD_ORDER.
At the very worst, (COD_ORDER,NUM_LINE) should have the same values as (COD_ORDER), shouldn't it?
I have tried adding USING SAMPLE 100 PERCENT with no better output.
How can I get the real full stats on the table? The same values as when I do:
SELECT COUNT(*) AS C FROM (
SELECT COD_ORDER,NUM_LINE
FROM STG_DB.TB_LINES
GROUP BY 1,2 ) D1;
Thanks in advance :)
Edit: Checking the stats values with:
SHOW STATISTICS VALUES COLUMN ( COD_ORDER,NUM_LINE ) ON STG_DB.TB_LINES;
I have seen that my ORDER values were getting truncated to 26 chars and then I have seen this option into the SQL Data Definition Language - Syntax and Examples.pdf:
MAXVALUELENGTH n
Specifies the maximum size for histogram values such as MinValue, ModeValue, MaxValue, and so on, where n is an integer.
For single-character statistics on CHARACTER and VARCHAR columns, n specifies the number of characters. For all other options, n specifies number of bytes.
You can only specify this option if you also specify an explicit index or column set.
You cannot use this option to collect statistics on a geospatial NUSI.
This option is valid only for tables.
So doing the following solved the issue:
COLLECT STATISTICS
USING MAXVALUELENGTH 60 -- length of my COD_ORDER field
COLUMN ( COD_ORDER ) ,
COLUMN ( COD_ORDER,NUM_LINE )
ON STG_DB.TB_LINES ;
Thanks for your time :)
Edit2: Adding the stat values:
COLLECT STATISTICS
COLUMN ( COD_ORDER,NUM_LINE )
ON STG_DB.TB_LINES
VALUES
(
/** SummaryInfo **/
/* Data Type and Length: 'CV:26', 'D:0:4:0' */
/* TimeStamp */ TIMESTAMP '2018-09-03 11:33:16-00:00',
/* Version */ 6,
/* OriginalVersion */ 6,
/* DBSVersion */ '15.00.06.13',
/* UsageType */ 'D',
/* ComplexStatInfo */ 'ComplexStatInfo',
/* NumOfBiasedValues */ 144,
/* NumOfEHIntervals */ 1,
/* NumOfHistoryRecords */ 0,
/* SamplePercent */ 0.00,
/* NumOfNulls */ 0,
/* NumOfAllNulls */ 0,
/* NumOfPartialNullVals */ 0,
/* PartialNullHMF */ 0,
/* AvgAmpRPV */ 0.000000,
/* MinVal */ 'ID:414d5120514d50524f30312', 0.,
/* MaxVal */ 'ID:414d5120514d53474945505', 0.,
/* ModeVal */ 'ID:414d5120514d53474945505', 0.,
/* HighModeFreq */ 36405,
/* NumOfDistinctVals */ 72097,
/* NumOfRows */ 6037117,
/* CPUUsage */ 0.000000,
/* IOUsage */ 0.000000,
/* Reserved */ 0,
/* Reserved */ 0,
/* Reserved */ 0.000000,
/* Reserved */ 0.000000,
/* Reserved */ 'T0000D00000S00000',
/* StatsSkipCount */ 0,
/* SysInsertCnt */ 0,
/* SysDeleteCnt */ 0,
/* SysUpdateCnt */ 0,
/* SysInsDelLastResetTS */ TIMESTAMP '9999-12-31 23:59:59-00:00',
/* SysUpdLastResetTS */ TIMESTAMP '9999-12-31 23:59:59-00:00',
/* IsSampleFollowingTrend*/ 0,
/** Biased: Value[2], Frequency **/
/* 1 */ 'ID:414d5120514d53474945505', 0., 18103,
/* 2 */ 'ID:414d5120514d53474945505', 0., 18110,
/* 3 */ 'ID:414d5120514d53474945505', 0., 17983,
/* 4 */ 'ID:414d5120514d53474945505', 0., 18018,
/* 5 */ 'ID:414d5120514d53474945505', 0., 18058,
/* 6 */ 'ID:414d5120514d53474945505', 0., 17943,
/* 7 */ 'ID:414d5120514d53474945505', 0., 17994,
/* 8 */ 'ID:414d5120514d53474945505', 0., 18166,
/* 9 */ 'ID:414d5120514d53474945505', 0., 18040,
/* 10 */ 'ID:414d5120514d53474945505', 0., 18062,
/* 11 */ 'ID:414d5120514d53474945505', 0., 18299,
/* 12 */ 'ID:414d5120514d53474945505', 0., 18128,
/* 13 */ 'ID:414d5120514d53474945505', 0., 17890,
/* 14 */ 'ID:414d5120514d53474945505', 0., 18422,
/* 15 */ 'ID:414d5120514d53474945505', 0., 18108,
/* 16 */ 'ID:414d5120514d53474945505', 0., 18223,
/* 17 */ 'ID:414d5120514d53474945505', 0., 18033,
/* 18 */ 'ID:414d5120514d53474945505', 0., 18213,
/* 19 */ 'ID:414d5120514d53474945505', 0., 17992,
/* 20 */ 'ID:414d5120514d53474945505', 0., 18225,
/* 21 */ 'ID:414d5120514d53474945505', 0., 18157,
/* 22 */ 'ID:414d5120514d53474945505', 0., 18207,
/* 23 */ 'ID:414d5120514d53474945505', 0., 18436,
/* 24 */ 'ID:414d5120514d53474945505', 0., 18141,
/* 25 */ 'ID:414d5120514d53474945505', 0., 18172,
/* 26 */ 'ID:414d5120514d53474945505', 0., 18241,
/* 27 */ 'ID:414d5120514d53474945505', 0., 18111,
/* 28 */ 'ID:414d5120514d53474945505', 0., 17898,
/* 29 */ 'ID:414d5120514d53474945505', 0., 18201,
/* 30 */ 'ID:414d5120514d53474945505', 0., 18071,
/* 31 */ 'ID:414d5120514d53474945505', 0., 17888,
/* 32 */ 'ID:414d5120514d53474945505', 0., 18035,
/* 33 */ 'ID:414d5120514d53474945505', 0., 18252,
/* 34 */ 'ID:414d5120514d53474945505', 0., 18059,
/* 35 */ 'ID:414d5120514d53474945505', 0., 18187,
/* 36 */ 'ID:414d5120514d53474945505', 0., 18150,
/* 37 */ 'ID:414d5120514d53474945505', 0., 18173,
/* 38 */ 'ID:414d5120514d53474945505', 0., 18026,
/* 39 */ 'ID:414d5120514d53474945505', 0., 18450,
/* 40 */ 'ID:414d5120514d53474945505', 0., 18330,
/* 41 */ 'ID:414d5120514d53474945505', 0., 18227,
/* 42 */ 'ID:414d5120514d53474945505', 0., 17953,
/* 43 */ 'ID:414d5120514d53474945505', 0., 18361,
/* 44 */ 'ID:414d5120514d53474945505', 0., 18176,
/* 45 */ 'ID:414d5120514d53474945505', 0., 18027,
/* 46 */ 'ID:414d5120514d53474945505', 0., 18041,
/* 47 */ 'ID:414d5120514d53474945505', 0., 17983,
/* 48 */ 'ID:414d5120514d53474945505', 0., 18095,
/* 49 */ 'ID:414d5120514d53474945505', 0., 18131,
/* 50 */ 'ID:414d5120514d53474945505', 0., 18334,
/* 51 */ 'ID:414d5120514d53474945505', 0., 18084,
/* 52 */ 'ID:414d5120514d53474945505', 0., 17901,
/* 53 */ 'ID:414d5120514d53474945505', 0., 18139,
/* 54 */ 'ID:414d5120514d53474945505', 0., 18311,
/* 55 */ 'ID:414d5120514d53474945505', 0., 18046,
/* 56 */ 'ID:414d5120514d53474945505', 0., 17992,
/* 57 */ 'ID:414d5120514d53474945505', 0., 17977,
/* 58 */ 'ID:414d5120514d53474945505', 0., 18220,
/* 59 */ 'ID:414d5120514d53474945505', 0., 18179,
/* 60 */ 'ID:414d5120514d53474945505', 0., 18171,
/* 61 */ 'ID:414d5120514d53474945505', 0., 17895,
/* 62 */ 'ID:414d5120514d53474945505', 0., 18270,
/* 63 */ 'ID:414d5120514d53474945505', 0., 18146,
/* 64 */ 'ID:414d5120514d53474945505', 0., 18248,
/* 65 */ 'ID:414d5120514d53474945505', 0., 17901,
/* 66 */ 'ID:414d5120514d53474945505', 0., 18202,
/* 67 */ 'ID:414d5120514d53474945505', 0., 18391,
/* 68 */ 'ID:414d5120514d53474945505', 0., 18173,
/* 69 */ 'ID:414d5120514d53474945505', 0., 18204,
/* 70 */ 'ID:414d5120514d53474945505', 0., 18164,
/* 71 */ 'ID:414d5120514d53474945505', 0., 18233,
/* 72 */ 'ID:414d5120514d53474945505', 0., 18195,
/* 73 */ 'ID:414d5120514d53474945505', 0., 35659,
/* 74 */ 'ID:414d5120514d53474945505', 0., 36011,
/* 75 */ 'ID:414d5120514d53474945505', 0., 35582,
/* 76 */ 'ID:414d5120514d53474945505', 0., 36139,
/* 77 */ 'ID:414d5120514d53474945505', 0., 36271,
/* 78 */ 'ID:414d5120514d53474945505', 0., 36069,
/* 79 */ 'ID:414d5120514d53474945505', 0., 36032,
/* 80 */ 'ID:414d5120514d53474945505', 0., 35960,
/* 81 */ 'ID:414d5120514d53474945505', 0., 36128,
/* 82 */ 'ID:414d5120514d53474945505', 0., 35982,
/* 83 */ 'ID:414d5120514d53474945505', 0., 35960,
/* 84 */ 'ID:414d5120514d53474945505', 0., 36081,
/* 85 */ 'ID:414d5120514d53474945505', 0., 35812,
/* 86 */ 'ID:414d5120514d53474945505', 0., 35858,
/* 87 */ 'ID:414d5120514d53474945505', 0., 35844,
/* 88 */ 'ID:414d5120514d53474945505', 0., 36212,
/* 89 */ 'ID:414d5120514d53474945505', 0., 35803,
/* 90 */ 'ID:414d5120514d53474945505', 0., 36057,
/* 91 */ 'ID:414d5120514d53474945505', 0., 36405,
/* 92 */ 'ID:414d5120514d53474945505', 0., 35983,
/* 93 */ 'ID:414d5120514d53474945505', 0., 35898,
/* 94 */ 'ID:414d5120514d53474945505', 0., 36200,
/* 95 */ 'ID:414d5120514d53474945505', 0., 35650,
/* 96 */ 'ID:414d5120514d53474945505', 0., 35718,
/* 97 */ 'ID:414d5120514d53474945505', 0., 35952,
/* 98 */ 'ID:414d5120514d53474945505', 0., 35979,
/* 99 */ 'ID:414d5120514d53474945505', 0., 35720,
/* 100 */ 'ID:414d5120514d53474945505', 0., 36012,
/* 101 */ 'ID:414d5120514d53474945505', 0., 35974,
/* 102 */ 'ID:414d5120514d53474945505', 0., 36095,
/* 103 */ 'ID:414d5120514d53474945505', 0., 35500,
/* 104 */ 'ID:414d5120514d53474945505', 0., 35932,
/* 105 */ 'ID:414d5120514d53474945505', 0., 36208,
/* 106 */ 'ID:414d5120514d53474945505', 0., 35794,
/* 107 */ 'ID:414d5120514d53474945505', 0., 35882,
/* 108 */ 'ID:414d5120514d53474945505', 0., 35860,
/* 109 */ 'ID:414d5120514d53474945505', 0., 36046,
/* 110 */ 'ID:414d5120514d53474945505', 0., 35880,
/* 111 */ 'ID:414d5120514d53474945505', 0., 35890,
/* 112 */ 'ID:414d5120514d53474945505', 0., 36121,
/* 113 */ 'ID:414d5120514d53474945505', 0., 36002,
/* 114 */ 'ID:414d5120514d53474945505', 0., 35618,
/* 115 */ 'ID:414d5120514d53474945505', 0., 35768,
/* 116 */ 'ID:414d5120514d53474945505', 0., 36022,
/* 117 */ 'ID:414d5120514d53474945505', 0., 35812,
/* 118 */ 'ID:414d5120514d53474945505', 0., 36246,
/* 119 */ 'ID:414d5120514d53474945505', 0., 36189,
/* 120 */ 'ID:414d5120514d53474945505', 0., 35994,
/* 121 */ 'ID:414d5120514d53474945505', 0., 36035,
/* 122 */ 'ID:414d5120514d53474945505', 0., 35618,
/* 123 */ 'ID:414d5120514d53474945505', 0., 35908,
/* 124 */ 'ID:414d5120514d53474945505', 0., 35567,
/* 125 */ 'ID:414d5120514d53474945505', 0., 35775,
/* 126 */ 'ID:414d5120514d53474945505', 0., 35922,
/* 127 */ 'ID:414d5120514d53474945505', 0., 35865,
/* 128 */ 'ID:414d5120514d53474945505', 0., 36027,
/* 129 */ 'ID:414d5120514d53474945505', 0., 35854,
/* 130 */ 'ID:414d5120514d53474945505', 0., 35926,
/* 131 */ 'ID:414d5120514d53474945505', 0., 35951,
/* 132 */ 'ID:414d5120514d53474945505', 0., 36256,
/* 133 */ 'ID:414d5120514d53474945505', 0., 35591,
/* 134 */ 'ID:414d5120514d53474945505', 0., 35822,
/* 135 */ 'ID:414d5120514d53474945505', 0., 35900,
/* 136 */ 'ID:414d5120514d53474945505', 0., 36265,
/* 137 */ 'ID:414d5120514d53474945505', 0., 36109,
/* 138 */ 'ID:414d5120514d53474945505', 0., 35881,
/* 139 */ 'ID:414d5120514d53474945505', 0., 35411,
/* 140 */ 'ID:414d5120514d53474945505', 0., 36192,
/* 141 */ 'ID:414d5120514d53474945505', 0., 35926,
/* 142 */ 'ID:414d5120514d53474945505', 0., 35919,
/* 143 */ 'ID:414d5120514d53474945505', 0., 36026,
/* 144 */ 'ID:414d5120514d53474945505', 0., 35811,
/** Interval: MaxVal[2], ModeVal[2], ModeFreq, LowFreq, OtherVals, OtherRows **/
/* 1 */ 'ID:414d5120514d50524f30312', 0., 'ID:414d5120514d50524f30312', 0., 68, 1, 71952, 2144117
);
Related
Css vars changes not simultaneously for nested elements
I have Vue 3 project with Pinia. I have store for theme export const useThemeStore = defineStore('theme', { state: () => ({ dark: false, }), getters: { current(state) { return state.dark ? Theme.dark : Theme.light }, }, persist: true, }) And I use it in my App.vue (with Pug templates) file like this Head html(:data-theme="theme.current") Also I have styles like html { --col-white: 255 255 255; --col-black: 22 25 33; &[data-theme='dark'] { --col-primary: 255 255 255; --col-secondary: 230 236 245; --col-page: 22 25 33; --col-page-content: 116 140 171; --col-success: 57 158 90; --col-info: 58 133 199; --col-warning: 255 127 17; --col-danger: 255 27 28; } &[data-theme='light'] { --col-primary: 22 25 33; --col-secondary: 116 140 171; --col-page: 255 255 255; --col-page-content: 230 236 245; --col-success: 57 158 90; --col-info: 58 133 199; --col-warning: 255 127 17; --col-danger: 255 27 28; } } And I have problem - all variables changes with delay from top to bottom in DOM nesting Here's gif to understand
traceroute -T -p 25 alt4.aspmx.l.google.com
When I am sending emails my log says connection timed out. when I ran traceroute: traceroute -T -p 25 alt4.aspmx.l.google.com , I am getting the following output. traceroute to alt4.aspmx.l.google.com (74.125.141.27), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * 4 * * * 5 * * * 6 * * * 7 * * * 8 * * * 9 * * * 10 * * * 11 * * * 12 * * * 13 * * * 14 * * * 15 * * * 16 * * * 17 * * * 18 * * * 19 * * * 20 * * * 21 * * * 22 * * * 23 * * * 24 * * * 25 * * * 26 * * * 27 * * * 28 * * * 29 * * * 30 * * * Any ideas how to solve this.
To check connectivity run telnet alt4.aspmx.l.google.com 25 and on other screen run tcpdump -i any port 25 or icmp And then analyze tcpdump output
SVG inlined in CSS works in Chrome/Edge but not in Firefox [duplicate]
This question already has an answer here: How to use a hex value for SVG in FireFox (1 answer) Closed 5 years ago. I have the following code to display icons. The GitHub icon doesn't work on Firefox but works on Chrome and Edge. Strangely, the Google icon works on all browsers! .github-icon { background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='#fff' d='M1664 896q0 251-146.5 451.5t-378.5 277.5q-27 5-39.5-7t-12.5-30v-211q0-97-52-142 57-6 102.5-18t94-39 81-66.5 53-105 20.5-150.5q0-121-79-206 37-91-8-204-28-9-81 11t-92 44l-38 24q-93-26-192-26t-192 26q-16-11-42.5-27t-83.5-38.5-86-13.5q-44 113-7 204-79 85-79 206 0 85 20.5 150t52.5 105 80.5 67 94 39 102.5 18q-40 36-49 103-21 10-45 15t-57 5-65.5-21.5-55.5-62.5q-19-32-48.5-52t-49.5-24l-20-3q-21 0-29 4.5t-5 11.5 9 14 13 12l7 5q22 10 43.5 38t31.5 51l10 23q13 38 44 61.5t67 30 69.5 7 55.5-3.5l23-4q0 38 .5 89t.5 54q0 18-13 30t-40 7q-232-77-378.5-277.5t-146.5-451.5q0-209 103-385.5t279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z'/%3E%3C/svg%3E%0A"); background-repeat: no-repeat; background-color: dimgray; } .google-icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-60 -60 710.117 710.117' %3E%3Cpath fill='%23fff' fill-rule='evenodd' clip-rule='evenodd' d='M516.375,255v-76.5h-51V255h-76.5v51h76.5v76.5h51V306h76.5v-51H516.375z M320.025,341.7l-28.051-20.4%0Ac-10.2-7.649-20.399-17.85-20.399-35.7s12.75-33.15,25.5-40.8c33.15-25.5,66.3-53.55,66.3-109.65c0-53.55-33.15-84.15-51-99.45%0Ah43.35l30.6-35.7h-158.1c-112.2,0-168.3,71.4-168.3,147.9c0,58.65,45.9,122.4,127.5,122.4h20.4c-2.55,7.65-10.2,20.4-10.2,33.15%0Ac0,25.5,10.2,35.7,22.95,51c-35.7,2.55-102,10.2-150.45,40.8c-45.9,28.05-58.65,66.3-58.65,94.35%0Ac0,58.65,53.55,114.75,168.3,114.75c137.7,0,204.001-76.5,204.001-150.449C383.775,400.35,355.725,372.3,320.025,341.7z%0AM126.225,109.65c0-56.1,33.15-81.6,68.85-81.6c66.3,0,102,89.25,102,140.25c0,66.3-53.55,79.05-73.95,79.05%0AC159.375,247.35,126.225,168.3,126.225,109.65z M218.024,568.65c-84.15,0-137.7-38.25-137.7-94.351c0-56.1,51-73.95,66.3-81.6%0Ac33.15-10.2,76.5-12.75,84.15-12.75s12.75,0,17.85,0c61.2,43.35,86.7,61.2,86.7,102C335.324,530.4,286.875,568.65,218.024,568.65z%0A'/%3E%3C/svg%3E%0A"); background-repeat: no-repeat; background-color: red; }
Found it. # should be replaced with %23
parsing asn.1 with bouncycastle
I have some asn.1 encoded data. I have some success decoding it with bouncycastle but I hit the wall with quite complex example. It must be doable, but can't get further, hope you could help me, here is the example data: A1 81 A9 02 02 1C 1F 02 01 15 30 81 9F 55 02 01 14 A0 81 98 A4 81 95 6B 10 30 0E 80 04 00 00 01 1F A1 06 30 04 80 02 33 32 63 06 30 04 80 02 33 32 61 0E 30 0C 80 0A 30 32 32 33 37 38 33 36 31 30 62 06 30 04 80 02 33 32 64 02 87 00 6B 13 30 11 80 04 00 00 01 1F A1 09 30 07 80 05 23 23 37 30 30 4E 01 02 0A 01 16 67 12 30 10 A3 0E 81 0C 2B 34 38 32 32 33 37 38 33 36 31 30 68 0F 30 0D A3 0B 82 09 32 32 38 36 35 33 33 39 38 65 09 30 07 80 05 23 23 37 30 30 7E 12 A0 10 18 0E 32 30 31 36 30 33 30 32 32 32 30 31 33 36 CSTA Browser decoded: rOSE.roiv-apdu { -- SEQUENCE -- invokeID = 7199, operation-value = 21 (cSTAEventReport), argument { -- SEQUENCE -- crossRefIdentifier = '01 14'H, eventSpecificInfo.callControlEvents.delivered { -- SEQUENCE -- connection.both { -- SEQUENCE -- callID = '00 00 01 1F'H, deviceID.staticID { -- SEQUENCE -- deviceIdentifier.dialingNumber = "32" '33 32'H } }, alertingDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.dialingNumber = "32" '33 32'H }, callingDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.dialingNumber = "0223783610" '30 32 32 33 37 38 33 36 31 30'H }, calledDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.dialingNumber = "32" '33 32'H }, lastRedirectionDevice.notKnown NULL, originatingNIDConnection.both { -- SEQUENCE -- callID = '00 00 01 1F'H, deviceID.staticID { -- SEQUENCE -- deviceIdentifier.dialingNumber = "##700" '23 23 37 30 30'H } }, localConnectionInfo = 2 (alerting), cause = 22 (newCall), networkCallingDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.explicitPublic.international = "+48223783610" '2B 34 38 32 32 33 37 38 33 36 31 30'H }, networkCalledDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.explicitPublic.national = "228653398" '32 32 38 36 35 33 33 39 38'H }, associatedCallingDevice.deviceIdentifier { -- SEQUENCE -- deviceIdentifier.dialingNumber = "##700" '23 23 37 30 30'H }, extensions { -- SEQUENCE -- security { -- SEQUENCE -- timestamp = "20160302220136" '32 30 31 36 30 33 30 32 32 32 30 31 33 36'H } } } } } bouncycastle's dump produces something like that: 00 AC A1 81 A9 02 02 5F B9 02 01 15 30 81 9F 55 02 01 91 A0 81 98 A4 81 95 6B 10 30 0E 80 04 00 00 03 98 A1 06 30 04 80 02 33 32 63 06 30 04 80 02 33 32 61 0E 30 0C 80 0A 30 32 32 33 37 38 33 36 31 30 62 06 30 04 80 02 33 32 64 02 87 00 6B 13 30 11 80 04 00 00 03 98 A1 09 30 07 80 05 23 23 37 30 30 4E 01 02 0A 01 16 67 12 30 10 A3 0E 81 0C 2B 34 38 32 32 33 37 38 33 36 31 30 68 0F 30 0D A3 0B 82 09 32 32 38 36 35 33 33 39 38 65 09 30 07 80 05 23 23 37 30 30 7E 12 A0 10 18 0E 32 30 31 36 30 33 30 34 31 35 32 32 34 30 buf:Tagged [1] IMPLICIT Sequence Integer(24505) Integer(21) DER Sequence DER ApplicationSpecific[21] (0191) Tagged [0] Tagged [4] IMPLICIT Sequence DER ApplicationSpecific[11] Sequence Tagged [0] IMPLICIT DER Octet String[4] Tagged [1] DER Sequence Tagged [0] IMPLICIT DER Octet String[2] DER ApplicationSpecific[3] Sequence Tagged [0] IMPLICIT DER Octet String[2] DER ApplicationSpecific[1] Sequence Tagged [0] IMPLICIT DER Octet String[10] DER ApplicationSpecific[2] Sequence Tagged [0] IMPLICIT DER Octet String[2] DER ApplicationSpecific[4] Tagged [7] IMPLICIT DER Octet String[0] DER ApplicationSpecific[11] Sequence Tagged [0] IMPLICIT DER Octet String[4] Tagged [1] DER Sequence Tagged [0] IMPLICIT DER Octet String[5] DER ApplicationSpecific[14] (02) DER Enumerated(22) DER ApplicationSpecific[7] Sequence Tagged [3] Tagged [1] IMPLICIT DER Octet String[12] DER ApplicationSpecific[8] Sequence Tagged [3] Tagged [2] IMPLICIT DER Octet String[9] DER ApplicationSpecific[5] Sequence Tagged [0] IMPLICIT DER Octet String[5] DER ApplicationSpecific[30] Tagged [0] GeneralizedTime(20160304152240GMT+01:00) and I am trying to parse it: protected void parse() { logger.trace("Executing parse()"); try { ASN1InputStream input = new ASN1InputStream(asn1Data); ASN1Primitive p; if ((p = input.readObject()) != null) { ASN1TaggedObject o1 = ASN1TaggedObject.getInstance(p); ASN1Sequence s1 = ASN1Sequence.getInstance(o1.getObject()); invokeID = Integer.parseInt(s1.getObjectAt(0).toString()); operationValue = Integer.parseInt(s1.getObjectAt(1).toString()); DERSequence ders = (DERSequence) DERSequence.getInstance(s1.getObjectAt(2)); DERApplicationSpecific das = (DERApplicationSpecific) ders.getObjectAt(0); crossRefIdentifier = das.getContents(); //here are some experiments, but can't get the right objects I could parse / walk through ASN1TaggedObject o2 = ASN1TaggedObject.getInstance(ders.getObjectAt(1)); DERTaggedObject dto = (DERTaggedObject) o2.getObject(); ASN1Sequence s2 = ASN1Sequence.getInstance(dto.getObject()); DERApplicationSpecific das1 = (DERApplicationSpecific) s2.getObjectAt(0); ASN1Sequence s3 = (ASN1Sequence) das1.getObject(); } } catch (Exception ex) { logger.warn("exception while parsing ASN1 data", ex); } } as you can see I've been able to decode some basic tags (ie. invokeID, operation-value and crossRefIdentifier) but can't get deeper in the tree (callId, callingNumber ...). If you have experience in that matter I would appreciate your help.
It is a very complex ASN.1 object. There are several places where it could go wrong with another sample due to structure differences. Here is an example. using System; using System.Collections; using System.IO; using Org.BouncyCastle.Asn1; namespace Asn1ParseBouncy { class Program { static void Main(string[] args) { var bytes2Parse = File.ReadAllBytes(#"c:\a.req"); // (0,169) CONTEXT SPECIFIC(1) DerTaggedObject rootObj = (DerTaggedObject)Asn1Object.FromByteArray(bytes2Parse); if (rootObj.TagNo == 1) { ParseAtRootLevel(rootObj); } else { throw new Exception("Expected Tag number to be 1"); } } private static void ParseAtRootLevel(DerTaggedObject rootObj) { // SEQUENCE under CONTEXT SPECIFIC(1) var seq = (Asn1Sequence)rootObj.GetObject(); IEnumerator e = seq.GetEnumerator(); bool hasNext; hasNext = e.MoveNext(); // (3,2) INTEGER -> invokeID { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; // TODO: put in a property of class that represents whole ASN.1 message var invokeID = DerInteger.GetInstance(obj); hasNext = e.MoveNext(); } // (7,1) INTEGER -> operation-value { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; // TODO: put in a property of class that represents whole ASN.1 message var operationValue = DerInteger.GetInstance(obj); hasNext = e.MoveNext(); } // (10,159) SEQUENCE -> argument { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; var argumentSeq = Asn1Sequence.GetInstance(obj); // argumentData is parsed asn.1 object - argument var argumentData = ParseArgumentData(argumentSeq); hasNext = e.MoveNext(); } if (hasNext) { throw new Exception("no more entries expected in sequence"); } } private static object ParseArgumentData(Asn1Sequence argumentSeq) { IEnumerator e = argumentSeq.GetEnumerator(); bool hasNext; hasNext = e.MoveNext(); // (13,2) APPLICATION (21) -> crossRefIdentifier { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; var crossRefIdentifierAppSpecific = (DerApplicationSpecific)obj; if (crossRefIdentifierAppSpecific.ApplicationTag != 21) throw new Exception("Expected application tag 21"); // TODO: put in a property of class that represents whole ASN.1 message var crossRefIdentifier = crossRefIdentifierAppSpecific.GetContents(); hasNext = e.MoveNext(); } // (17,152) CONTEXT SPECIFIC (0) -> eventSpecificInfo.callControlEvents.delivered { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; var eventSpecificInfo = ((DerTaggedObject)obj); if (eventSpecificInfo.TagNo != 0) throw new Exception("Expected Context specific tag number to be 0"); // TODO: put in a property of class that represents whole ASN.1 message var eventSpecificInfoData = ParseEventSpecificInfo(eventSpecificInfo); hasNext = e.MoveNext(); } if (hasNext) { throw new Exception("no more entries expected in sequence"); } // TODO: return parsed values in some class return null; } private static object ParseEventSpecificInfo(DerTaggedObject obj) { // still (17,152) CONTEXT SPECIFIC (0) var connectionBothData = ParseConnectionBoth(obj); return connectionBothData; } private static object ParseConnectionBoth(DerTaggedObject connectionBoth) { // (20,149) CONTEXT SPECIFIC (4)->connection.both var connectionBothTagged = (DerTaggedObject)connectionBoth.GetObject(); if (connectionBothTagged.TagNo != 4) throw new Exception("Expected Context specific tag number to be 4"); // Sequence under (20,149) CONTEXT SPECIFIC (4) -> connection.both var connectionBothSeq = (DerSequence)connectionBothTagged.GetObject(); IEnumerator e = connectionBothSeq.GetEnumerator(); bool hasNext; hasNext = e.MoveNext(); // callID { Asn1Encodable obj; if (!hasNext) { throw new Exception("more entries expected in sequence"); } obj = (Asn1Encodable)e.Current; // (23,16) APPLICATION (11) // TODO: put in a property of class that represents whole ASN.1 message var callIDTagged = (DerApplicationSpecific)obj; if (callIDTagged.ApplicationTag != 11) throw new Exception("Expected tag number 11"); // (25,14) SEQUENCE var callIdSeq = callIDTagged.GetObject().GetDerEncoded(); // TODO: parse CallIdSeq -> (27,4) ContextSpecific(0), (33,6) ContextSpecific(1) hasNext = e.MoveNext(); } // TODO: continue with (41,6) Application (3) // TODO: continue with (49,14) Application (1) // TODO: continue with (65,6) Application (2) // etc. // TOOD: return something useful throw new NotImplementedException(); } } } I placed notes in the code sample according to dump from ASN.1 Editor You could make your life a lot easier if you had ASN.1 definition of the object. With help from Binary Notes you could generate classes to parse ASN.1 data object.
convert float to integer
how to scale and by which factor to scale dctmtx coefficients from float to get following integer values: float dctmtx: ( (0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536), (0.4904 0.4157 0.2778 0.0975 -0.0975 -0.2778 -0.4157 -0.4904), (0.4619 0.1913 -0.1913 -0.4619 -0.4619 -0.1913 0.1913 0.4619), (0.4157 -0.0975 -0.4904 -0.2778 0.2778 0.4904 0.0975 -0.4157), (0.3536 -0.3536 -0.3536 0.3536 0.3536 -0.3536 -0.3536 0.3536), (0.2778 -0.4904 0.0975 0.4157 -0.4157 -0.0975 0.4904 -0.2778), (0.1913 -0.4619 0.4619 -0.1913 -0.1913 0.4619 -0.4619 0.1913), (0.0975 -0.2778 0.4157 -0.4904 0.4904 -0.4157 0.2778 -0.0975) ) integer dctmtx: (( 125, 122, 115, 103, 88, 69, 47, 24 ), ( 125, 103, 47, -24, -88, -122, -115, -69 ), ( 125, 69, -47, -122, -88, 24, 115, 103 ), ( 125, 24, -115, -69, 88, 103, -47, -122 ), ( 125, -24, -115, 69, 88, -103, -47, 122 ), ( 125, -69, -47, 122, -88, -24, 115, -103 ), ( 125, -103, 47, 24, -88, 122, -115, 69 ), ( 125, -122, 115, -103, 88, -69, 47, -24 ) );
Besides one of the two matrices being rotated the two don't appear to have a direct linear relationship: #include <stdlib.h> #include <stdio.h> #include <math.h> int main (int argc, char *argv[]) { float dctmtx[8][8] = { 0.3536, 0.3536, 0.3536, 0.3536, 0.3536, 0.3536, 0.3536, 0.3536, 0.4904, 0.4157, 0.2778, 0.0975, -0.0975, -0.2778, -0.4157, -0.4904, 0.4619, 0.1913, -0.1913, -0.4619, -0.4619, -0.1913, 0.1913, 0.4619, 0.4157, -0.0975, -0.4904, -0.2778, 0.2778, 0.4904, 0.0975, -0.4157, 0.3536, -0.3536, -0.3536, 0.3536, 0.3536, -0.3536, -0.3536, 0.3536, 0.2778, -0.4904, 0.0975, 0.4157, -0.4157, -0.0975, 0.4904, -0.2778, 0.1913, -0.4619, 0.4619, -0.1913, -0.1913, 0.4619, -0.4619, 0.1913, 0.0975, -0.2778, 0.4157, -0.4904, 0.4904, -0.4157, 0.2778, -0.0975 }; int j,k, i; float m; for ( j = 0; j < 8; j++) { for ( k = 0; k < 8; k++) { if ( k == 0) m = (dctmtx[k][j] * 354) ; else m = (dctmtx[k][j] * 248) ; i = lroundf(m); printf("%4d ",i); } printf("\n"); } } The first coefficient in each row appears to be to a different accuracy than the remaining: %% convftoi 125 122 115 103 88 69 47 24 125 103 47 -24 -88 -122 -115 -69 125 69 -47 -122 -88 24 115 103 125 24 -115 -69 88 103 -47 -122 125 -24 -115 69 88 -103 -47 122 125 -69 -47 122 -88 -24 115 -103 125 -103 47 24 -88 122 -115 69 125 -122 115 -103 88 -69 47 -24 After a little finessing to find scaling factors that did give a match. addendum After LutzL's answer I derived the float coefficient matrix algorithmically: #include <stdlib.h> #include <stdio.h> #include <math.h> #define PI 3.14159265359 int main (int argc, char *argv[]) { float calcmtx[8][8]; int j,k, i; float m; printf("float coefficients calculated\n"); for ( j = 0; j < 8; j++) { for ( k = 0; k < 8; k++) { if ( j == 0) m = cos(PI*j*(2*k+1)/16)/(sqrt(2)*2) ; else m = cos(PI*j*(2*k+1)/16)/2 ; calcmtx[k][j] = floorf(m*10000 + 0.5)/10000; } } for ( j = 0; j < 8; j++) { for ( k = 0; k < 8; k++) { printf("% 2.4f ", calcmtx[k][j]); } printf("\n"); } printf("\n") ; printf("integer coefficients derived\n"); for ( j = 0; j < 8; j++) { for ( k = 0; k < 8; k++) { if (k == 0) m = sqrt(2); else m = 1; i = (int) (calcmtx[j][k] * 250 * m); printf("%4d ", i); } printf("\n"); } printf("\n") ; printf("approximated integer coefficients\n"); for ( j = 0; j < 8; j++) { for ( k = 0; k < 8; k++) { if ( k == 0) m = calcmtx[j][k] * 354 ; else m = calcmtx[j][k] * 248 ; i = lroundf(m); printf("%4d ", i); } printf("\n"); } } And we see that the integer matrix first coefficient is multiplied by the square root of two: %% gencoeffi float coefficients calculated 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.4904 0.4157 0.2778 0.0975 -0.0975 -0.2778 -0.4157 -0.4904 0.4619 0.1913 -0.1913 -0.4619 -0.4619 -0.1913 0.1913 0.4619 0.4157 -0.0975 -0.4904 -0.2778 0.2778 0.4904 0.0975 -0.4157 0.3536 -0.3536 -0.3536 0.3536 0.3536 -0.3536 -0.3536 0.3536 0.2778 -0.4904 0.0975 0.4157 -0.4157 -0.0975 0.4904 -0.2778 0.1913 -0.4619 0.4619 -0.1913 -0.1913 0.4619 -0.4619 0.1913 0.0975 -0.2778 0.4157 -0.4904 0.4904 -0.4157 0.2778 -0.0975 integer coefficients derived 125 122 115 103 88 69 47 24 125 103 47 -24 -88 -122 -115 -69 125 69 -47 -122 -88 24 115 103 125 24 -115 -69 88 103 -47 -122 125 -24 -115 69 88 -103 -47 122 125 -69 -47 122 -88 -24 115 -103 125 -103 47 24 -88 122 -115 69 125 -122 115 -103 88 -69 47 -24 approximated integer coefficients 125 122 115 103 88 69 47 24 125 103 47 -24 -88 -122 -115 -69 125 69 -47 -122 -88 24 115 103 125 24 -115 -69 88 103 -47 -122 125 -24 -115 69 88 -103 -47 122 125 -69 -47 122 -88 -24 115 -103 125 -103 47 24 -88 122 -115 69 125 -122 115 -103 88 -69 47 -24 Which matches the approximation when the float accuracy is limited.
If you read up on the discrete cosine transform, you will find that the basic coefficient is cos(pi*i*(2*j+1)/16), i,j=0..7 Then the first table consists of these values scaled by 0.5, except for the first row/column, which is scaled by 0.25*sqrt(2)=1/sqrt(8). Which is the correct way to obtain an orthogonal matrix. The square sum of the first column is 8, of the others 4. The second table is the rounded results when multiplying the cosine values with 125, uniformly. Here one has to take care to properly rescale the vector when using the transpose matrix to compute the inverse transform. First table reproduced, except for the first column: > [[ Cos(pi*i*(2*j+1)/16)/2 : i in [0..7] ]: j in [0..7] ]; [ [ 0.5, 0.49039264, 0.46193977, 0.41573481, 0.35355339, 0.27778512, 0.19134172, 0.09754516 ], [ 0.5, 0.41573481, 0.19134172, -0.09754516, -0.35355339, -0.49039264, -0.46193977, -0.27778512 ], [ 0.5, 0.27778512, -0.19134172, -0.49039264, -0.35355339, 0.09754516, 0.46193977, 0.41573481 ], [ 0.5, 0.09754516, -0.46193977, -0.27778512, 0.35355339, 0.41573481, -0.19134172, -0.49039264 ], [ 0.5, -0.09754516, -0.46193977, 0.27778512, 0.35355339, -0.41573481, -0.19134172, 0.49039264 ], [ 0.5, -0.27778512, -0.19134172, 0.49039264, -0.35355339, -0.09754516, 0.46193977, -0.41573481 ], [ 0.5, -0.41573481, 0.19134172, 0.09754516, -0.35355339, 0.49039264, -0.46193977, 0.27778512 ], [ 0.5, -0.49039264, 0.46193977, -0.41573481, 0.35355339, -0.27778512, 0.19134172, -0.09754516 ] ] Second table, before integer rounding > [[ Cos( pi*i*(2*j+1)/16 ) *125 : i in [0..7] ]: j in [0..7] ]; [ [ 125, 122.5982, 115.4849, 103.9337, 88.3883, 69.4463, 47.8354, 24.3863 ], [ 125, 103.9337, 47.8354, -24.3863, -88.3883, -122.5982, -115.4849, -69.4463 ], [ 125, 69.4463, -47.8354, -122.5982, -88.3883, 24.3863, 115.4849, 103.9337 ], [ 125, 24.3863, -115.4849, -69.4463, 88.3883, 103.9337, -47.8354, -122.5982 ], [ 125, -24.3863, -115.4849, 69.4463, 88.3883, -103.9337, -47.8354, 122.5982 ], [ 125, -69.4463, -47.8354, 122.5982, -88.3883, -24.3863, 115.4849, -103.9337 ], [ 125, -103.9337, 47.8354, 24.3863, -88.3883, 122.5982, -115.4849, 69.4463 ], [ 125, -122.5982, 115.4849, -103.9337, 88.3883, -69.4463, 47.8354, -24.3863 ] ]