Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbette committed Nov 22, 2021
2 parents 74c562e + 4892ac4 commit 5ec7bad
Show file tree
Hide file tree
Showing 20 changed files with 1,429 additions and 136 deletions.
101 changes: 50 additions & 51 deletions elements/ip6/ip6drop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,69 +85,69 @@ void
#endif
IP6Drop::drop_model(Packet *p_in, std::function<void(Packet*)>push)
{
// Do not drop the repair symbols
// TODO: adapt if we change and do not use ping anymore
int idxs[] = {2, 3, 7};
if (p_in->length() < 200) {
#if HAVE_BATCH
return p_in;
#else
push(p_in);
#endif
}
total_seen++;
for (int i = 0; i < 1; ++i) {
if (total_seen % 1000 == idxs[i]) {
//click_chatter("Drop packet");
#if HAVE_BATCH
return 0;
#else
return;
#endif
}
}
#if HAVE_BATCH
return p_in;
#else
push(p_in);
#endif


// const click_ip6 *ip6 = reinterpret_cast<const click_ip6 *>(p_in->data());
// uint32_t *dst_32 = (uint32_t *)&ip6->ip6_dst;
// bool found = false;
// for (int i = 0; i < addrs.size(); ++i) {
// IP6Address addr = addrs.at(i);
// uint32_t *addr_32 = (uint32_t *)addr.data32();
// if (addr_eq(addr_32, dst_32)) {
// found = true;
// break;
// }
// }
// if (!found) {
// // Do not drop the repair symbols
// // TODO: adapt if we change and do not use ping anymore
// int idxs[] = {2, 3, 7};
// if (p_in->length() < 200) {
// #if HAVE_BATCH
// return p_in;
// #else
// push(p_in);
// #endif
// }

// total_seen++;
// // Do not drop the first packets to ensure a connection between the client and the broker
// if (total_seen < 20) {
// return p_in;
// }

// if (!gemodel()) {
// click_chatter("Drop packet #%u", total_seen);
// for (int i = 0; i < 3; ++i) {
// if (total_seen % 20 == idxs[i]) {
// // click_chatter("Drop packet");
// #if HAVE_BATCH
// return 0;
// return 0;
// #else
// return;
// #endif
// }
// }
// #if HAVE_BATCH
// return p_in;
// #else
// }
// push(p_in);
// #endif


const click_ip6 *ip6 = reinterpret_cast<const click_ip6 *>(p_in->data());
uint32_t *dst_32 = (uint32_t *)&ip6->ip6_dst;
bool found = false;
for (int i = 0; i < addrs.size(); ++i) {
IP6Address addr = addrs.at(i);
uint32_t *addr_32 = (uint32_t *)addr.data32();
if (addr_eq(addr_32, dst_32)) {
found = true;
break;
}
}
if (!found) {
#if HAVE_BATCH
return p_in;
#else
push(p_in);
#endif
}

total_seen++;
// Do not drop the first packets to ensure a connection between the client and the broker
if (total_seen < 20) {
return p_in;
}

if (!gemodel()) {
click_chatter("Drop packet #%u", total_seen);
#if HAVE_BATCH
return 0;
}
return p_in;
#else
}
push(p_in);
#endif
}

bool
Expand Down Expand Up @@ -198,4 +198,3 @@ IP6Drop::add_handlers()
CLICK_ENDDECLS
EXPORT_ELEMENT(IP6Drop)
ELEMENT_MT_SAFE(IP6Drop)

6 changes: 2 additions & 4 deletions elements/ip6/ip6srdecap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ IP6SRDecap::simple_action(Packet *p_in)

if (_force || sr->segment_left == 1) {


IP6Address last = IP6Address(sr->segments[0]);

unsigned char* old_data = p->data();
Expand All @@ -82,8 +81,8 @@ IP6SRDecap::simple_action(Packet *p_in)

ip6->ip6_dst = last;
ip6->ip6_nxt = nxt;
ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) - srlen);
p->set_network_header(p->data(), offset - srlen);
ip6->ip6_plen = htons(ntohs(ip6->ip6_plen));
p->set_network_header(p->data(), offset);


} else if (unlikely(sr->segment_left == 0)) {
Expand All @@ -93,7 +92,6 @@ IP6SRDecap::simple_action(Packet *p_in)
ip6->ip6_dst = sr->segments[--sr->segment_left];
}


return p;
}

Expand Down
13 changes: 7 additions & 6 deletions elements/ip6/ip6srv6fec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ IP6SRv6FECEncode::fec_framework(Packet *p_in, std::function<void(Packet*)>push)
return;
}

if (err == 1) { // Repair
//t_scheme_s = Timestamp::now();
if (err == 1 && _send_repair) { // Repair
if (!_repair_packet) {
// click_chatter("No repair packet TODO");
return;
}

Expand All @@ -177,15 +175,14 @@ IP6SRv6FECEncode::fec_framework(Packet *p_in, std::function<void(Packet*)>push)
encapsulate_repair_payload(_repair_packet, &_repair_tlv, _rlc_info.max_length);

// Send repair packet
push(_repair_packet);
_repair_packet = 0;
push(_repair_packet);
_repair_packet = 0;

// Reset parameters of the RLC information
_rlc_info.max_length = 0;
memset(&_repair_tlv, 0, sizeof(repair_tlv_t));
_rlc_info.prng = rlc_reset_coefs();
}

}

int
Expand All @@ -210,6 +207,8 @@ IP6SRv6FECEncode::fec_scheme(Packet *p_in, std::function<void(Packet*)>push)
// Update RLC information
++_rlc_info.buffer_size;
++_rlc_info.encoding_symbol_id;

push(p);

// Same as the srv6_fec_add_source_tlv
push(p);
Expand Down Expand Up @@ -257,10 +256,12 @@ IP6SRv6FECEncode::fec_scheme(Packet *p_in, std::function<void(Packet*)>push)
_rlc_info.previous_window_step = _rlc_info.window_step;
// Update coding rate
// TODO


return 1;
}


return 0;
}

Expand Down
1 change: 1 addition & 0 deletions elements/ip6/ip6srv6fec.hh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class IP6SRv6FECEncode : public BatchElement {
click_ip6_sr _repair_srv6;
bool _use_dst_anno;
bool _send_repair;
bool _do_fec;
IP6Address enc; // Encoder SID
IP6Address dec; // Decoder SID
IP6Address fed; // Feedback SID
Expand Down
Loading

0 comments on commit 5ec7bad

Please sign in to comment.