Skip to content

Instantly share code, notes, and snippets.

@atoonk
atoonk / afpacket.c
Created March 25, 2024 00:36
sending a packet with AF_PACKET in C
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <netinet/ip.h> // Include for struct iphdr
@atoonk
atoonk / main.go
Created March 11, 2024 20:15
net.dial http get
package main
import (
"bufio"
"fmt"
"io"
"net"
)
func main() {
@atoonk
atoonk / gist:46f60156bfad71d4ac43b7460367121d
Created February 27, 2024 22:43
af_packet_compare.go
// POC for sending packets using tpacket and afpacket
// tpacket is a high-performance packet sending mechanism using MMap'd AF_PACKET
// afpacket is a regular packet sending mechanism
package main
import (
"fmt"
"log"
"net"
@atoonk
atoonk / ipv4_prefixes_aws_2024.md
Last active February 8, 2024 10:50
IPv4 addresses allocated to Amazon and their worth
arin_entities = ["GOOGL-2", "GOOGL-1", "YL-29", "GOGL"]
urls = ["https://www.gstatic.com/ipranges/cloud.json", "https://www.gstatic.com/ipranges/goog.json"]
4.3.2.0/24
8.8.4.0/24
8.8.8.0/24
8.34.208.0/20
8.35.192.0/20
23.236.48.0/20
23.251.128.0/19
@atoonk
atoonk / ipv4_prefixes_aws_2023.md
Last active February 20, 2024 10:24
ipv4_prefixes_aws_2023

Summary

2023 AWS data Total number of IPv4 addresses: 127,972,688 That’s the equivalent of 7.6 /8’s Also see this blog: https://toonk.io/aws-ipv4-estate-now-worth-4-5-billion/index.html

just for fun, let's put a value number on that

value at $20 per ip: $2,559,453,760
value at $25 per ip: $3,199,317,200
value at $30 per ip: $3,839,180,640
@atoonk
atoonk / dpdk_ifstats.py
Created April 7, 2021 22:43
VPP DPDK interface stats
#!/usr/bin/env python3
import subprocess
import time
import signal
import sys, os
def get_stats(interface):
command=["vppctl", "show", "hardware-interfaces", interface]
#!/bin/bash
if [ `whoami` != 'root' ]; then
echo "Please run this as root..., don't worry about it..."
exit 1
fi
echo "updating fstab"
r=`grep hugetlbfs /etc/fstab`
@atoonk
atoonk / connect_mysocket.py
Created December 5, 2020 01:35
connect_mysocket.py
#!/usr/bin/env python3
import os
import time
import jwt as jwt
from mysocketctl.tunnel import new_tunnel, delete_tunnel
from mysocketctl.login import get_token
from mysocketctl.utils import ssh_tunnel
username = os.getenv("email")
@atoonk
atoonk / mysocket-client.py
Last active December 5, 2020 01:00
mysocket example code
from mysocketctl.socket import get_sockets, new_socket
from mysocketctl.tunnel import new_tunnel
from mysocketctl.login import get_token
from mysocketctl.ssh import SystemSSH, Paramiko
import jwt
username="xxx@gmail.com"
password="xxx"
token = get_token(username,password)