I am trying to understand what data is inside this tageta. I tried to pass it to ASCII but rare characters come out.
+Sector: 0
53E04E2DD00804006263646566676869
00006166280000000000000000000026
000000000000000000000000000000B1
A0000000000078778869B00000000000
+Sector: 1
F852340000000000000000000000001A
000000000000000000000000000000B1
000000000000000000000000000000B1
A0100000000078778869B01000000000
+Sector: 2
2020202020202020202020202020206B
2020202020202020202020202020206B
2020202020202020202020202020206B
A0200000000078778869B02000000000
+Sector: 3
BC036087E80102000000000000000020
000000000000000000000000000000B1
000000000000000000000000000000B1
A0300000000078778869B03000000000
+Sector: 4
04C4220000888EA96E4DA4781111C9D8
04C4220000888EA96E4DA4781111C9D8
000000000000000000000000000000B1
A040000000007B478869B04000000000
+Sector: 5
BC542B0000000000FF6909000000002B
0100008088270E041CE0566EB00700A2
0100008088270E041CE0566EB00700A2
A050000000007E178869B05000000000
+Sector: 6
000000000000000000000000000000B1
000000000000000000000000000000B1
000000000000000000000000000000B1
A060000000007E178869B06000000000
+Sector: 7
FFFFFFFF00000000FFFFFFFF1CE31C73
FFFFFFFF00000000FFFFFFFF1DE21DAC
000000000000000000000000000000B1
A0700000000048778B69B07000000000
+Sector: 8
000000000000000000000000000000B1
000000000000000000000000000000B1
000000000000000000000000000000B1
A0800000000078778869B08000000000
+Sector: 9
FEA30411A812F505548702A0006C1336
FEA30411A812F505548702B0107122A2
FEA30411A812F505548702C0104117E1
A0900000000078778869B09000000000
+Sector: 10
000000000000000000000000000000B1
000000000000000000000000000000B1
000000000000000000000000000000B1
A1000000000078778869B10000000000
+Sector: 11
A03A80404000B25C7D27DE0E11AB19DD
A11A80404012AA5B13299E6C11CB45F2
A03A80404020B7DB6DE99E6C11EEC4D4
A110000000007F078869B11000000000
+Sector: 12
A11A80402002B25C7D27DE21110E75D1
A03A80404000B25C7D279E0E11CE19C8
A11A80404062AA5B13299EA711EE19D1
A120000000007F078869B12000000000
+Sector: 13
A05A00814080375E52E95E00110F354C
A11A00812092B1DCB127DE28112F0978
A03A80404020B7DB6DE99E6C11F1C49B
A130000000007F078869B13000000000
+Sector: 14
A11A80402062AA5B13299E541111C9A1
000000000000000000000000000000B1
000000000000000000000000000000B1
A1400000000079678869B14000000000
+Sector: 15
000000000000000000000000000000B1
000000000000000000000000000000B1
000000000000000000000000000000B1
A1500000000078778869B15000000000
I mean like you can turn it into data that you can understand?
The First Sector (0) is the MAD where the first block is the
manufacturecode. Then comes the MIFARE Application Directory (MAD)
which says where are the applications stored. The Byte 0 from BLOCK1
is a CRC in your case 0x26 then byte1 is an info byte after that
there comes the application id´s (AID´s) 2 byte per AID in your case
there is in Sector 5 an Application with the AID 2800 and sector 6 an
application with AID 6661 and so on.
The Sector it self is build like:
A11A80402002B25C7D27DE21110E75D1 - BLOCK0
A03A80404000B25C7D279E0E11CE19C8 - BLOCK1
A11A80404062AA5B13299EA711EE19D1 - BLOCK2
[ KEYA ][ AC ]69[ KEYB ] - SECTORTRAILOR
That said your data should be only in SECTOR 5,6,8
For the Data itself there are many way´s to interpret data.
BCD (Binary Coded Decimal)
Also you can interpret the data as ASCII-Encoded
Further more there is int16, int32, int64 and it´s unsignt equivalent
For your data I try to interpret something. Sector 5 the first block
may build from 4 UInt Numbers which are:
BC542B00 ~> 2839740 LSB may be an ID
00000000 ~> 0
FF690900 ~> 616959 LSB another ID
0000002B ~> 43 MSB some kind of version
The second Block of Sector 5 starts with a BCD
010000808827 ~> 010000808827
The software which is interpreting the data should know where to find
it´s data and what todo with it. So mostly the data format is given
by some spec.
Related
I have some data that looks like the following:
UniqueID MonthYear Count2 CCount
402ABC OCT2018 5 1
402ABC NOV2018 5 2
402ABC DEC2018 5 3
402ABC JAN2019 5 4
402ABC FEB2019 5 5
495DEF FEB2019 10 1
495DEF MAR2019 10 2
495DEF APR2019 10 3
495DEF MAY2019 10 4
495DEF JUN2019 10 5
495DEF AUG2019 10 6
495DEF SEP2019 10 7
495DEF DEC2019 10 8
495DEF JAN2020 10 9
495DEF FEB2020 10 10
What I want is to be able to create a new column titled "Corrected" that finds the last instance of a UniqueID. Ideally, the new data would look like the following:
UniqueID MonthYear Count2 CCount Corrected
402ABC OCT2018 5 1 0
402ABC NOV2018 5 2 0
402ABC DEC2018 5 3 0
402ABC JAN2019 5 4 0
402ABC FEB2019 5 5 1
495DEF FEB2019 10 1 0
495DEF MAR2019 10 2 0
495DEF APR2019 10 3 0
495DEF MAY2019 10 4 0
495DEF JUN2019 10 5 0
495DEF AUG2019 10 6 0
495DEF SEP2019 10 7 0
495DEF DEC2019 10 8 0
495DEF JAN2020 10 9 0
495DEF FEB2020 10 10 1
I had a series of nested ifelse functions used to create the "Corrected" column in my data frame. The nested chunk looked like the following:
smd$Corrected=ifelse(smd$MonthYear=="OCT2018" & smd$Count2==1, 1,ifelse(
smd$MonthYear=="OCT2018" & smd$Count2 >1, 0,ifelse(
smd$MonthYear=="NOV2018" & smd$Count2==1, 1,ifelse(
smd$MonthYear=="NOV2018" & smd$Count2==smd$CCount, 1,ifelse(
smd$MonthYear=="NOV2018" & smd$Count2!=smd$CCount, 0,ifelse(
smd$MonthYear=="DEC2018" & smd$Count2==1, 1,ifelse(
smd$MonthYear=="DEC2018" & smd$Count2==smd$CCount, 1,ifelse(
smd$MonthYear=="DEC2018" & smd$Count2!=smd$CCount, 0,ifelse(
………………………
smd$MonthYear=="MAY2020" & smd$Count2==1, 1,ifelse(
smd$MonthYear=="MAY2020" & smd$Count2==smd$CCount, 1,ifelse(
smd$MonthYear=="MAY2020" & smd$Count2!=smd$CCount, 0,0
)))))))))))))))))))))))))))))))))))))))))))))))))))))
I understand this was not the most elegant solution, but it worked for my purposes. This is just one part of a larger analysis I was running. The analysis was updated once every month and I added a new chunk to this code each time I updated it. Today, when I attempted to update the code, I got the following error:
Error: contextstack overflow at line 66
Doing a little bit of research, I learned that this error pops up when you use too many nested ifelse statements. Other questions on StackOverflow suggested I use either sapply or mapply to rewrite this code. I tried a couple of apply functions here to rewrite my code, but nothing seemed to work quite right.
Can anyone help suggesting how I would rewrite my code to not use all the nested ifelse functions? Any help would be appreciated!
Thank you!
As I mentioned in a comment, my suggestion would be to remove the line-by-line conditioning on MonthYear, it seems like you don't really need to do that.
If it is necessary to condition on MonthYear, it may be better to use
smd$MonthYear %in% c("OCT2018", "NOV2018" ...)
in your ifelse.
I'm reading about raft, but I got a bit confused when it comes to consensus after a network partition.
So, considering a cluster of 2 nodes, 1 Leader, 1 Follower.
Before partitioning, there where X messages written, successfully replicated, and then imagine that a network problem caused partitioning, so there are 2 partitions, A(ex-leader) and B(ex-follower), which are now both leaders (receiving writes):
before partition | Messages |x| Partition | Messages
Leader | 0 1 2 3 4 |x| Partition A | 5 6 7 8 9
Follower | 0 1 2 3 4 |x| Partition B | 5' 6' 7' 8' 9'
After the partition event, we've figured it out, what happens?
a) We elect 1 new leader and consider its log? (dropping messages of the new follower?
e.g:
0 1 2 3 4 5 6 7 8 9 (total of 10 messages, 5 dropped)
or even:
0 1 2 3 4 5' 6' 7' 8' 9' (total of 10 messages, 5 dropped)
(depending on which node got to be leader)
b) We elect a new leader and find a way to make consensus of all the messages?
0 1 2 3 4 5 5' 6 6' 7 7' 8 8' 9 9' (total of 15 messages, 0 dropped)
if b, is there any specific way of doing that? or it depends on client implementation? (e.g.: message timestamp...)
The leaders log is taken to be "the log" when the leader is elected and has successfully written its initial log entry for the term. However in your case the starting premise is not correct. In a cluster of 2 nodes, a node needs 2 votes to be leader, not 1. So given a network partition neither node will be leader.
This question already has answers here:
How to sum a variable by group
(18 answers)
Closed 7 years ago.
I don't know how to word the title exactly, so I will just do my best to explain below... Sorry in advance for the .csv format.
I have the following example dataset:
print(data)
ID Tag Flowers
1 1 6871 1
2 2 6750 1
3 3 6859 1
4 4 6767 1
5 5 6747 1
6 6 6261 1
7 7 6750 1
8 8 6767 1
9 9 6812 1
10 10 6746 1
11 11 6496 4
12 12 6497 1
13 13 6495 4
14 14 6481 1
15 15 6485 1
Notice that in Lines 2 and 7, the tag 6750 appears twice. I observed one flower on plant number 6750 on two separate days, equaling two flowers in its lifetime. Basically, I want to add every flower that occurs for tag 6750, tag 6767, etc throughout ~100 rows. Each tag appears more than once, usually around 4 or 5 times.
I feel like I need to apply the unlist function here, but I'm a little bit lost as to how I should do so.
Without any extra packages, you can use function aggregate():
res<-aggregate(data$Flowers, list(data$Tag), sum)
This calculates a sum of the values in Flowers column for every value in the Tag column.
I'm trying to encode a TCP header myself, but can't understand what is the right order of bits/octets in it. This is what RFC 793 says:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
This means that Source Port should take first two octets and the lowest bit should be in the first octet. This means to me that in order to encode source port 180 I should start my TCP header with these two bytes:
B4 00 ...
However, all examples I can find tell me to do it the other way around:
00 B4 ...
Why?
This means that Source Port should take first two octets
Correct.
and the lowest bit should be in the first octet.
Incorrect. It doesn't mean that. It doesn't say anything about it.
All multi-byte integers in all IP headers are represented in network byte order, which is big-endian. This is specified in RFC 1700.
What is the correct name of this error correction method?
It is quite similar to Hamming Code, but much more simple. I also cannot find it in the literature any more. The only internet sources, I'm now able to find, which describes the method, are this:
http://www.mathcs.emory.edu/~cheung/Courses/455/Syllabus/2-physical/errors-Hamming.html
And the german-language Wikipedia.
http://de.wikipedia.org/w/index.php?title=Fehlerkorrekturverfahren
In the Wikipedia article, the method is called Hamming-ECC method. But I'm not 100% sure, this is correct.
Here is an example, which describes the way the method works.
Payload: 10011010
Step 1: Determine parity bit positions. Bits, which are powers of 2 (1, 2, 4, 8, 16, etc.) are parity bits:
Position: 1 2 3 4 5 6 7 8 9 10 11 12
Data to be transmitted: ? ? 1 ? 0 0 1 ? 1 0 1 0
Step 2: Calculate parity bit values. Each bit position in the transmission is assigned to a position number. In this example, the position number is a 4-digit number, because we have 4 parity bits. Calculate XOR of the values of those positions (in 4-digit format), where the payload is a 1 bit in the transmission:
0011 Position 3
0111 Position 7
1001 Position 9
XOR 1011 Position 11
--------------------
0110 = parity bit values
Step 3: Insert parity bit values into the transmission:
Position: 1 2 3 4 5 6 7 8 9 10 11 12
Data to be transmitted: 0 1 1 1 0 0 1 0 1 0 1 0
Is is quite simple to verify, if a received message was transmitted correctly and single-bit errors can be corrected. Here is an example. The receiver calulates XOR of the calculated and received payload bits where the value is a 1 bit. Is the result is 0, there the transmission is error-free. Otherwise the result contains the position of the bit with the wrong value.
Received message: 0001101100101101
Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Received data: 0 0 0 1 1 0 1 1 0 0 1 0 1 1 0 1
Parity bits: X X X X X
00101 Position 5
00111 Position 7
01011 Position 11
01101 Position 13
XOR 01110 Position 14
--------------------
01010 Parity bits calculated
XOR 00111 Parity bits received
--------------------
01101 => Bit 13 ist defective!
I hope, anybody here knows the correct name of the method.
Thanks for any help.
This looks like a complicated implementation of the Hamming(15,11) encoding & decoding algorithm.
Interleaving the parity bits with the information bits does not change the behaviour (or performance) of the code. Your description only uses 8 information bits, where the Hamming(15,11) corrects all single bit errors even with 11 information bits being transmitted.
Your description does not explain how the transmitted 12-bit message gets extended to a 16-bit message on the receive side.