Skip to content

Commit

Permalink
ping
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent committed Dec 11, 2024
1 parent 43c6221 commit b379c18
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/QUIC/icmp-bi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DeviceID" : "udp:10.0.0.20:8888",
"SoR" : [
{
"RuleID": 6,
"RuleIDLength": 3,
"Compression": [
{"FID": "IPV6.VER", "TV": 6, "MO": "equal", "CDA": "not-sent"},
{"FID": "IPV6.TC", "TV": 0, "MO": "equal", "CDA": "not-sent"},
{"FID": "IPV6.FL", "TV": 0, "MO": "ignore","CDA": "not-sent"},
{"FID": "IPV6.LEN", "MO": "ignore","CDA": "compute-length"},
{"FID": "IPV6.NXT", "TV": 58, "MO": "equal", "CDA": "not-sent"},
{"FID": "IPV6.HOP_LMT", "TV" : 255,"MO": "ignore","CDA": "not-sent"},
{"FID": "IPV6.DEV_PREFIX","TV": "AAAA::/64",
"MO": "equal","CDA": "not-sent"},
{"FID": "IPV6.DEV_IID", "TV": "::1","MO": "equal","CDA": "not-sent"},
{"FID": "IPV6.APP_PREFIX", "MO": "ignore","CDA": "value-sent"},
{"FID": "IPV6.APP_IID", "MO": "ignore","CDA": "value-sent"},
{"FID": "ICMPV6.TYPE", "TV": 128, "DI" : "DW", "MO": "equal","CDA": "not-sent"},
{"FID": "ICMPV6.TYPE", "TV": 129, "DI" : "UP", "MO": "equal","CDA": "not-sent"},
{"FID": "ICMPV6.CODE", "TV": 0, "MO": "equal","CDA": "not-sent"},
{"FID": "ICMPV6.CKSUM", "TV": 0, "MO": "ignore","CDA": "compute-checksum"},
{"FID": "ICMPV6.IDENT", "TV": 0, "MO": "ignore","CDA": "value-sent"},
{"FID": "ICMPV6.SEQNO", "TV": 0, "MO": "ignore", "CDA": "value-sent"},
{"FID": "ICMPV6.PAYLOAD", "TV": 0,"MO": "ignore","CDA": "value-sent"}
]
}
]
}

51 changes: 51 additions & 0 deletions examples/QUIC/ping_core1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '../../src/')

from scapy.all import *

import gen_rulemanager as RM
from protocol import SCHCProtocol
from gen_parameters import T_POSITION_CORE

# Create a Rule Manager and upload the rules.

rm = RM.RuleManager()
rm.Add(file="icmp-bi.json")
rm.Print()

def processPkt(pkt):

scheduler.run(session=schc_machine)

if pkt.getlayer(Ether) != None:
e_type = pkt.getlayer(Ether).type
if e_type == 0x86dd:
schc_machine.schc_send(bytes(pkt)[14:])
elif e_type == 0x0800:
if pkt[IP].proto == 17 and pkt[UDP].dport == 0x5C4C:
# got a packet in the socket
SCHC_pkt, device = tunnel.recvfrom(1000)

other_end = 'udp:'+device[0]+':'+str(device[1])

origin, full_packet = schc_machine.schc_recv(
schc_packet=SCHC_pkt,
device_id=other_end,
iface='eth1',
verbose=True)

# Start SCHC Machine
POSITION = T_POSITION_CORE

schc_machine = SCHCProtocol(role=POSITION)
schc_machine.set_rulemanager(rm)
scheduler = schc_machine.system.get_scheduler()
tunnel = schc_machine.get_tunnel()

sniff(prn=processPkt, iface=["eth0", "eth1", "lo"])





51 changes: 51 additions & 0 deletions examples/QUIC/ping_dev3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '../../src/')

from scapy.all import *

import gen_rulemanager as RM
from protocol import SCHCProtocol
from gen_parameters import T_POSITION_CORE

# Create a Rule Manager and upload the rules.

rm = RM.RuleManager()
rm.Add(file="icmp-bi.json")
rm.Print()

def processPkt(pkt):

scheduler.run(session=schc_machine)

if pkt.getlayer(Ether) != None:
e_type = pkt.getlayer(Ether).type
if e_type == 0x86dd:
schc_machine.schc_send(bytes(pkt)[14:])
elif e_type == 0x0800:
if pkt[IP].proto == 17 and pkt[UDP].port == 0x5C4C:
# got a packet in the socket
SCHC_pkt, device = tunnel.recvfrom(1000)

other_end = 'udp:'+device[0]+':'+str(device[1])

origin, full_packet = schc_machine.schc_recv(
schc_packet=SCHC_pkt,
device_id=other_end,
iface='eth1',
verbose=True)

# Start SCHC Machine
POSITION = T_POSITION_CORE

schc_machine = SCHCProtocol(role=POSITION)
schc_machine.set_rulemanager(rm)
scheduler = schc_machine.system.get_scheduler()
tunnel = schc_machine.get_tunnel()

sniff(prn=processPkt, iface=["eth0", "eth1", "lo"])





0 comments on commit b379c18

Please sign in to comment.