Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added balancing groups and common group receiver #2885

Draft
wants to merge 100 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
463085c
First trial version
Jul 29, 2022
7fbca8a
Completed balancing code (compiled, not tested)
Aug 1, 2022
6602b15
Updated to latest master
Aug 4, 2022
29735ff
First version compiled with new recv buffer. Nothing tested.
Aug 19, 2022
3549bb8
Merged last upstream. Fixed compiling against ENABLE_NEW_RCVBUFFER
Aug 22, 2022
027072a
Fixed referring to buffer pointer in the socket
Aug 24, 2022
7a5853b
Fixed some bux during the first run
Aug 24, 2022
44803f2
Merge remote-tracking branch 'origin/master' into dev-add-group-balan…
Aug 24, 2022
6862b97
Fixed getting group status with the reading function
Aug 25, 2022
087b8db
Fixed bux in receiver buffer. Fixed handshake resource creation order…
Aug 30, 2022
b5d95d2
Added a workaround to read-ready check for a group-member socket
Aug 31, 2022
f03b09e
Added specific algorithm for tracking group loss for balancing groups
Sep 2, 2022
38510ab
Fixed broken release build
ethouris Sep 2, 2022
23dec40
Fixed bug: wrong loss range found in the buffer. Added broadcast grou…
ethouris Sep 2, 2022
e739133
Added common group losses handling
Sep 22, 2022
92639ad
Implemented receiver loss management for new bonding
ethouris Sep 22, 2022
2de148e
Cosmetics
ethouris Sep 22, 2022
047f126
Merge branch 'master' into dev-add-group-balancing
ethouris Sep 22, 2022
d07e71a
Minor bugfixes. Some line reordering and comment fixes
ethouris Sep 22, 2022
496e6a7
Exported fragment to a separate function
Sep 22, 2022
dbc3729
Fixed one deadlock. Added verification in snd-loss-removal procedure
Sep 23, 2022
b514108
Added handling of balancing group for srt-test-live. Fixed permissions.
ethouris Sep 26, 2022
03214ff
Applied changes from PR 2467-before merging
Sep 30, 2022
a1bb540
Fixed balancing mode sending. Fixed loss list selective extraction. A…
Oct 5, 2022
1f8faac
Improved and fixed balancing loss detection
ethouris Oct 24, 2022
faf9bec
Merged against latest master
Oct 25, 2022
96e92dd
Adjusted to the latest changes in the group branch, per changes in ma…
Oct 25, 2022
bdc6fff
Updated and post-fixed
Oct 25, 2022
deeaf05
Some cosmetic fixes after the update
Oct 26, 2022
a68d5cf
Updated for latest master
Oct 26, 2022
d2d1c90
Merge branch 'master' into dev-processdata-refax
Oct 26, 2022
89e927f
Added lacking fix for AEAD
Oct 26, 2022
a56c84d
Fixed: block static variable that might be unused when no logging (tr…
Oct 27, 2022
974a6ed
Merged with master (changes for AEAD)
Oct 27, 2022
0168c5e
Fixed after PR comments
Nov 1, 2022
870509f
Renamed getPacketPTS. Moved call to obtain PTS under belated condition
Nov 3, 2022
c103433
Updated taking pts for stats and logs only where needed. Added more e…
Nov 3, 2022
b3f768f
Improved logging for the receiver side
ethouris Nov 3, 2022
e979a68
Updated from master and post-fixed
Nov 3, 2022
a5d0e73
Merge remote-tracking branch 'refs/remotes/ethouris/dev-add-group-bal…
Nov 3, 2022
b15876e
Added some comments regarding the new TSBPD triggering rules
Nov 7, 2022
9f5174c
Merge branch 'dev-processdata-refax' into dev-refax-buffer-tsbpd-trig…
Nov 7, 2022
652e35d
Applied changes for improved TSBPD and receiver buffer
Nov 7, 2022
37ec000
Updated to the latest master and fixed
Nov 8, 2022
6295cb9
Updated and fixed
Nov 8, 2022
36c1f67
Updated usage of shortcuts and new names
Nov 8, 2022
1fbd754
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Nov 9, 2022
478ca41
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Nov 10, 2022
8335cbe
Fixed some logs formatting
ethouris Nov 10, 2022
e217b7d
Updated to latest upstream
Nov 23, 2022
df46c57
Updated to latest upstream
Nov 23, 2022
251c9c5
Updated, part 1. Not tested (only UT)
Dec 6, 2022
4b39b7b
Merge branch 'master' into dev-add-group-balancing
Dec 6, 2022
1df7e40
Updated and fixed
Dec 6, 2022
631adb0
Some cosmetics and updates from upstream
Dec 7, 2022
26d11de
Updated to latest upstream
Dec 7, 2022
db18435
Fixed atomic operator bug (reported by gcc-11)
Dec 7, 2022
9f7db49
Fixed: for backup link sync use the common group buffer start sequence
Dec 8, 2022
35450ca
Fixed deadlock on 2L locked GroupLock. Fixed crash when discarding a …
Dec 15, 2022
a826e3c
Trial fix for the rogue ACK in backup groups
Dec 16, 2022
b116838
Some cosmetic log fixes
ethouris Dec 16, 2022
eaf51e4
Updated to latest upstream
ethouris Dec 19, 2022
0b515e8
Updated
Dec 23, 2022
f636ce7
Updated and fixed
Feb 22, 2023
dc2dcdf
Updated lock info in the comment
Jul 18, 2023
ae914e5
Merged and stabilized
Sep 19, 2023
519cb7e
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Sep 19, 2023
4bb7b47
Added mutex spec to a function
Sep 19, 2023
d179878
Added more thread check entries
Sep 19, 2023
94fb676
Updated to latest upstream
Feb 15, 2024
8ad69ed
Fixed a suggested uninitialized variable
Feb 15, 2024
bbced79
Renamed eclipsed variable
Feb 16, 2024
5136ca2
Added doxy description for some functions. Applied NonOrder in names …
Feb 16, 2024
f6e0271
Removed wrong fix. Fixed C++11 style initialization of PacketInfo
Feb 16, 2024
072a8c4
Refax: CRcvBuffer extracted some parts of insert() to separate functions
Feb 16, 2024
4302615
Updated and fixed
Feb 21, 2024
1830e3a
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Feb 22, 2024
7bdd82c
Merged and post-fixed
Feb 22, 2024
432b0c7
Fixed some problems around macros that caused build breaks
Feb 22, 2024
f416392
Fixed gcc extension causing BB on Windows
Feb 22, 2024
5b99754
Fixed some build breaks reported by CI
Feb 26, 2024
328c359
Fixed C++03 incompat case
Feb 26, 2024
283021e
Apply suggestions from code review
ethouris Feb 28, 2024
b969a83
Remaining post-review fixes
Feb 28, 2024
df237d6
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Feb 29, 2024
d8f485a
Merge branch 'master' into dev-refax-buffer-tsbpd-triggers
Mar 11, 2024
d9f079a
Turned integer-based values to strong types. CHECKPOINT: tests passed
Jun 3, 2024
ab469d6
Fixed previous problems with receiver buffer
Jun 10, 2024
a2b1b44
First working version with end/drop as offset
ethouris Jun 17, 2024
ff16e68
Blocked development support types and fixed the test
Jun 17, 2024
1f6ac3d
Updated to latest upstream
Jun 18, 2024
fa70fda
Merged changes
Jun 18, 2024
1bf93ff
Cleanup of the commented-out code
Jun 18, 2024
f4f22ba
Cleaning up other temporary development entries
Jun 18, 2024
2e182a8
Updated with latest changes in receiver buffer. NOT TESTED, one IPE i…
Jun 20, 2024
0a88fdf
Updated and fixed
Aug 14, 2024
74a27ed
Updated and fixed
Aug 29, 2024
cb00cce
Added option to disable test discovery (off by default)
Sep 3, 2024
5bc71e9
BUGFIX: the buffer info extraction function wasn't mutex-protected
Sep 4, 2024
498d980
Updated and fixed
Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
#set_tests_properties(test-srt PROPERTIES RUN_SERIAL TRUE)
else()
set_tests_properties(${tests_srt} PROPERTIES RUN_SERIAL TRUE)
gtest_discover_tests(test-srt)
#gtest_discover_tests(test-srt)
endif()

enable_testing()
Expand Down
1 change: 1 addition & 0 deletions apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const SocketOption srt_options [] {
#if ENABLE_BONDING
{ "groupconnect", 0, SRTO_GROUPCONNECT, SocketOption::PRE, SocketOption::INT, nullptr},
{ "groupminstabletimeo", 0, SRTO_GROUPMINSTABLETIMEO, SocketOption::PRE, SocketOption::INT, nullptr},
{ "groupconfig", 0, SRTO_GROUPCONFIG, SocketOption::PRE, SocketOption::STRING, nullptr},
#endif
#ifdef SRT_ENABLE_BINDTODEVICE
{ "bindtodevice", 0, SRTO_BINDTODEVICE, SocketOption::PRE, SocketOption::STRING, nullptr},
Expand Down
63 changes: 30 additions & 33 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ void srt::CUDTSocket::setBrokenClosed()

bool srt::CUDTSocket::readReady()
{
#if ENABLE_BONDING

// If this is a group member socket, then reading happens exclusively from
// the group and the socket is only used as a connection point, packet
// dispatching and single link management. Data buffering and hence ability
// to deliver a packet through API is exclusively the matter of group,
// therefore a single socket is never "read ready".

if (m_GroupOf)
return false;
#endif
if (m_UDT.m_bConnected && m_UDT.isRcvBufferReady())
return true;

Expand Down Expand Up @@ -716,35 +727,17 @@ int srt::CUDTUnited::newConnection(const SRTSOCKET listen,
g->m_bConnected = true;
}

// XXX PROLBEM!!! These events are subscribed here so that this is done once, lazily,
// but groupwise connections could be accepted from multiple listeners for the same group!
// m_listener MUST BE A CONTAINER, NOT POINTER!!!
// ALSO: Maybe checking "the same listener" is not necessary as subscruption may be done
// multiple times anyway?
if (!g->m_listener)
{
// Newly created group from the listener, which hasn't yet
// the listener set.
g->m_listener = ls;

// Listen on both first connected socket and continued sockets.
// This might help with jump-over situations, and in regular continued
// sockets the IN event won't be reported anyway.
int listener_modes = SRT_EPOLL_ACCEPT | SRT_EPOLL_UPDATE;
epoll_add_usock_INTERNAL(g->m_RcvEID, ls, &listener_modes);

// This listening should be done always when a first connected socket
// appears as accepted off the listener. This is for the sake of swait() calls
// inside the group receiving and sending functions so that they get
// interrupted when a new socket is connected.
}
// In the new recvbuffer mode (and common receiver buffer) there's no waiting for reception
// on a socket and no reading from a socket directly is being done; instead the reading API
// is directly bound to the group and reading happens directly from the group's buffer.
// This includes also a situation of a newly connected socket, which will be delivering packets
// into the same common receiver buffer for the group, so readable will be the group itself
// when it has its own common buffer read-ready, by whatever reason. Packets to the buffer
// will be delivered by the sockets' receiver threads, so all these things happen strictly
// in the background.

// Add also per-direction subscription for the about-to-be-accepted socket.
// Both first accepted socket that makes the group-accept and every next
// socket that adds a new link.
int read_modes = SRT_EPOLL_IN | SRT_EPOLL_ERR;
// Keep per-socket sender ready EID.
int write_modes = SRT_EPOLL_OUT | SRT_EPOLL_ERR;
epoll_add_usock_INTERNAL(g->m_RcvEID, ns, &read_modes);
epoll_add_usock_INTERNAL(g->m_SndEID, ns, &write_modes);

// With app reader, do not set groupPacketArrival (block the
Expand Down Expand Up @@ -1439,7 +1432,7 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i
// Do it after setting all stored options, as some of them may
// influence some group data.

srt::groups::SocketData data = srt::groups::prepareSocketData(ns);
srt::groups::SocketData data = srt::groups::prepareSocketData(ns, g.type());
if (targets[tii].token != -1)
{
// Reuse the token, if specified by the caller
Expand Down Expand Up @@ -1530,7 +1523,6 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i
// connection succeeded or failed and whether the new socket is
// ready to use or needs to be closed.
epoll_add_usock_INTERNAL(g.m_SndEID, ns, &connect_modes);
epoll_add_usock_INTERNAL(g.m_RcvEID, ns, &connect_modes);

// Adding a socket on which we need to block to BOTH these tracking EIDs
// and the blocker EID. We'll simply remove from them later all sockets that
Expand Down Expand Up @@ -1652,7 +1644,6 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i
f->sndstate = SRT_GST_BROKEN;
f->rcvstate = SRT_GST_BROKEN;
epoll_remove_socket_INTERNAL(g.m_SndEID, ns);
epoll_remove_socket_INTERNAL(g.m_RcvEID, ns);
}
else
{
Expand Down Expand Up @@ -1738,7 +1729,6 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i

epoll_remove_socket_INTERNAL(eid, y->second);
epoll_remove_socket_INTERNAL(g.m_SndEID, y->second);
epoll_remove_socket_INTERNAL(g.m_RcvEID, y->second);
}
}

Expand Down Expand Up @@ -1778,7 +1768,6 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i

epoll_remove_socket_INTERNAL(eid, s);
epoll_remove_socket_INTERNAL(g.m_SndEID, s);
epoll_remove_socket_INTERNAL(g.m_RcvEID, s);

continue;
}
Expand Down Expand Up @@ -2287,6 +2276,8 @@ int srt::CUDTUnited::select(UDT::UDSET* readfds, UDT::UDSET* writefds, UDT::UDSE
return count;
}

// XXX This may crash when a member socket is added to selectEx.
// Consider revising to prevent a member socket from being used.
int srt::CUDTUnited::selectEx(const vector<SRTSOCKET>& fds,
vector<SRTSOCKET>* readfds,
vector<SRTSOCKET>* writefds,
Expand Down Expand Up @@ -2622,6 +2613,12 @@ void srt::CUDTUnited::checkBrokenSockets()
continue;
}
else

// Additional note on group receiver: with the new group
// receiver m_pRcvBuffer in the socket core is NULL always,
// but that's not a problem - you can close the member socket
// safely without worrying about reading data because they are
// in the group anyway.
{
CUDT& u = s->core();

Expand Down Expand Up @@ -3186,7 +3183,7 @@ void srt::CUDTUnited::updateMux(CUDTSocket* s, const sockaddr_any& reqaddr, cons
m.m_pSndQueue = new CSndQueue;
m.m_pSndQueue->init(m.m_pChannel, m.m_pTimer);
m.m_pRcvQueue = new CRcvQueue;
m.m_pRcvQueue->init(128, s->core().maxPayloadSize(), m.m_iIPversion, 1024, m.m_pChannel, m.m_pTimer);
m.m_pRcvQueue->init(128, s->core().maxPayloadSize(), m.m_iIPversion, 1024, m.m_pChannel, m.m_pTimer, s->m_SocketID);

// Rewrite the port here, as it might be only known upon return
// from CChannel::open.
Expand Down
7 changes: 6 additions & 1 deletion srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ class CUDTSocket

void construct();

SRT_ATTR_GUARDED_BY(m_ControlLock)
// XXX Controversial as to whether it should be guarded by this lock.
// It is used in many places without the lock, and it is also atomic.
// (blocked because it makes more ado than actual help)
//SRT_ATTR_GUARDED_BY(m_ControlLock)
sync::atomic<SRT_SOCKSTATUS> m_Status; //< current socket state

/// Time when the socket is closed.
Expand Down Expand Up @@ -484,6 +487,8 @@ class CUDTUnited
#endif

void checkBrokenSockets();

SRT_ATTR_REQUIRES(m_GlobControlLock)
void removeSocket(const SRTSOCKET u);

CEPoll m_EPoll; // handling epoll data structures and events
Expand Down
Loading
Loading