For developer, required some explanation on code with timer and BGP
Hello all, this is a message for developer and who know how bird use timer, and buffer. Sorry for the length of this mail. For first, the protocol i want to modify and upgrade is BGP, i see that there isn't the timer MRAI implemented and it will be useful for some studies on information propagation, so i decided to develop a first version of it. The actual process to send any kind of pkt is to call the function bgp_fire_tx() and it's called by two other function respectively bgp_kick_tx() and bgp_tx() and the function bgp_fire_tx() take care to read from the buffer the message that has to be sent and send it. bgp_kick_tx() and bgp_tx() call bgp_fire_tx() while it don't return 0, so the clear all the buffer of the message that has to be sent. So my idea to introduce MRAI was that: Create a timer (for now I created it for connection, after like say RFC 4271 this timer has to be set for every route) and put it on the connection. Initialize it with the other timer of the conn when the state of the conn goes up i set it to some value and start the timer. when the timer finish i call the function MRAI_finish() that call the function bgp_fire_tx() while there is something to send more ore less like the while loop in bgp_kick_tx() and bgp_tx() when it's called bgp_fire_tx() on the update message part i written a check, if the timer isn't at 0 i can't send the update, because the function can be called from bgp_kick_tx() or bgp_tx(), but if it 0 it is finished so i can send the message When all the message had been send i reset the timer and start it again. But unfortunately i see something that doesn't make my code work. when something call bgp_kick_tx() or bgp_tx() the call bgp_fire_tx() and they clear all the buffer, including update message that wasn't sended so when the timer finish it didn't found anything on the buffer. Now how can i change that? My idea is to use a secondary buffer, when in bgp_fire_tx() i see that i can't send the update I will insert the pkt in this secondary buffer and consume the pkt on the main buffer. when bgp_kick_tx() or bgp_tx() have send all the messages I will transfer all the pkt in the secondary buffer into the main buffer. So I ask you it's possible that? there is something in the code already written that could help me? do you see another way to implement the MRAI timer? Thanks a lot to everyone, Mattia
On Thu, Jul 05, 2018 at 05:19:33PM +0200, Mattia Milani wrote:
Hello all, this is a message for developer and who know how bird use timer, and buffer. Sorry for the length of this mail.
For first, the protocol i want to modify and upgrade is BGP, i see that there isn't the timer MRAI implemented and it will be useful for some studies on information propagation, so i decided to develop a first version of it.
The actual process to send any kind of pkt is to call the function
bgp_fire_tx() and it's called by two other function respectively bgp_kick_tx() and bgp_tx()
Hi If you want to implement per-conn MRAI timer, you should not do that on level of *_tx() functions (as they handle all packets), but one level before that - you could enforce MRAI intervals between update-scheduled and update-not-scheduled states. Update-scheduled state starts when bgp_rt_notify() calls bgp_schedule_packet(p->conn, PKT_UPDATE) and ends when conn->packets_to_send is set to zero in bgp_fire_tx(). You could ensure that there is MRAI interval between last update cycle and new one by postponing bgp_schedule_packet(p->conn, PKT_UPDATE) when necessary (i.e. if it is not currently sheduled and it is less that MRAI from last end). It is not completely correct (as you can get new route update even before the cycle in which the previous one was already sent is finished). The even better and correct way would be to implement it one more level before when prefixes (in struct bgp_prefix) are dispatched for struct bgp_bucket. There could be timestamps in struct bgp_prefix, separate queue for bgp_buckets that contain only postponed bgp_prefixes, and list of recently sent but not yet collected bgp_prefixes to keep their timestamps. But that would be significantly more work. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
If you want to implement per-conn MRAI timer, you should not do that on level of *_tx() functions (as they handle all packets), but one level before that - you could enforce MRAI intervals between update-scheduled and update-not-scheduled states.
Update-scheduled state starts when bgp_rt_notify() calls
bgp_schedule_packet(p->conn, PKT_UPDATE) and ends when conn->packets_to_send is set to zero in bgp_fire_tx().
Ok, so i was on the wrong level, i didn't see the level where there is update-scheduled and not scheduled, my mistake. Tomorrow i will study this parto so in the next days I'll be able to implement it. You could ensure that there is MRAI interval between last update cycle and
new one by postponing bgp_schedule_packet(p->conn, PKT_UPDATE) when necessary (i.e. if it is not currently sheduled and it is less that MRAI from last end).
It is not completely correct (as you can get new route update even before the cycle in which the previous one was already sent is finished).
Did you mean that if I develop MRAI on per-conn level there will be this problem? In that case yeah I agree with that. But my final goal it's to implement it for every route that i learn and i want to shar, like RFC say.
The even better and correct way would be to implement it one more level before when prefixes (in struct bgp_prefix) are dispatched for struct bgp_bucket. There could be timestamps in struct bgp_prefix, separate queue for bgp_buckets that contain only postponed bgp_prefixes, and list of recently sent but not yet collected bgp_prefixes to keep their timestamps. But that would be significantly more work.
Ok i this could be the next step, first of all i will develop the simple solution, after the tests that works fine I'll develop the complete solution for that. Thanks you for the help, if in the next days you have bettere ideas please notify me. Thanks, Mattia
The even better and correct way would be to implement it one more level before when prefixes (in struct bgp_prefix) are dispatched for struct bgp_bucket. There could be timestamps in struct bgp_prefix, separate queue for bgp_buckets that contain only postponed bgp_prefixes, and list of recently sent but not yet collected bgp_prefixes to keep their timestamps. But that would be significantly more work.
Hello, sorry if I resume this old thread. I would like to implement the MRAI timer in this better and correct way in the latest version and in the end maybe do a pull request. First of all, which version would you suggest to download? from the git repo i see a lot of branches, I thought to work from the master branch, but i don't know if it's the best choice for this purpose. Second, could you please explain much deeper this correct approach? I'm not scared by the dimension of the work, but I want to understand it correctly to do it in the right way. Thanks, Mattia
participants (2)
-
Mattia Milani -
Ondrej Zajicek