Repository navigation
Open
Description
With NATS (#56, #76), we can have multiple extractors pushing events into the message queue. Here are some ideas for future extractors that could be good to implement:
- RPC extractor: in a certain interval, fetch RPC data and publish it into the NATS message queue. For example,
getpeerinfocan provide useful information about our peers that we currently don't have via the tracepoints. Add basic RPC extractor with getpeerinfo support #191 - P2P-extractor: Connects to the localhost node via the P2P interface and e.g. frequently pings it and records the ping-pong duration to measure backlog (add: p2p-extractor (initially keeps track of ping-pong durations) #256)
- Log extractor: parse the log and publish interesting log messages (maybe already parsed and pre-processed) into the NATS message queue. We don't have tracepoints for everything. While the log interface might not be as stable, why not use it if we can. Additionally, the debug log is a machine-to-human interface. Ideally, we'd use machine-to-machine interfaces. (Implement log extractor #272)
- IPC-extractor: Since Bitcoin Core v30.0, the first IPC interface was introduced. A
TracingEventsIPC-interface could be introduced which, if low-overhead, would solve some of the tracing interface pain points. See Tracepoint-like interface via libmultiprocess and IPC communication bitcoin-core/libmultiprocess#185 and POC: IPC tracing interface bitcoin/bitcoin#32898. Also, see Implement an experimental ipc-extractor against the Bitcoin Core chain IPC interface (proposed in #29409) #370 for an ipc-extractor that we could build to test a Bitcoin Core PR. Add IPC extractor #379 - call-stack extractor: call-stack extractor: In which function is
bitcoindspending it's time? #391 - TCP extractor: not a high priority, see Implement more extractors #141 (comment)
- ZMQ extractor: not as important
Metadata
Metadata
Assignees
Labels
No labels
Activity
0xB10C commentedon Apr 10, 2025
For the RPC extractor, it probably makes sense to use https://crates.io/crates/jsonrpc-core - however it does not provide a proper transport. Maybe the "for non-production use only" transport is enough for us.
edilmedeiros commentedon Jun 18, 2025
Looks like it was superseded by https://github.com/paritytech/jsonrpsee.
Also,
rust-bitcoinincludes an active project to provide types for the RPC interface here https://crates.io/crates/corepc-types (pretty new library, not sure if it covers the whole RPC right now, but is probably a good starting point).0xB10C commentedon Jun 23, 2025
Thanks @edilmedeiros! I meant to link https://crates.io/crates/corepc-types and not https://crates.io/crates/jsonrpc-core.
All new software should probably use https://crates.io/crates/corepc-types going forward and implement the missing calls there.
mv: extractor to extractors/ebpf-extractors
mv: extractor to extractors/ebpf-extractors
0xB10C commentedon Jul 8, 2025
In preparation for multiple extractors, I've moved the ebpf extractor into the extractors sub directory in #181
rename: extractor -> ebpf-extractor
0xB10C commentedon Jul 10, 2025
An IPC/multiprocess extractor is becoming more and more interesting IMO. See bitcoin-core/libmultiprocess#185 and bitcoin/bitcoin#32898. However, still very early.
The RPC extractor is probably the thing to work on next.
rename: extractor -> ebpf-extractor
0xB10C commentedon Jul 30, 2025
Implementing an RPC extractor in #191
0xB10C commentedon Aug 15, 2025
Added a P2P exporter to OP:
0xB10C commentedon Sep 16, 2025
Started working on a (wip) P2P-extractor in #256
m4ycon commentedon Sep 23, 2025
Just to inform, I'll start working on a log extractor, me and @edilmedeiros talked about it being a "unix pipe" consumed by this extractor, if this doesn't work well I'll go to a more straight solution that is pooling the btc core log file. I think that initially we can publish all logs to nats and tools could filter these logs for specific messages. If you have any suggestions, please let me know.
0xB10C commentedon Sep 23, 2025
Cool! A few thoughts:
shared/so different tools can consume it. An alternative would be to parse the logs in the log-extractor and send specific messages for each supported log event.I'm somewhat leaning towards only having to parse the log messages in one place. Otherwise multiple tools try to parse the same message at the same time. So ideally a
log-extractorwould do this for all messages it knows and can parse. These would then be put into a protobuf event and send via NATS to the tools. For all unknown and not yet implemented log messages, it could forward the full log message in aUnknownLogMessageprotobuf (or similar).mv: extractor to extractors/ebpf-extractors
2 remaining items
RazorBest commentedon Mar 24, 2026
Hi! Would you be open for a TCP layer extractor in peer-observer?
I've recently been working with TCP level inspection, and I see two ways of doing it:
libpcaplibnetfilter_queue(Linux only). Harder to do it correctly because the extractor would need to make a decision for every received packet.0xB10C commentedon Mar 24, 2026
Interesting idea! What events, metrics, or data (that we don't yet have) would we get from a tcp-extractor?
RazorBest commentedon Mar 24, 2026
I'm not seeing a lot of value from it, but I'll still list what you could do with it.
You would get similar data that you get from
net:inbound_messageandnet:outbound_messageebpf traces. However, when those traces are triggered, the received data is already parsed/decrypted and split into messages. From a tcp-extractor you'd get the unparsed and encrypted data. You can use it for nodes other than bitcoin-core.You can also observe behaviors that are outside of the P2P protocol. But I'm not too sure how valuable this would be. One such behavior that I observed are the ping health checks from https://www.dsn.kastel.kit.edu/bitcoin/, which are not malicious.
The kind of data you would get from this extractor could look like this:
Concretely:
0xB10C commentedon Mar 25, 2026
Thanks for sharing, I think these events are not uninteresting, but as you said, we get similar ones via the ebpf message/connection tracepoints. I don't think a tcp extractor should attempt to parse/decrypt the packets. Reporting on the connections being opened/closed and packages send/received would probably be the main focus.
Do we need special permissions (e.g. root) for running this? Can
libpcapgive us stuff in real time?I like that this works for non Bitcoin Core nodes and possibly on non-linux systems(?).
Added it to the OP, but I don't think it's very high priority at the moment (unless we find something unique we don't yet have insights into). It might still be a fun exercise for you.
edit: can we track e.g. TCP ping times with this to connections? Also SYN/ACK times?
RazorBest commentedon Mar 25, 2026
libpcap is BPF (probably eBPF) based, so you'll need root privileges, or the
CAP_BPFcapability. I don't know if eBPF has more granular permissions. However there issswhich is based on thesock_diagsubsystem, and doesn't need privileges. For example, withss -tiyou can list the active connections and the amount of bytes transferred. From, my understanding,sock_diagdoesn't have notifications (referencing this presentation: https://events.static.linuxfound.org/sites/events/files/slides/Exploration%20of%20Linux%20Container%20Network%20Monitoring%20and%20Visualization.pdf), so you need to do some polling.If you don't have root permissions, you might also use strace, but that comes with its own problems.
For windows, there's https://npcap.com/, which from my understanding, it's driver + a library that interfaces with libpcap.
With tcpdump/libpcap, definetly. But I only found out now that it's based on eBPF. So, there might be more simple tools to track that. A quick way to verify that is to look through bcc-tools - the ones prefixed by tcp*. For example,
tcplifelistens to tcp sessions, and logs them when they end.For non-root, I saw that
ssalso outputslastack, which is the last value of the ACK field. To get the times, you can query it continuously. So, we still have to confirm if it has notifications. If it doesn't, I don't see how it can be used. This is just a snapshot:Another thing I didn't go into are retransmissions or other TCP-internal stuff. I don't even know if that is traced by the kernel.
RazorBest commentedon Mar 25, 2026
Apart from that, there's also the
conntracktool (root needed), which is an interface over thenf_conntracksubsystem, which holds the state table for the TCP connections. This is also behind the NAT functionality used by iptables. You can easily see it withcat /proc/net/nf_conntrack.This doesn't show each packet. Only state table updates. But this one allows notifications.
Reference: https://www.netfilter.org/projects/libnetfilter_conntrack/index.html
0xB10C commentedon Mar 25, 2026
We have some extractors that are polling based (e.g. RPC extractor and the IPC extractor). So I don't think it's a hard requirement.
I think we can use
procfs::net::tcpto get some information about TCP sockets from/proc/net/tcp.Note that there is also #258, which goes into a similar direction.
0xB10C commentedon Mar 26, 2026
Unrelated to the TCP extractor, I had an idea for a call-stack extractor. I've written down a few raw thoughts on it here: #391 - we are not reinventing the wheel with it, but I think it's a considerable enginnering effort to get it working well.
ViniciusCestarii commentedon Jul 3, 2026
Initial TTL, window size/scaling, MSS, TCP options ordering.
These could be used for stack/OS fingerprinting on ipv4/ipv6. connections. One nice output is an aggregate OS distribution of peers (% Linux/macOS/Windows/BSD).
Caveats: it only covers ipv4/ipv6 peers and it's biased by NAT/VPS/middlebox stacks so it partly reflects hosting rather than operator OS. Also, even with a fingerprint in hand, the OS match is probabilistic, so it should be treated as a best-guess label rather than ground truth.
Do you think this would be an interesting metric for peer-observer?
0xB10C commentedon Jul 3, 2026
If we can do this with a high accuracy, then I think something like this, especially as a library so it can be re-used, is very interesting.
I had been looking into something related for a different project (https://github.com/0xB10C/p2p-observer/blob/master/observer/src/tcp.rs) and my impression was fingerprinting OS is quite hard. Happy to be convinced otherwise.
Next to OS fingerprinting, some of the other metrics are certainly interesting, even if we don't know how to best use them.
ViniciusCestarii commentedon Jul 4, 2026
Yes, it's not a simple task. Based on the article Passive operating system fingerprinting revisited: Evaluation and current challenges, building a good OS passive fingerprinting tool for the Bitcoin network would require a labeled dataset that maps OS labels to the TCP Options, TCP Window Size, IP TTL, and IP Flags collected from the actual network, and then using this data to train a decision tree. The article fingerprints the client's SYN, but the same fields are present in a responder's SYN-ACK, and passive fingerprinting from SYN-ACKs works too. oopir/os_fingerprinting did it on ~1M web servers.
One way to build that dataset: for every reachable node, connect and send a minimal P2P version message while tracing the TCP messages, capturing the TCP/IP fields from the SYN-ACK packet, and obtain the OS label via nmap -O (an active fingerprinter, so generally more accurate than passive fingerprinting).
The quality ceiling for this approach is set by the accuracy of nmap's guesses, since they're the labels the model learns from.
The cool thing is that the dataset is already useful on its own, since it would contain a mapping of every reachable node in the network to its OS guess at the time of collection.
ViniciusCestarii commentedon Jul 7, 2026
I have done it: https://github.com/ViniciusCestarii/bitcoin-node-os-fingerprint. In aggregate, the results seem reliable.
0xB10C commentedon Jul 7, 2026
pretty cool! maybe worth a short bnoc.xyz post? doing this monthly is probably interesting to report on changes. For quality control, you could check if any IPs switch between OS from time to time. Additionally, it might be interesting to find out the hoster/AS (maybe see #470 for inspiration) of the Windows machines. I wouldn't be surprised if it's Azure.
0xB10C commentedon Jul 7, 2026
Actually, see this which I extracted from your scan with
awk -F, '$3=="Windows" {print $1}' scan-2026-07-06.csv. Mostly ISPs and not hosters. Didn't see any Azure.ViniciusCestarii commentedon Jul 7, 2026
I'd love to! I will cook a post.
For sure, I will add a cronjob in a VPS that I have for running it each month and push the result to the repo.
Just documented on the README: Measured across the two published scans (scan-2026-07-06.csv and scan-2026-07-07.csv): of the 10,302 targets reachable on both days, 256 (~2.5%) had their os_class flip between runs, mostly Linux ↔ Unknown and Linux ↔ Other/Device. (I looked into it and it seems that it is most nmap confusing Android and Linux, which makes sense since Android is based on Linux)
~2.5% flip seems reasonable because the real values is the aggregate.