You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-24 14:20:59 +03:00
the begginning
This commit is contained in:
77
utils/multicast/Makefile
Normal file
77
utils/multicast/Makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
include ../../rules.mak
|
||||
#******************************************************************************************
|
||||
# $Id: $
|
||||
#
|
||||
# Copyright (C) 2009-2012 Calpont Corporation
|
||||
# All rights reserved
|
||||
#*****************************************************************************************/
|
||||
.PHONY: install clean test docs coverage leakcheck
|
||||
# The name of the executable
|
||||
|
||||
PROGRAM=libmulticast.so
|
||||
VERSION=1.0.0
|
||||
LIBRARY=$(PROGRAM).$(VERSION)
|
||||
|
||||
SRCS=multicast.cpp
|
||||
|
||||
LINCLUDES=multicast.h
|
||||
|
||||
# Run-time directories for project shared libs
|
||||
CALPONT_LIBRARY_PATH=$(EXPORT_ROOT)/lib
|
||||
|
||||
# Preprocessor flags
|
||||
CPPFLAGS=-I. -I$(EXPORT_ROOT)/include -I/usr/include/libxml2
|
||||
|
||||
# Compiler flags
|
||||
CXXFLAGS+=$(DEBUG_FLAGS) -Wall -fPIC
|
||||
|
||||
# Linker flags
|
||||
LDFLAGS+=-L$(CALPONT_LIBRARY_PATH) -lmessageqcpp -lconfigcpp -lloggingcpp -lxml2
|
||||
|
||||
.PHONY: install clean test docs coverage leakcheck
|
||||
|
||||
CLIBS=-L$(EXPORT_ROOT)/lib
|
||||
TLIBS=-L. $(CLIBS)
|
||||
|
||||
LLIBS=-L$(CALPONT_LIBRARY_PATH)
|
||||
|
||||
OBJS=$(SRCS:.cpp=.o)
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
$(MAKE) -C ../messageqcpp install
|
||||
$(MAKE) -C ../configcpp install
|
||||
$(MAKE) -C ../threadpool install
|
||||
$(MAKE) -C ../loggingcpp install
|
||||
$(LINK.cpp) -shared -o $(LIBRARY) $(OBJS)
|
||||
rm -f $(PROGRAM)
|
||||
ln -s $(LIBRARY) $(PROGRAM)
|
||||
|
||||
install: bootstrap $(LIBRARY)
|
||||
umask 002; \
|
||||
mkdir -p $(INSTALL_ROOT_LIB) $(INSTALL_ROOT_INCLUDE); \
|
||||
pushd $(INSTALL_ROOT_LIB) >/dev/null; \
|
||||
rm -f $(LIBRARY) $(PROGRAM); \
|
||||
ln -s $(LIBRARY) $(PROGRAM); \
|
||||
popd >/dev/null; \
|
||||
$(INSTALL) $(LIBRARY) $(INSTALL_ROOT_LIB)
|
||||
|
||||
bootstrap:
|
||||
|
||||
xxx:
|
||||
$(INSTALL) $(LINCLUDES) $(INSTALL_ROOT_INCLUDE)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) tdriver.o $(PROGRAM) $(LIBRARY) tdriver core *~ *.tag *-gcov.* *.gcov tdriver-gcov *.d *.d.*
|
||||
|
||||
docs:
|
||||
doxygen $(EXPORT_ROOT)/etc/Doxyfile
|
||||
|
||||
%.d: %.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
||||
ifndef BOOTSTRAP
|
||||
-include $(SRCS:.cpp=.d)
|
||||
endif
|
||||
38
utils/multicast/Makefile.am
Normal file
38
utils/multicast/Makefile.am
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (C) 2014 InfiniDB, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 of
|
||||
# the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
# $Id$
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
AM_CPPFLAGS = $(idb_common_includes) $(idb_cppflags)
|
||||
AM_CFLAGS = $(idb_cflags)
|
||||
AM_CXXFLAGS = $(idb_cxxflags)
|
||||
AM_LDFLAGS = -version-info 1:0:0 $(idb_ldflags)
|
||||
lib_LTLIBRARIES = libmulticast.la
|
||||
libmulticast_la_SOURCES = multicast.cpp
|
||||
include_HEADERS = multicast.h
|
||||
|
||||
test:
|
||||
|
||||
coverage:
|
||||
|
||||
leakcheck:
|
||||
|
||||
docs:
|
||||
|
||||
bootstrap: install-data-am
|
||||
|
||||
208
utils/multicast/config.h
Normal file
208
utils/multicast/config.h
Normal file
@@ -0,0 +1,208 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the `atexit' function. */
|
||||
#define HAVE_ATEXIT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `dlsym' function. */
|
||||
#define HAVE_DLSYM 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* Define to 1 if you have the `htons' function. */
|
||||
#define HAVE_HTONS 1
|
||||
|
||||
/* Define to 1 if you have the `inet_aton' function. */
|
||||
#define HAVE_INET_ATON 1
|
||||
|
||||
/* Define to 1 if you have the `inet_pton' function. */
|
||||
#define HAVE_INET_PTON 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `in_addr_t'. */
|
||||
#define HAVE_IN_ADDR_T 1
|
||||
|
||||
/* Define to 1 if you have the `dl' library (-ldl). */
|
||||
#define HAVE_LIBDL 1
|
||||
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
#define HAVE_LIBPTHREAD 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define when you have an LLSEEK prototype */
|
||||
/* #undef HAVE_LLSEEK_PROTOTYPE */
|
||||
|
||||
/* Define when the compiler supports LOFF_T type */
|
||||
#define HAVE_LOFF_T 1
|
||||
|
||||
/* Define when the compiler supports LONG_LONG type */
|
||||
#define HAVE_LONG_LONG 1
|
||||
|
||||
/* Define to 1 if you have the `lseek64' function. */
|
||||
#define HAVE_LSEEK64 1
|
||||
|
||||
/* Define when you have an LSEEK64 prototype */
|
||||
#define HAVE_LSEEK64_PROTOTYPE 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define when the compiler supports OFFSET_T type */
|
||||
/* #undef HAVE_OFFSET_T */
|
||||
|
||||
/* Define when the system has a 64 bit off_t type */
|
||||
#define HAVE_OFF_T_64 1
|
||||
|
||||
/* Define to 1 if you have the `on_exit' function. */
|
||||
#define HAVE_ON_EXIT 1
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if `imr_ifindex' is member of `struct ip_mreqn'. */
|
||||
#define HAVE_STRUCT_IP_MREQN_IMR_IFINDEX 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKIO_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/termios.h> header file. */
|
||||
/* #undef HAVE_SYS_TERMIOS_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the `tcsetattr' function. */
|
||||
#define HAVE_TCSETATTR 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <winsock2.h> header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* #undef inline */
|
||||
#endif
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
3417
utils/multicast/impl.cpp
Normal file
3417
utils/multicast/impl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
67
utils/multicast/impl.h
Normal file
67
utils/multicast/impl.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/******************************************************************************
|
||||
* $Id: impl.h 3495 2013-01-21 14:09:51Z rdempsey $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* This code is based on udpcast-20090830. Most of the source code in that release
|
||||
contains no copyright or licensing notices at all. The exception is fec.c, which
|
||||
is not used here. The udpcast website, http://udpcast.linux.lu/, implies that
|
||||
the source is covered under GPL. */
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef MCAST_IMPL_H__
|
||||
#define MCAST_IMPL_H__
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bytestream.h"
|
||||
|
||||
#include "udpcast.h"
|
||||
#include "participants.h"
|
||||
|
||||
namespace multicast
|
||||
{
|
||||
|
||||
class MulticastImpl
|
||||
{
|
||||
public:
|
||||
MulticastImpl(int min_receivers, const std::string& ifName, int portBase=9000, int bufSize=8*1024*1024);
|
||||
~MulticastImpl();
|
||||
|
||||
void startSender();
|
||||
void doTransfer(const uint8_t* buf, uint32_t len);
|
||||
|
||||
void startReceiver();
|
||||
void receive(messageqcpp::SBS obs);
|
||||
|
||||
struct net_config fNet_config;
|
||||
struct stat_config fStat_config;
|
||||
struct client_config fClient_config;
|
||||
std::string fIfName;
|
||||
int fSock[3];
|
||||
participantsDb_t fDb;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
35
utils/multicast/mc_fifo.h
Normal file
35
utils/multicast/mc_fifo.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef FIFO_H
|
||||
#define FIFO_H
|
||||
|
||||
#include "threads.h"
|
||||
#include "produconsum.h"
|
||||
|
||||
typedef struct fifo {
|
||||
unsigned char *dataBuffer;
|
||||
unsigned int dataBufSize;
|
||||
|
||||
produconsum_t freeMemQueue; /* queue for free memory */
|
||||
produconsum_t data; /* queue for received data or data received
|
||||
* from disk */
|
||||
|
||||
pthread_t thread;
|
||||
} *fifo_t;
|
||||
|
||||
#endif
|
||||
95
utils/multicast/multicast.cpp
Normal file
95
utils/multicast/multicast.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/******************************************************************************
|
||||
* $Id: multicast.cpp 3495 2013-01-21 14:09:51Z rdempsey $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace std;
|
||||
|
||||
#include "bytestream.h"
|
||||
using namespace messageqcpp;
|
||||
|
||||
#include "configcpp.h"
|
||||
using namespace config;
|
||||
|
||||
#include "multicast.h"
|
||||
|
||||
namespace multicast
|
||||
{
|
||||
|
||||
Multicast::Multicast() :
|
||||
fPMCount(1),
|
||||
fIFName("eth0"),
|
||||
fPortBase(9000),
|
||||
fBufSize(8 * 1024 * 1024)
|
||||
{
|
||||
int tmp;
|
||||
string stmp;
|
||||
|
||||
Config* cf = Config::makeConfig();
|
||||
|
||||
tmp = Config::fromText(cf->getConfig("PrimitiveServers", "Count"));
|
||||
if (tmp > 0) fPMCount = tmp;
|
||||
|
||||
stmp = cf->getConfig("Multicast", "Interface");
|
||||
if (!stmp.empty()) fIFName = stmp;
|
||||
|
||||
tmp = Config::fromText(cf->getConfig("Multicast", "PortBase"));
|
||||
if (tmp > 0) fPortBase = tmp;
|
||||
|
||||
tmp = Config::fromText(cf->getConfig("Multicast", "BufSize"));
|
||||
if (tmp > 0) fBufSize = tmp;
|
||||
}
|
||||
|
||||
MulticastReceiver::MulticastReceiver() :
|
||||
fPimpl(0)
|
||||
{
|
||||
}
|
||||
|
||||
MulticastReceiver::~MulticastReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
SBS MulticastReceiver::receive()
|
||||
{
|
||||
throw runtime_error("Multicast is not available");
|
||||
return fByteStream;
|
||||
}
|
||||
|
||||
MulticastSender::MulticastSender() :
|
||||
fPimpl(0)
|
||||
{
|
||||
}
|
||||
|
||||
MulticastSender::~MulticastSender()
|
||||
{
|
||||
}
|
||||
|
||||
void MulticastSender::send(const ByteStream& msg)
|
||||
{
|
||||
throw runtime_error("Multicast is not available");
|
||||
}
|
||||
|
||||
} //namespace multicast
|
||||
|
||||
//vim:ts=4 sw=4:
|
||||
119
utils/multicast/multicast.h
Normal file
119
utils/multicast/multicast.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/******************************************************************************
|
||||
* $Id: multicast.h 3495 2013-01-21 14:09:51Z rdempsey $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/** @file
|
||||
* class Multicast interface
|
||||
*/
|
||||
|
||||
#ifndef MULTICAST_H
|
||||
#define MULTICAST_H
|
||||
|
||||
#include "messagequeue.h"
|
||||
|
||||
namespace multicast
|
||||
{
|
||||
|
||||
/** @brief MulticastReceive
|
||||
* Wrapper for multicast proto
|
||||
*/
|
||||
|
||||
class MulticastImpl;
|
||||
|
||||
class Multicast
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
* Base class
|
||||
*/
|
||||
Multicast();
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
virtual ~Multicast() { destroy(); }
|
||||
|
||||
virtual void destroy() { }
|
||||
|
||||
int PMCount() const { return fPMCount; }
|
||||
std::string iFName() const { return fIFName; }
|
||||
int portBase() const { return fPortBase; }
|
||||
int bufSize() const { return fBufSize; }
|
||||
|
||||
private:
|
||||
int fPMCount;
|
||||
std::string fIFName;
|
||||
int fPortBase;
|
||||
int fBufSize;
|
||||
|
||||
};
|
||||
|
||||
class MulticastReceiver: public Multicast
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*
|
||||
*/
|
||||
MulticastReceiver();
|
||||
|
||||
~MulticastReceiver();
|
||||
|
||||
messageqcpp::SBS receive();
|
||||
|
||||
private:
|
||||
// not copyable
|
||||
MulticastReceiver(const MulticastReceiver& rhs);
|
||||
MulticastReceiver& operator=(const MulticastReceiver& rhs);
|
||||
|
||||
messageqcpp::SBS fByteStream;
|
||||
|
||||
MulticastImpl* fPimpl;
|
||||
};
|
||||
|
||||
|
||||
class MulticastSender : public Multicast
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*
|
||||
*/
|
||||
MulticastSender();
|
||||
|
||||
~MulticastSender();
|
||||
|
||||
/** @brief receive
|
||||
*
|
||||
* @param bytestream to send
|
||||
*/
|
||||
void send(const messageqcpp::ByteStream& bs);
|
||||
|
||||
private:
|
||||
//Not copyable
|
||||
MulticastSender(const MulticastSender& rhs);
|
||||
MulticastSender& operator=(const MulticastSender& rhs);
|
||||
|
||||
MulticastImpl* fPimpl;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif //MULTICAST_H
|
||||
|
||||
31
utils/multicast/participants.h
Normal file
31
utils/multicast/participants.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef PARTICIPANTS_H
|
||||
#define PARTICIPANTS_H
|
||||
|
||||
#define MAX_CLIENTS 1024
|
||||
|
||||
typedef struct participantsDb *participantsDb_t;
|
||||
|
||||
#define printNotSet udpc_printNotSet
|
||||
#define printSet udpc_printSet
|
||||
|
||||
void udpc_printNotSet(participantsDb_t db, char *d);
|
||||
void udpc_printSet(participantsDb_t db, char *d);
|
||||
|
||||
#endif
|
||||
28
utils/multicast/produconsum.h
Normal file
28
utils/multicast/produconsum.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef PRODUCONSUM_H
|
||||
#define PRODUCONSUM_H
|
||||
|
||||
typedef struct produconsum *produconsum_t;
|
||||
|
||||
/**
|
||||
* Get contiguous chunk of data
|
||||
*/
|
||||
int pc_consumeAnyContiguous(produconsum_t pc);
|
||||
|
||||
#endif
|
||||
171
utils/multicast/socklib.h
Normal file
171
utils/multicast/socklib.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef SOCKLIB_H
|
||||
#define SOCKLIB_H
|
||||
|
||||
#ifndef UDPCAST_CONFIG_H
|
||||
# define UDPCAST_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define WINDOWS
|
||||
#undef USE_SYSLOG
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Untested so far ... */
|
||||
#define WINDOWS
|
||||
#endif
|
||||
|
||||
#define RECEIVER_PORT(x) (x)
|
||||
#define SENDER_PORT(x) ((x)+1)
|
||||
|
||||
#define loseSendPacket udpc_loseSendPacket
|
||||
#define loseRecvPacket udpc_loseRecvPacket
|
||||
#define setWriteLoss udpc_setWriteLoss
|
||||
#define setReadLoss udpc_setReadLoss
|
||||
#define setReadSwap udpc_setReadSwap
|
||||
#define srandomTime udpc_srandomTime
|
||||
#define RecvMsg udpc_RecvMsg
|
||||
#define doAutoRateLimit udpc_doAutoRateLimit
|
||||
#define makeSockAddr udpc_makeSockAddr
|
||||
#define printMyIp udpc_printMyIp
|
||||
#define getSendBuf udpc_getSendBuf
|
||||
#define setIpFromString udpc_setIpFromString
|
||||
#define parseSize udpc_parseSize
|
||||
|
||||
#ifdef LOSSTEST
|
||||
int loseSendPacket(void);
|
||||
void loseRecvPacket(int s);
|
||||
void setWriteLoss(char *l);
|
||||
void setReadLoss(char *l);
|
||||
void setReadSwap(char *l);
|
||||
void srandomTime(int printSeed);
|
||||
int RecvMsg(int s, struct msghdr *msg, int flags);
|
||||
#endif
|
||||
|
||||
struct net_if {
|
||||
struct in_addr addr;
|
||||
struct in_addr bcast;
|
||||
const char *name;
|
||||
#ifdef SIOCGIFINDEX
|
||||
int index;
|
||||
#endif
|
||||
};
|
||||
typedef struct net_if net_if_t;
|
||||
|
||||
typedef enum addr_type_t {
|
||||
ADDR_TYPE_UCAST,
|
||||
ADDR_TYPE_MCAST,
|
||||
ADDR_TYPE_BCAST
|
||||
} addr_type_t;
|
||||
|
||||
void doAutoRateLimit(int sock, int dir, int qsize, int size);
|
||||
|
||||
int makeSockAddr(char *hostname, short port, struct sockaddr_in *addr);
|
||||
|
||||
void printMyIp(net_if_t *net_if);
|
||||
|
||||
int getSendBuf(int sock);
|
||||
|
||||
#define SEND(s, msg, to) \
|
||||
doSend(s, &msg, sizeof(msg), &to)
|
||||
|
||||
#define RECV(s, msg, from, portBase ) \
|
||||
doReceive((s), &msg, sizeof(msg), &from, (portBase) )
|
||||
|
||||
#define BCAST_CONTROL(s, msg) \
|
||||
doSend(s, &msg, sizeof(msg), &net_config->controlMcastAddr)
|
||||
|
||||
void setIpFromString(struct sockaddr_in *addr, char *ip);
|
||||
|
||||
unsigned long parseSize(char *sizeString);
|
||||
|
||||
int udpc_socklibFatal(int code);
|
||||
|
||||
#ifdef __MINGW32__ /* __MINGW32__ */
|
||||
|
||||
struct iovec {
|
||||
void *iov_base;
|
||||
int iov_len;
|
||||
};
|
||||
struct msghdr {
|
||||
void *msg_name;
|
||||
int msg_namelen;
|
||||
struct iovec *msg_iov;
|
||||
int msg_iovlen;
|
||||
|
||||
};
|
||||
|
||||
ssize_t sendmsg(int s, const struct msghdr *msg, int flags);
|
||||
ssize_t recvmsg (int fd, struct msghdr *msg, int flags);
|
||||
|
||||
#define usleep(x) Sleep((x)/1000)
|
||||
#define sleep(x) Sleep(1000L*(x))
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
static inline void initMsgHdr(struct msghdr *hdr) {
|
||||
#ifndef WINDOWS
|
||||
hdr->msg_control = 0;
|
||||
hdr->msg_controllen = 0;
|
||||
hdr->msg_flags = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#undef closesocket
|
||||
#define closesocket(x) close(x)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_IN_ADDR_T
|
||||
typedef unsigned long in_addr_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
42
utils/multicast/statistics.h
Normal file
42
utils/multicast/statistics.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef STATISTICS_H
|
||||
#define STATISTICS_H
|
||||
|
||||
|
||||
typedef struct receiver_stats *receiver_stats_t;
|
||||
typedef struct sender_stats *sender_stats_t;
|
||||
|
||||
#define allocReadStats udpc_allocReadStats
|
||||
#define receiverStatsStartTimer udpc_receiverStatsStartTimer
|
||||
#define displayReceiverStats udpc_displayReceiverStats
|
||||
|
||||
receiver_stats_t udpc_allocReadStats(int fd, long statPeriod,
|
||||
int printUncompressedPos);
|
||||
void udpc_receiverStatsStartTimer(receiver_stats_t);
|
||||
void udpc_displayReceiverStats(receiver_stats_t, int isFinal);
|
||||
|
||||
#define allocSenderStats udpc_allocSenderStats
|
||||
#define displaySenderStats udpc_displaySenderStats
|
||||
|
||||
sender_stats_t udpc_allocSenderStats(int fd, FILE *logfile, long bwPeriod,
|
||||
long statPeriod, int printUncompressedPos);
|
||||
void udpc_displaySenderStats(sender_stats_t,int blockSize, int sliceSize,
|
||||
int isFinal);
|
||||
|
||||
#endif
|
||||
142
utils/multicast/threads.h
Normal file
142
utils/multicast/threads.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef UDPCTHREADS_H
|
||||
#define UDPCTHREADS_H
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#include "socklib.h"
|
||||
#include <winsock2.h>
|
||||
#include <winbase.h>
|
||||
#include <sys/time.h>
|
||||
typedef HANDLE pthread_t;
|
||||
typedef CRITICAL_SECTION pthread_mutex_t;
|
||||
typedef HANDLE pthread_cond_t;
|
||||
|
||||
struct timespec {
|
||||
unsigned long tv_sec;
|
||||
unsigned long tv_nsec;
|
||||
};
|
||||
|
||||
static inline int pthread_create(pthread_t *thread, void *dummy1,
|
||||
LPTHREAD_START_ROUTINE start_routine,
|
||||
void *arg) {
|
||||
/* Start thread ...
|
||||
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
|
||||
*/
|
||||
*thread = CreateThread(NULL, /* lpThreadAttributes */
|
||||
0, /* dwStackSize */
|
||||
start_routine,
|
||||
arg, /* lpParameter */
|
||||
0, /* dwCreationFlags */
|
||||
NULL /* lpThreadId */);
|
||||
return *thread != NULL ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int pthread_join(pthread_t th, void **thread_return) {
|
||||
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int pthread_mutex_init(pthread_mutex_t *mutex, void *dummy) {
|
||||
InitializeCriticalSection(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pthread_mutex_lock(pthread_mutex_t *mutex) {
|
||||
EnterCriticalSection(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) {
|
||||
LeaveCriticalSection(mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline int pthread_cond_init(pthread_cond_t *cond, void *dummy) {
|
||||
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||
if(*cond == NULL)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pthread_cond_signal(pthread_cond_t *cond) {
|
||||
return SetEvent(*cond) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int pthread_cond_wait(pthread_cond_t *cond,
|
||||
pthread_mutex_t *mutex) {
|
||||
int r;
|
||||
ResetEvent(*cond);
|
||||
LeaveCriticalSection(mutex);
|
||||
r= WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
|
||||
EnterCriticalSection(mutex);
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void pthread_cancel(pthread_t *thread)
|
||||
{
|
||||
TerminateThread(thread, 0);
|
||||
}
|
||||
|
||||
#define ETIMEDOUT -2
|
||||
#define MILLION 1000000
|
||||
#define BILLION 1000000000
|
||||
|
||||
static inline int pthread_cond_timedwait(pthread_cond_t *cond,
|
||||
pthread_mutex_t *mutex,
|
||||
struct timespec *ts) {
|
||||
int r;
|
||||
struct timeval tv;
|
||||
long delta;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
delta = (ts->tv_sec - tv.tv_sec) * 1000 +
|
||||
(ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
|
||||
if(delta < 0)
|
||||
delta = 0;
|
||||
|
||||
ResetEvent(*cond);
|
||||
LeaveCriticalSection(mutex);
|
||||
|
||||
switch(WaitForSingleObject(*cond, delta )) {
|
||||
case WAIT_OBJECT_0:
|
||||
r=0;
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
r=ETIMEDOUT;
|
||||
break;
|
||||
default:
|
||||
r=-1;
|
||||
break;
|
||||
}
|
||||
EnterCriticalSection(mutex);
|
||||
return r;
|
||||
}
|
||||
|
||||
#define THREAD_RETURN DWORD WINAPI
|
||||
|
||||
|
||||
#else /* __MINGW32__ */
|
||||
#include <pthread.h>
|
||||
#define THREAD_RETURN void *
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#endif
|
||||
108
utils/multicast/udp-sender.h
Normal file
108
utils/multicast/udp-sender.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef UDP_SENDER_H
|
||||
#define UDP_SENDER_H
|
||||
|
||||
#include "udp-sender.h"
|
||||
#include "udpcast.h"
|
||||
#include "participants.h"
|
||||
#include "statistics.h"
|
||||
#include "socklib.h"
|
||||
|
||||
extern FILE *udpc_log;
|
||||
|
||||
struct fifo;
|
||||
|
||||
#define openFile udpc_openFile
|
||||
#define openPipe udpcs_openPipe
|
||||
#define localReader udpc_localReader
|
||||
#define doSend udpc_doSend
|
||||
|
||||
int openFile(struct disk_config *config);
|
||||
int openPipe(struct disk_config *config, int in, int *pid);
|
||||
int localReader(struct fifo *fifo, int in);
|
||||
|
||||
#define BCAST_DATA(s, msg) \
|
||||
doSend(s, &msg, sizeof(msg), &net_config->dataMcastAddr)
|
||||
|
||||
|
||||
/**
|
||||
* "switched network" mode: server already starts sending next slice before
|
||||
* first one is acknowledged. Do not use on old coax networks
|
||||
*/
|
||||
#define FLAG_SN 0x0001
|
||||
|
||||
/**
|
||||
* "not switched network" mode: network is known not to be switched
|
||||
*/
|
||||
#define FLAG_NOTSN 0x0002
|
||||
|
||||
/**
|
||||
* Asynchronous mode: do not any confirmation at all from clients.
|
||||
* Useful in situations where no return channel is available
|
||||
*/
|
||||
#define FLAG_ASYNC 0x0004
|
||||
|
||||
|
||||
/**
|
||||
* Point-to-point transmission mode: use unicast in the (frequent)
|
||||
* special case where there is only one receiver.
|
||||
*/
|
||||
#define FLAG_POINTOPOINT 0x0008
|
||||
|
||||
|
||||
/**
|
||||
* Do automatic rate limitation by monitoring socket's send buffer
|
||||
* size. Not very useful, as this still doesn't protect against the
|
||||
* switch dropping packets because its queue (which might be slightly slower)
|
||||
* overruns
|
||||
*/
|
||||
#ifndef WINDOWS
|
||||
#define FLAG_AUTORATE 0x0008
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_UDPCAST_FEC
|
||||
/**
|
||||
* Forward error correction
|
||||
*/
|
||||
#define FLAG_FEC 0x0010
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use broadcast rather than multicast (useful for cards that don't support
|
||||
* multicast correctly
|
||||
*/
|
||||
#define FLAG_BCAST 0x0020
|
||||
|
||||
/**
|
||||
* Never use point-to-point, even if only one receiver
|
||||
*/
|
||||
#define FLAG_NOPOINTOPOINT 0x0040
|
||||
|
||||
|
||||
/*
|
||||
* Don't ask for keyboard input on sender end.
|
||||
*/
|
||||
#define FLAG_NOKBD 0x0080
|
||||
|
||||
/**
|
||||
* Streaming mode: allow receiver to join a running transmission
|
||||
*/
|
||||
#define FLAG_STREAMING 0x0100
|
||||
|
||||
#endif
|
||||
203
utils/multicast/udpc-protoc.h
Normal file
203
utils/multicast/udpc-protoc.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef UDPC_PROTOC_H
|
||||
#define UDPC_PROTOC_H
|
||||
|
||||
#include "udpcast.h"
|
||||
|
||||
#define MAX_BLOCK_SIZE 1456
|
||||
#define MAX_FEC_INTERLEAVE 256
|
||||
|
||||
/**
|
||||
* This file describes the UDPCast protocol
|
||||
*/
|
||||
enum opCode {
|
||||
/* Receiver to sender */
|
||||
|
||||
CMD_OK, /* all is ok, no need to retransmit anything */
|
||||
CMD_RETRANSMIT, /* receiver asks for some data to be retransmitted */
|
||||
CMD_GO, /* receiver tells server to start */
|
||||
CMD_CONNECT_REQ, /* receiver tries to find out server's address */
|
||||
CMD_DISCONNECT, /* receiver wants to disconnect itself */
|
||||
|
||||
CMD_UNUSED, /* obsolete version of CMD_HELLO, dating back to the
|
||||
* time when we had little endianness (PC). This
|
||||
* opcode contained a long unnoticed bug with parsing of
|
||||
* blocksize */
|
||||
|
||||
/* Sender to receiver */
|
||||
CMD_REQACK, /* server request acknowledgments from receiver */
|
||||
CMD_CONNECT_REPLY, /* receiver tries to find out server's address */
|
||||
|
||||
CMD_DATA, /* a block of data */
|
||||
CMD_FEC, /* a forward-error-correction block */
|
||||
|
||||
CMD_HELLO_NEW, /* sender says he's up */
|
||||
CMD_HELLO_STREAMING, /* retransmitted hello during streaming mode */
|
||||
};
|
||||
|
||||
/* Sender says he's up. This is not in the enum with the others,
|
||||
* because of some endianness Snafu in early versions. However,since
|
||||
* 2005-12-23, new receivers now understand a CMD_HELLO_NEW which is
|
||||
* in sequence. Once enough of those are out in the field, we'll send
|
||||
* CMD_HELLO_NEW by default, and then phase out the old variant. */
|
||||
/* Tried to remove this on 2009-08-30, but noticed that receiver was printing
|
||||
* "unexpected opcode" on retransmitted hello */
|
||||
#define CMD_HELLO 0x0500
|
||||
|
||||
struct connectReq {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int capabilities;
|
||||
unsigned int rcvbuf;
|
||||
};
|
||||
struct retransmit {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int sliceNo;
|
||||
int rxmit;
|
||||
unsigned char map[MAX_SLICE_SIZE / BITS_PER_CHAR];
|
||||
};
|
||||
struct ok {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int sliceNo;
|
||||
} ok;
|
||||
|
||||
union message {
|
||||
unsigned short opCode;
|
||||
struct ok ok;
|
||||
|
||||
struct retransmit retransmit;
|
||||
|
||||
struct connectReq connectReq;
|
||||
|
||||
struct go {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
} go;
|
||||
|
||||
struct disconnect {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
} disconnect;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct connectReply {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int clNr;
|
||||
int blockSize;
|
||||
int capabilities;
|
||||
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
|
||||
};
|
||||
|
||||
struct hello {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int capabilities;
|
||||
unsigned char mcastAddr[16]; /* provide enough place for IPV6 */
|
||||
short blockSize;
|
||||
};
|
||||
|
||||
union serverControlMsg {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
struct hello hello;
|
||||
struct connectReply connectReply;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct dataBlock {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int sliceNo;
|
||||
unsigned short blockNo;
|
||||
unsigned short reserved2;
|
||||
int bytes;
|
||||
};
|
||||
|
||||
struct fecBlock {
|
||||
unsigned short opCode;
|
||||
short stripes;
|
||||
int sliceNo;
|
||||
unsigned short blockNo;
|
||||
unsigned short reserved2;
|
||||
int bytes;
|
||||
};
|
||||
|
||||
struct reqack {
|
||||
unsigned short opCode;
|
||||
short reserved;
|
||||
int sliceNo;
|
||||
int bytes;
|
||||
int rxmit;
|
||||
};
|
||||
|
||||
union serverDataMsg {
|
||||
unsigned short opCode;
|
||||
struct reqack reqack;
|
||||
struct dataBlock dataBlock;
|
||||
struct fecBlock fecBlock;
|
||||
};
|
||||
|
||||
/* ============================================
|
||||
* Capabilities
|
||||
*/
|
||||
|
||||
/* Does the receiver support the new CMD_DATA command, which carries
|
||||
* capabilities mask?
|
||||
* "new generation" receiver:
|
||||
* - capabilities word included in hello/connectReq commands
|
||||
* - receiver multicast capable
|
||||
* - receiver can receive ASYNC and SN
|
||||
*/
|
||||
#define CAP_NEW_GEN 0x0001
|
||||
|
||||
/* Use multicast instead of Broadcast for data */
|
||||
/*#define CAP_MULTICAST 0x0002*/
|
||||
|
||||
#ifdef BB_FEATURE_UDPCAST_FEC
|
||||
/* Forward error correction */
|
||||
#define CAP_FEC 0x0004
|
||||
#endif
|
||||
|
||||
/* Supports big endians (a.k.a. network) */
|
||||
#define CAP_BIG_ENDIAN 0x0008
|
||||
|
||||
/* Support little endians (a.k.a. PC) ==> obsolete! */
|
||||
#define CAP_LITTLE_ENDIAN 0x0010
|
||||
|
||||
/* This transmission is asynchronous (no receiver reply) */
|
||||
#define CAP_ASYNC 0x0020
|
||||
|
||||
/* Sender currently supports CAPABILITIES and MULTICAST */
|
||||
#define SENDER_CAPABILITIES ( \
|
||||
CAP_NEW_GEN | \
|
||||
CAP_BIG_ENDIAN)
|
||||
|
||||
|
||||
#define RECEIVER_CAPABILITIES ( \
|
||||
CAP_NEW_GEN | \
|
||||
CAP_BIG_ENDIAN)
|
||||
|
||||
|
||||
#endif
|
||||
157
utils/multicast/udpcast.h
Normal file
157
utils/multicast/udpcast.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef UDPCAST_H
|
||||
#define UDPCAST_H
|
||||
|
||||
#include "socklib.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define BITS_PER_INT (sizeof(int) * 8)
|
||||
#define BITS_PER_CHAR 8
|
||||
|
||||
|
||||
#define MAP_ZERO(l, map) (memset(map, 0, ((l) + BITS_PER_INT - 1)/ BIT_PER_INT))
|
||||
#define BZERO(data) (memset((void *)&data, 0, sizeof(data)))
|
||||
|
||||
|
||||
#define RDATABUFSIZE (2*(MAX_SLICE_SIZE + 1)* MAX_BLOCK_SIZE)
|
||||
|
||||
#define DATABUFSIZE (RDATABUFSIZE + 4096 - RDATABUFSIZE % 4096)
|
||||
|
||||
int udpc_writeSize(void);
|
||||
int udpc_largeReadSize(void);
|
||||
int udpc_smallReadSize(void);
|
||||
int udpc_makeDataBuffer(int blocksize);
|
||||
int udpc_parseCommand(char *pipeName, char **arg);
|
||||
|
||||
int udpc_printLongNum(unsigned long long x);
|
||||
int udpc_waitForProcess(int pid, const char *message);
|
||||
|
||||
struct disk_config {
|
||||
int origOutFile;
|
||||
const char *fileName;
|
||||
char *pipeName;
|
||||
int flags;
|
||||
|
||||
struct timeval stats_last_printed;
|
||||
};
|
||||
|
||||
#define MAX_GOVERNORS 10
|
||||
|
||||
struct net_config {
|
||||
net_if_t *net_if; /* Network interface (eth0, isdn0, etc.) on which to
|
||||
* multicast */
|
||||
int portBase; /* Port base */
|
||||
int blockSize;
|
||||
int sliceSize;
|
||||
struct sockaddr_in controlMcastAddr;
|
||||
struct sockaddr_in dataMcastAddr;
|
||||
const char *mcastRdv;
|
||||
int ttl;
|
||||
int nrGovernors;
|
||||
struct rateGovernor_t *rateGovernor[MAX_GOVERNORS];
|
||||
void *rateGovernorData[MAX_GOVERNORS];
|
||||
/*int async;*/
|
||||
/*int pointopoint;*/
|
||||
struct timeval ref_tv;
|
||||
|
||||
enum discovery {
|
||||
DSC_DOUBLING,
|
||||
DSC_REDUCING
|
||||
} discovery;
|
||||
|
||||
/* int autoRate; do queue watching using TIOCOUTQ, to avoid overruns */
|
||||
|
||||
int flags; /* non-capability command line flags */
|
||||
int capabilities;
|
||||
|
||||
int min_slice_size;
|
||||
int default_slice_size;
|
||||
int max_slice_size;
|
||||
unsigned int rcvbuf;
|
||||
|
||||
int rexmit_hello_interval; /* retransmission interval between hello's.
|
||||
* If 0, hello message won't be retransmitted
|
||||
*/
|
||||
int autostart; /* autostart after that many retransmits */
|
||||
|
||||
int requestedBufSize; /* requested receiver buffer */
|
||||
|
||||
/* sender-specific parameters */
|
||||
int min_receivers;
|
||||
int max_receivers_wait;
|
||||
int min_receivers_wait;
|
||||
|
||||
int retriesUntilDrop;
|
||||
|
||||
/* receiver-specif parameters */
|
||||
int exitWait; /* How many milliseconds to wait on program exit */
|
||||
|
||||
int startTimeout; /* Timeout at start */
|
||||
|
||||
/* FEC config */
|
||||
#ifdef BB_FEATURE_UDPCAST_FEC
|
||||
int fec_redundancy; /* how much fec blocks are added per group */
|
||||
int fec_stripesize; /* size of FEC group */
|
||||
int fec_stripes; /* number of FEC stripes per slice */
|
||||
#endif
|
||||
|
||||
int rehelloOffset; /* how far before end will rehello packet will
|
||||
be retransmitted */
|
||||
};
|
||||
|
||||
struct stat_config {
|
||||
FILE *log; /* Log file for statistics */
|
||||
long bwPeriod; /* How often are bandwidth estimations logged? */
|
||||
|
||||
int statPeriod;
|
||||
int printUncompressedPos;
|
||||
};
|
||||
|
||||
#define NR_CLIENT_SOCKS 4
|
||||
|
||||
struct client_config {
|
||||
int socks[NR_CLIENT_SOCKS];
|
||||
struct sockaddr_in serverAddr;
|
||||
int clientNumber;
|
||||
int isStarted;
|
||||
pthread_t thread;
|
||||
int sender_is_newgen;
|
||||
};
|
||||
|
||||
void *rgInitGovernor(struct net_config *cfg, struct rateGovernor_t *gov);
|
||||
void rgParseRateGovernor(struct net_config *net_config, char *rg);
|
||||
void rgWaitAll(struct net_config *cfg, int sock, in_addr_t ip, int size);
|
||||
void rgShutdownAll(struct net_config *cfg);
|
||||
|
||||
/**
|
||||
* Answers whether given fd is seekable
|
||||
*/
|
||||
int udpc_shouldPrintUncompressedPos(int deflt, int fd, int pipe);
|
||||
|
||||
#define MAX_SLICE_SIZE 1024
|
||||
|
||||
#define DEFLT_STAT_PERIOD 500000
|
||||
|
||||
#ifndef DEBUG
|
||||
# define DEBUG 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
34
utils/multicast/util.h
Normal file
34
utils/multicast/util.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2 of
|
||||
the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MALLOC(type) ((type*)calloc(1, sizeof(type)))
|
||||
|
||||
/* bitmap manipulation */
|
||||
#define BITS_PER_ITEM(map) (sizeof(map[0])*8)
|
||||
#define MASK(pos,map) (1 << ((pos) % (BITS_PER_ITEM(map))))
|
||||
#define POS(pos,map) ((pos) / BITS_PER_ITEM(map))
|
||||
#define SET_BIT(x, map) (map[POS(x,map)] |= MASK(x,map))
|
||||
#define CLR_BIT(x, map) (map[POS(x,map)] &= ~MASK(x,map))
|
||||
#define BIT_ISSET(x, map) (map[POS(x,map)] & MASK(x,map))
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user