WIP thunder
This commit is contained in:
parent
e95a4caabe
commit
0b43f944a8
3 changed files with 50 additions and 12 deletions
|
@ -8,6 +8,11 @@
|
|||
struct thunder_ctx {
|
||||
uint16_t recv_id;
|
||||
uint16_t emit_id;
|
||||
uint64_t lid_sent;
|
||||
uint8_t selected_link;
|
||||
uint8_t total_links;
|
||||
uint64_t lid_sent_per_link[64];
|
||||
uint8_t delta_t_per_link[64];
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,8 +26,10 @@ void prepare(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct bu
|
|||
.fmt.headers.size = sizeof(metadata.fmt.headers) + sizeof(metadata.fmt.content.udp_metadata_thunder),
|
||||
.fmt.headers.flags = 0,
|
||||
.fmt.content.udp_metadata_thunder.id = thunderc->emit_id,
|
||||
.fmt.content.udp_metadata_thunder.deltat = 0
|
||||
.fmt.content.udp_metadata_thunder.deltat = 0 //@FIXME
|
||||
};
|
||||
buffer_append_ap (bp, &metadata);
|
||||
|
||||
}
|
||||
|
||||
void pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||
|
@ -30,7 +37,40 @@ void pad(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer
|
|||
}
|
||||
|
||||
int schedule(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||
struct evt_core_fdinfo *to_fdinfo = NULL;
|
||||
struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "tcp-write");
|
||||
|
||||
do {
|
||||
thunderc->selected_link = thunderc->selected_link + 1 % cat->socklist->len;
|
||||
|
||||
if (thunderc->selected_link == 0) {
|
||||
thunderc->lid_sent++;
|
||||
|
||||
}
|
||||
|
||||
union abstract_packet links = {
|
||||
.fmt.headers.cmd = CMD_LINK_MONITORING_THUNDER,
|
||||
.fmt.headers.size = sizeof(links.fmt.headers) + sizeof(links.fmt.content.link_monitoring_thunder),
|
||||
.fmt.headers.flags = 0,
|
||||
.fmt.content.link_monitoring_thunder.lid = thunderc->lid_sent,
|
||||
.fmt.content.link_monitoring_thunder.links_status = NULL
|
||||
};
|
||||
|
||||
to_fdinfo = g_array_index(cat->socklist, struct evt_core_fdinfo*, thunderc->selected_link);
|
||||
|
||||
// We move the buffer and notify the target
|
||||
struct buffer_packet* bp_dup = dup_buffer_tow (&app_ctx->br, bp, to_fdinfo);
|
||||
buffer_append_ap (bp_dup, &links);
|
||||
|
||||
main_on_tcp_write(ctx, to_fdinfo);
|
||||
} while (1);
|
||||
|
||||
if (ctx->verbose > 1) fprintf(stderr, " [algo_thunder] Packets sent\n");
|
||||
|
||||
// Release the buffer
|
||||
mv_buffer_rtof (&app_ctx->br, fdinfo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -42,6 +82,7 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
memset(app_ctx->misc, 0, sizeof(struct thunder_ctx));
|
||||
struct thunder_ctx* thunderc = app_ctx->misc;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -202,12 +202,7 @@ void dump_abstract_packet(union abstract_packet* ap) {
|
|||
printf(" size=%d, cmd=%d\n", ap->fmt.headers.size, ap->fmt.headers.cmd);
|
||||
switch (ap->fmt.headers.cmd) {
|
||||
case CMD_LINK_MONITORING_THUNDER:
|
||||
printf(" <LinkMonitoringThunder>id=%d, deltat=%d, prevlink=%d, min_blocked_pkt=%d, bitfield=%02x</LinkMonitoringThunder>\n",
|
||||
ap->fmt.content.link_monitoring_thunder.id,
|
||||
ap->fmt.content.link_monitoring_thunder.deltat,
|
||||
ap->fmt.content.link_monitoring_thunder.prevlink,
|
||||
ap->fmt.content.link_monitoring_thunder.min_blocked_pkt,
|
||||
ap->fmt.content.link_monitoring_thunder.bitfield);
|
||||
printf(" <LinkMonitoringThunder/>\n");
|
||||
break;
|
||||
case CMD_UDP_METADATA_THUNDER:
|
||||
printf(" <UdpMetadataThunder>id=%d</UdpMetadataThunder>\n",
|
||||
|
|
12
src/packet.h
12
src/packet.h
|
@ -41,6 +41,11 @@ enum PKT_FLAGS {
|
|||
FLAG_READ_NEXT = 1 << 0,
|
||||
};
|
||||
|
||||
struct link_info {
|
||||
uint8_t delta_t;
|
||||
uint8_t delta_lid;
|
||||
};
|
||||
|
||||
union abstract_packet {
|
||||
char raw;
|
||||
struct {
|
||||
|
@ -52,11 +57,8 @@ union abstract_packet {
|
|||
|
||||
union {
|
||||
struct {
|
||||
uint16_t id;
|
||||
uint8_t bitfield;
|
||||
uint8_t prevlink;
|
||||
uint16_t deltat;
|
||||
uint16_t min_blocked_pkt;
|
||||
uint16_t lid;
|
||||
struct link_info *links_status;
|
||||
} link_monitoring_thunder;
|
||||
struct {
|
||||
uint16_t id;
|
||||
|
|
Loading…
Reference in a new issue