Skip to content

Commit

Permalink
Merge pull request #7 from SamClercky/rpl-mop3
Browse files Browse the repository at this point in the history
Implement `StoringModeWithMulticast` aka RPL MOP3
  • Loading branch information
thvdveld authored Aug 28, 2024
2 parents 8438f9e + db1bd6c commit 98ab091
Show file tree
Hide file tree
Showing 41 changed files with 2,660 additions and 562 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
*.pcap
sim_logs/
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static CONFIGS: &[(&str, usize)] = &[
("IFACE_MAX_SIXLOWPAN_ADDRESS_CONTEXT_COUNT", 4),
("IFACE_NEIGHBOR_CACHE_COUNT", 4),
("IFACE_MAX_ROUTE_COUNT", 2),
("IFACE_MAX_MULTICAST_DUPLICATION_COUNT", 16),
("FRAGMENTATION_BUFFER_SIZE", 1500),
("ASSEMBLER_MAX_SEGMENT_COUNT", 4),
("REASSEMBLY_BUFFER_SIZE", 1500),
Expand All @@ -22,6 +23,7 @@ static CONFIGS: &[(&str, usize)] = &[
("RPL_RELATIONS_BUFFER_COUNT", 16),
("RPL_PARENTS_BUFFER_COUNT", 8),
("RPL_MAX_OPTIONS", 2),
("RPL_MAX_NEXT_HOP_PER_DESTINATION", 4),
// END AUTOGENERATED CONFIG FEATURES
];

Expand Down
9 changes: 8 additions & 1 deletion examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::thread;
use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::{wait as phy_wait, Device, Medium};
use smoltcp::socket::tcp;
use smoltcp::storage::PacketMetadata;
use smoltcp::time::{Duration, Instant};
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};

Expand Down Expand Up @@ -97,7 +98,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod utils;

use log::debug;
use smoltcp::storage::PacketMetadata;
use std::os::unix::io::AsRawFd;
use std::str::{self, FromStr};

Expand Down Expand Up @@ -38,7 +39,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/dhcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
mod utils;

use log::*;
use smoltcp::storage::PacketMetadata;
use std::os::unix::io::AsRawFd;

use smoltcp::iface::{Config, Interface, SocketSet};
Expand Down Expand Up @@ -36,7 +37,13 @@ fn main() {
Medium::Ieee802154 => todo!(),
};
config.random_seed = rand::random();
let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);

// Create sockets
let mut dhcp_socket = dhcpv4::Socket::new();
Expand Down
9 changes: 8 additions & 1 deletion examples/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::Device;
use smoltcp::phy::{wait as phy_wait, Medium};
use smoltcp::socket::dns::{self, GetQueryResultError};
use smoltcp::storage::PacketMetadata;
use smoltcp::time::Instant;
use smoltcp::wire::{DnsQueryType, EthernetAddress, IpAddress, IpCidr, Ipv4Address, Ipv6Address};
use std::os::unix::io::AsRawFd;
Expand Down Expand Up @@ -33,7 +34,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/httpclient.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod utils;

use log::debug;
use smoltcp::storage::PacketMetadata;
use std::os::unix::io::AsRawFd;
use std::str::{self, FromStr};
use url::Url;
Expand Down Expand Up @@ -38,7 +39,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
13 changes: 12 additions & 1 deletion examples/loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use log::{debug, error, info};
use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::{Device, Loopback, Medium};
use smoltcp::socket::tcp;
use smoltcp::storage::PacketMetadata;
use smoltcp::time::{Duration, Instant};
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};

Expand Down Expand Up @@ -91,7 +92,17 @@ fn main() {
Medium::Ieee802154 => todo!(),
};

let mut iface = Interface::new(config, &mut device, Instant::now());
// Setup multicast queues
let mut metadata = [PacketMetadata::EMPTY; 16];
let mut multicast_packets = [0; 2048];

let mut iface = Interface::new(
config,
&mut device,
&mut metadata[..],
&mut multicast_packets[..],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8))
Expand Down
9 changes: 8 additions & 1 deletion examples/multicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::os::unix::io::AsRawFd;
use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::{wait as phy_wait, Device, Medium};
use smoltcp::socket::{raw, udp};
use smoltcp::storage::PacketMetadata;
use smoltcp::time::Instant;
use smoltcp::wire::{
EthernetAddress, IgmpPacket, IgmpRepr, IpAddress, IpCidr, IpProtocol, IpVersion, Ipv4Address,
Expand Down Expand Up @@ -37,7 +38,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod utils;

use byteorder::{ByteOrder, NetworkEndian};
use smoltcp::iface::{Interface, SocketSet};
use smoltcp::storage::PacketMetadata;
use std::cmp;
use std::collections::HashMap;
use std::os::unix::io::AsRawFd;
Expand Down Expand Up @@ -114,7 +115,13 @@ fn main() {
};
config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod utils;

use log::debug;
use smoltcp::storage::PacketMetadata;
use std::fmt::Write;
use std::os::unix::io::AsRawFd;

Expand Down Expand Up @@ -34,7 +35,13 @@ fn main() {

config.random_seed = rand::random();

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(IpAddress::v4(192, 168, 69, 1), 24))
Expand Down
9 changes: 8 additions & 1 deletion examples/sixlowpan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
mod utils;

use log::debug;
use smoltcp::storage::PacketMetadata;
use std::os::unix::io::AsRawFd;
use std::str;

Expand Down Expand Up @@ -83,7 +84,13 @@ fn main() {
config.rpl_config = None;
}

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(
Expand Down
9 changes: 8 additions & 1 deletion examples/sixlowpan_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use std::str;
use smoltcp::iface::{Config, Interface, SocketSet};
use smoltcp::phy::{wait as phy_wait, Device, Medium, RawSocket};
use smoltcp::socket::tcp;
use smoltcp::storage::PacketMetadata;
use smoltcp::wire::{EthernetAddress, Ieee802154Address, Ieee802154Pan, IpAddress, IpCidr};

//For benchmark
Expand Down Expand Up @@ -159,7 +160,13 @@ fn main() {
config.random_seed = rand::random();
config.pan_id = Some(Ieee802154Pan(0xbeef));

let mut iface = Interface::new(config, &mut device, Instant::now());
let mut iface = Interface::new(
config,
&mut device,
vec![PacketMetadata::EMPTY; 16],
vec![0; 2048],
Instant::now(),
);
iface.update_ip_addrs(|ip_addrs| {
ip_addrs
.push(IpCidr::new(
Expand Down
11 changes: 9 additions & 2 deletions src/iface/interface/ethernet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ impl InterfaceInner {
meta: crate::phy::PacketMeta,
frame: &'frame [u8],
fragments: &'frame mut FragmentsBuffer,
multicast_queue: &mut PacketBuffer<'_, MulticastMetadata>,
) -> Option<EthernetPacket<'frame>> {
let eth_frame = check!(EthernetFrame::new_checked(frame));

Expand All @@ -31,8 +32,14 @@ impl InterfaceInner {
#[cfg(feature = "proto-ipv6")]
EthernetProtocol::Ipv6 => {
let ipv6_packet = check!(Ipv6Packet::new_checked(eth_frame.payload()));
self.process_ipv6(sockets, meta, &ipv6_packet)
.map(EthernetPacket::Ip)
self.process_ipv6(
sockets,
meta,
&ipv6_packet,
Some(&eth_frame.src_addr().into()),
multicast_queue,
)
.map(EthernetPacket::Ip)
}
// Drop all other traffic.
_ => None,
Expand Down
12 changes: 9 additions & 3 deletions src/iface/interface/ieee802154.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl InterfaceInner {
meta: PacketMeta,
sixlowpan_payload: &'payload [u8],
_fragments: &'output mut FragmentsBuffer,
multicast_queue: &mut PacketBuffer<'_, MulticastMetadata>,
) -> Option<Packet<'output>> {
let ieee802154_frame = check!(Ieee802154Frame::new_checked(sixlowpan_payload));

Expand All @@ -41,9 +42,14 @@ impl InterfaceInner {
self.current_frame = Some(ieee802154_repr);

match ieee802154_frame.payload() {
Some(payload) => {
self.process_sixlowpan(sockets, meta, &ieee802154_repr, payload, _fragments)
}
Some(payload) => self.process_sixlowpan(
sockets,
meta,
&ieee802154_repr,
payload,
_fragments,
multicast_queue,
),
None => None,
}
}
Expand Down
Loading

0 comments on commit 98ab091

Please sign in to comment.