pcherenkov / udpxy Goto Github PK
View Code? Open in Web Editor NEWlightweight network-traffic relay daemon
lightweight network-traffic relay daemon
# # Copyright 2008-2018 Pavel V. Cherenkov ([email protected]) # # This file is part of udpxy. # # udpxy 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, either version 3 of the License, or # (at your option) any later version. # # udpxy 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 udpxy. If not, see <http://www.gnu.org/licenses/>. # Summary -------------- udpxy is a UDP-to-HTTP multicast traffic relay daemon: it forwards UDP traffic from a given multicast subscription to the requesting HTTP client. udpxy is released under GPL v.3 Project status -------------- udpxy has not been extended or supported for 4+ years, having been replaced by Gigapxy - a superior enterprise-oriented product. Please see more info at <http://gigapxy.com>, thank you. Building and installing -------------- Untar the *.tgz source distribution into a directory of your choice by running tar -xzvf udpxy.X.Y-ZZ.tgz or gzip -dc udpxy.X.Y-ZZ.tgz | tar -xvf - Make sure GNU make and gcc are available (gcc 3.x and up should work, lower versions are not guaranteed to build the source correctly); for compilers other than gcc alterations to Makefile might be needed. Running 'make' without a target will build the 'release' version of udpxy (no asserts, no debug symbols, verbose mode on). Other make targets are: debug (asserts, debug symbols, verbose mode on); lean (no asserts, no debug symbols, verbose mode off); rdebug (same as 'release' but with debug symbols); ldebug (same as 'lean' but with debug symbols); Once the make has succeeded, the udpxy executable file could be copied to a location of one's choice and run from there - no additional installation steps are required. udpxy can be started with a number of configuration parameters, such as listening address/port, multicast interface name, etc. A brief usage summary is provided when udpxy is invoked from command line without parameters. HTTP commands -------------- udpxy responds to HTTP (GET) commands to receive data from a dedicated multicast group and forward it to the initiating (HTTP) connection. The command to relay traffic is in the format as below: http://<address>:<port>/<cmd>/[src_address@]<mgroup_address><sep><mgroup_port>/ [SEP] ::= :|%|~|+|-|^ i.e: http://ip:port/cmd/mgroup_address:mgroup_port/ http://ip:port/cmd/mgroup_address%mgroup_port/ http://ip:port/cmd/mgroup_address~mgroup_port/ ...... http://ip:port/cmd/mgroup_address^mgroup_port/ are acceptable and should all work in the same manner. cmd ::= udp | rtp where ip and port match the listening address/port combination of udpxy, and [src_address@]mgroup_address:mgroup_port identify the multicast group (and optional source) to subscribe to. Using 'udp' command will instruct udpxy to probe for known types of payload (such as MPEG-TS and RTP over MPEG-TS); using 'rtp' makes udpxy assume RTP over MPEG-TS payload, thus skipping the probes. udpxy will start a 'client' process for each new relay request as long as their number would not exceed a pre-set maximum (see usage summary). udpxy also supports a few additional HTTP requests, such as: http://address:port/status/ - to display basic daemon's statistics http://address:port/restart/ - to close all active connections and restart Payload types and handling -------------- udpxy recognizes MPEG-TS and RTP (over MPEG-TS) payloads within relayed packets; if udpxy encounters RTP payload it automatically 'translates' it to MPEG-TS so that media players not recognizing RTP on TCP could still play back the stream. So far, no translation is performed for other payload types. Recording MPEG traffic -------------- udpxy (in builds >0.33) includes functionality to record captured traffic as raw MPEG-TS stream into a file. This functionality is enabled through udpxrec: a bundled-in application that is linked together with udpxy (as one executable). udpxrec is invoked by a symbolic link (named udpxrec) to the udpxy executable (NB: do not rename udpxy executable). udpxrec creates MPEG files encapsulating MPEG-TS segments; most media players will *NOT* play such files; to make them playable the stream must be transcoded to MPEG-PS; vlc knows how to do such transcoding, here is a command-line example: vlc input-ts.mpg --sout="#std{access=file,mux=ps,dst=out-ps.mpg}" The resulting PS file can be played back by most media players. Portability -------------- udpxy was written to run on 'POSIX-compliant' systems; so far all builds have been tested to build and run on Linux 2.4, 2.6, 3.x (IA32, ARM) and *some* (but not all) on HP-UX 11.11 (PA-RISC 1.1, 2.0w). Build 12 of version 1.0 (Chipmunk) was ported to compile under FreeBSD 7.1 using GNU make 3.8; later builds have been tested to compile under later versions of FreeBSD (up to 9.0); Certain builds have been ported to build under cygwin; cygwin is *NOT* considered to be a fully supported platform yet there is an ongoing effort to make udpxy run on it as well. Environment variables -------------- udpxy utilizes the following environment variables to compliment its command-line options; the variables are considered for the options that most people would not need to change too often (or simply inconvenient to use from the command line). NB: If there is a command-line switch that would intersect in functionality with an environment variable, the switch *always* has the higher priority. UDPXY_RCV_TMOUT - timeout (sec) on the inbound data stream (multicast), default=5; UDPXY_DHOLD_TMOUT - timeout (sec) to hold buffered data before sending/flushing to client(s), default=1; UDPXY_SREAD_TMOUT - timeout (sec) to read from the listening socked (handling HTTP requests), default=1; UDPXY_SWRITE_TMOUT - timeout (sec) to write to the listening socked (handling HTTP requests), default=1; UDPXY_SSEL_TMOUT - timeout (sec) to select(2) in server loop (unused if pselect(2) is employed), default=30; UDPXY_LQ_BACKLOG - size of the listener socket's backlog, default=16; UDPXY_SRV_RLWMARK - low watermaek on the receiving (m-cast) socket, default=0 (not set); UDPXY_SSOCKBUF_NOSYNC - do not sync inbound (UDP) socket's buffer size (with value set by -B), default=1 (sync); UDPXY_DSOCKBUF_NOSYNC - do not sync outbound (TCP) socket's buffer size (with value set by -B), default=1 (sync); UDPXY_TCP_NODELAY - disable Nagle algorithm on the newly accepted socket (faster channel switching), default=1; UDPXY_HTTP200_FTR_FILE - append contents of the given file to the HTTP 200 response, default=none; UDPXY_HTTP200_FTR_LN - append the text (line) to the HTTP 200 response, default=none; UDPXY_ALLOW_PAUSES - if blocked on a write, keep reading data until the buffer (-B size) is full, default=disabled; UDPXY_PAUSE_MSEC - allow only N milliseconds of reading data when blocked on a write. UDPXY_CONTENT_TYPE - specify custom Content-Type in HTTP responses. --EOF--
hi, not sure if this is a problem with udpxy or something else, but thought i'll report it here.
my ISP provides an iptv stream and when i use udpxy, i have each minute or 2 some lag for 1-2 seconds.
is there some way to configure udpxy that it buffers more? i use kodi with iptvsimple.
in the kodi.log i have some of those:
2023-04-08 21:39:05.325 T:8953 warning : OutputPicture - timeout waiting for buffer
2023-04-08 21:41:04.008 T:8951 info : CAEStreamParser::TrySyncAC3 - AC3 stream detected (2 channels, 48000Hz)
2023-04-08 21:42:04.894 T:8953 warning : OutputPicture - timeout waiting for buffer
2023-04-08 21:48:03.380 T:8951 info : CAEStreamParser::TrySyncAC3 - AC3 stream detected (2 channels, 48000Hz)
2023-04-08 21:49:03.583 T:8951 info : CAEStreamParser::TrySyncAC3 - AC3 stream detected (2 channels, 48000Hz)
2023-04-08 21:49:05.214 T:8953 warning : OutputPicture - timeout waiting for buffer
2023-04-08 21:51:04.880 T:8953 warning : OutputPicture - timeout waiting for buffer
2023-04-08 21:54:03.246 T:8951 info : CAEStreamParser::TrySyncAC3 - AC3 stream detected (2 channels, 48000Hz)
2023-04-08 21:54:04.808 T:8953 warning : OutputPicture - timeout waiting for buffer
on my router the log looks like:
2023-04-08 22:36:25.070137 CEST S(24170) Received TSTAT={ sender=[15445], bytes=[1316000.000000], seconds=[1.000000] }
2023-04-08 22:36:25.070193 CEST S(24170) Updated context for pid=[15445]; [1285.2] Kb/sec
2023-04-08 22:36:25.070245 CEST S(24170) Waiting for input from [2] fd's, NO timeout
2023-04-08 22:36:25.750613 CEST S(24170) No children exited since last check
2023-04-08 22:36:25.750729 CEST S(24170) Got 1 requests
2023-04-08 22:36:25.750787 CEST S(24170) Received TSTAT={ sender=[15445], bytes=[1316000.000000], seconds=[0.000000] }
2023-04-08 22:36:25.750854 CEST S(24170) Updated context for pid=[15445]; [inf] Kb/sec
2023-04-08 22:36:25.750911 CEST S(24170) Waiting for input from [2] fd's, NO timeout
not sure if that inf kb/sec is correct
It will be nice to see that udpxy set by default TTL for multicast and unicast sockets to 1, to not allow use it outside LAN.
And nice to see option to able to increase it.
For unicast sockets:
int ttl = 1; /* max = 255 */
setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
This for multicast:
u_char ttl = 1; /* range: 0 to 255, default = 1 */
setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
Now, there is 1.0-24.1 on my router, Dozens of channels can be switched freely and played perfectly, only one channel cannot be played, there will be such an error message in the background
However, the igmp address of this channel is playable, such as rtp: //239.3.1.209: 8052
rtp: //239.3.1.209: 8052 can play
http://192.168.123.1:2333/rtp/239.3.1.209:8052 cannot be played
All other channels are normal, but this one is problematic. The error is:
Mar 10 14:39:31 udpxy[10557]: setup_mcast_listener: bind: Address already in use
Mar 10 14:39:31 udpxy[10558]: setup_mcast_listener: bind: Address already in use
update
I found that there are other programs occupying 8052 port
I want to know from udpxy's perspective, is there any way to solve this problem?
Hello!
I wonder, will be ssm/imr supported in udpxy someday? Last time i saw this was asked, it was 2012, maybe something changed in roadmap.
There is an issue with source specific multicast (SSM) support, that source address is uninitialized if SSM unspecified.
Which may cause mcast listen with wrong parameter since set_multicast() rely on following condition (netop.c, line 158):
if (s_in_addr->s_addr != 0)
It will result in socket timeout if source address is unspecified and uninitialized.
Hello,
please, is there a way to block status html page?
Thank You
Hello,
This is rather feature request than a bug.
Multiple providers deliver their multicast as IGMP v3 SSM (source specific multicast) for example:
rtp://[email protected]:10000
and that can't be relayed by udpxy at all.
Those SSM multicasts are causing "issues" as many of the software just don't support those at all, tvheadend for example, but support http streams without issue.
There are workarounds by using ffmpeg to translate ssm multicast to fifio pipe but those are CPU intensive.
Having udpxy be able to convert ssm to http stream would be quite nice.
I am using udpxy on mt7621 router with multicast renew enabled. My iptv provider requires the client send multicast report packet periodicity.
After enabling the feature, packet loss causes VLC video lag periodicity.
Attached logs from VLC:
main debug: resampling stopped (drift: 485 us)
main debug: picture might be displayed late (missing 4 ms)
ts warning: discontinuity received 0x7 instead of 0x0 (pid=4113)
ts warning: discontinuity received 0x4 instead of 0xe (pid=4113)
main debug: picture might be displayed late (missing 1 ms)
main debug: auto hiding mouse cursor
main warning: picture is too late to be displayed (missing 25 ms)
main warning: picture is too late to be displayed (missing 49 ms)
main debug: picture might be displayed late (missing 9 ms)
main debug: auto hiding mouse cursor
ts warning: discontinuity received 0xc instead of 0x0 (pid=4113)
ts warning: discontinuity received 0x1 instead of 0xf (pid=4352)
main debug: picture might be displayed late (missing 9 ms)
main debug: picture might be displayed late (missing 17 ms)
main debug: auto hiding mouse cursor
main debug: auto hiding mouse cursor
Hi,
Using a Debian 7 x64 machine (yes, quite old but working) I detected that the double call to the setsockopt SO_REUSEPORT fails:
Line 236 in cdb8106
So, I suggest to improve the code or include a configurable alternive, like with Environment variables.
I compiled it disabling this and then it works in this server.
I hope this helps to improve this tool.
Regards.
It running find on Android 6 but I got this error when running on Android 4.4
# udpxy -vT -a wlan0 -m eth0 -p 8888
Added client: pid=[17586], maddr=[239.1.1.15], mport=[8064], saddr=[192.168.100.2], sport=[26015]
setup_mcast_listener: setsockopt SO_REUSEPORT: Protocol not available
resolved. please delete
Hello and thanks for your work.
I have a problem with udpxy running on my OpenWrt router :
I have a multicast stream provided by my ISP : I get this stream on my LAN with IGMPproxy on my router (i have IGMPsnooping enabled on my entire lan).
But I would like to add udpxy to convert multicast to unicast when I need (through my home VPN per exemple).
So udpxy is configured with sources as my LAN router IP but I have a problem :
If the multicast stream is active on the lan (on another machine for exemple), udpxy works and I can get the unicast stream of this multicast from udpxy.
But if this multicast stream is not active, udpxy can't access this stream.
Also if I stop the multicast stream in all my machines on my LAN, the unicast stream from udpxy stops after about 10 seconds.
It looks as if udpxy can't make the subscription to multicast.
Do you know why it doesn't work the way I want ?
Thanks
I want to update FreeBSD net/udpxy port to the latest version.
Under FreeBSD 12.1 with clang 8 from base system I get this:
cc -W -Wall -Werror --pedantic -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DUDPXREC_MOD -DNDEBUG -DTRACE_MODULE -c mkpg.c -o mkpg.o
mkpg.c:93:29: error: address of array 'client->tail' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
client->tail ? client->tail : "",
~~~~~~~~^~~~ ~
mkpg.c:100:25: error: address of array 'client->tail' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
if (client->tail && (ssize_t)strlen(client->tail) > max_cli_tail)
~~~~~~~~^~~~ ~~
2 errors generated.
The same error with clang 9.
This problem appears again:
util.c: In function 'get_sysinfo':
util.c:1082:61: error: ' ' directive output may be truncated writing 1 byte into a region of size between 0 and 255 [-Werror=format-truncation=]
1082 | (void) snprintf (s_sysinfo, sizeof(s_sysinfo)-1, "%s %s %s",
| ^
util.c:1082:16: note: 'snprintf' output between 3 and 768 bytes into a destination of size 255
1082 | (void) snprintf (s_sysinfo, sizeof(s_sysinfo)-1, "%s %s %s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1083 | uts.sysname, uts.release, uts.machine);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
s_sysinfo was extended to 256 before in 2cdb00f, but this is not enough for gcc9.
I suppose this should be reworked somehow.
Also seems like snprintf() always null terminates the buffer. Is such code really needed?
https://github.com/pcherenkov/udpxy/blob/master/chipmunk/util.c#L1081
I'm not sure this problem is related to udpxy, but it could be.
On a weak internet connection, I set a 30 second buffered time in the vlc (the stream is provided by udpxy, of course) and I find that once the buffer is loaded and the vlc starts playing, the 30 second buffered video is also interrupted.
I would expect playback to be smooth for at least the first 30 seconds.
I tried configuring udpxy parameterization as well as linux sysctl values but it didn't help.
udpxy -B 4K -H 30 -R -1
net.core.wmem_max = 1677721600
net.core.rmem_max = 1677721600
net.core.wmem_default = 167772160
net.core.rmem_default = 167772160
udpxy-1.0-25.0 has error when compile on OpenBSD 6.8 uses gmake.
gmake[1]: Entering directory '/home/builder/udpxy-1.0-25.0/chipmunk'
cc -W -Wall -Werror --pedantic -DUDPXREC_MOD -DNDEBUG -DTRACE_MODULE -c util.c -o util.o
util.c:857:16: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to
9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
if( dval > LONG_MAX || dval < LONG_MIN )
~ ^~~~~~~~
/usr/include/sys/limits.h:63:19: note: expanded from macro 'LONG_MAX'
# define LONG_MAX 0x7fffffffffffffffL
^~~~~~~~~~~~~~~~~~~
1 error generated.
gmake[1]: *** [Makefile:106: util.o] Error 1
gmake[1]: Leaving directory '/home/builder/udpxy-1.0-25.0/chipmunk'
gmake: *** [Makefile:110: release] Error 2
obsd68$
Version 1.0.24.1 compile successfully.
Hi! Appreciate for your great work.
I would like to know if there is a way to make udpxy listen both on ipv4&&ipv6 request?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.