[Sumover-dev] [svn commit] r4773 - in vic/branches/mpeg4: net tcl
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Mon Apr 12 00:57:57 BST 2010
Author: douglask
Date: Mon Apr 12 00:57:57 2010
New Revision: 4773
Modified:
vic/branches/mpeg4/main.cpp
vic/branches/mpeg4/net/net-ip.cpp
vic/branches/mpeg4/net/net-ipv6.cpp
vic/branches/mpeg4/tcl/cf-network.tcl
vic/branches/mpeg4/tcl/ui-resource.tcl
vic/branches/mpeg4/vic.1
Log:
For the data sockets only, set the size of the send/recv IP buffers.
Introduced command-line -b switch (which is what openMASN vic also has)
to explicitly set the buffer size
Modified: vic/branches/mpeg4/main.cpp
==============================================================================
--- vic/branches/mpeg4/main.cpp (original)
+++ vic/branches/mpeg4/main.cpp Mon Apr 12 00:57:57 2010
@@ -136,7 +136,7 @@
the connection identifier (an even number between 1024-65536).\n\n\
For more details see:\n\
\thttp://www-mice.cs.ucl.ac.uk/multimedia/software/vic/faq.html\n\n\
-Options: vic [-HPs] [-A nv|ivs|rtp] [-B maxbps] [-C conf]\n\
+Options: vic [-HPs] [-A nv|ivs|rtp] [-B maxbps] [-b netBufferSize] [-C conf]\n\
[-c ed|gray|od|quantize] [-D device] [-d display]\n\
[-f bvc|cellb|h261|jpeg|nv|mpeg4|h264] [-F maxfps] [-i ifAddr ]\n\
[-I channel] [-K key ] [-L flowLabel (ip6 only)] [-l (creates log file)]\n\
@@ -525,7 +525,7 @@
// Option list; If letter is followed by ':' then it takes an argument
const char* options =
- "A:B:C:c:D:d:f:F:HI:i:j:K:lL:M:m:N:n:o:Pq:QrsST:t:U:u:vV:w:x:X:y";
+ "A:B:b:C:c:D:d:f:F:HI:i:j:K:lL:M:m:N:n:o:Pq:QrsST:t:U:u:vV:w:x:X:y";
/* process display and window (-use) options before initialising tcl/tk */
char buf[256], tmp[256];
const char *display=0, *use=0;
@@ -629,6 +629,10 @@
tcl.add_option("maxbw", optarg);
break;
+ case 'b':
+ tcl.add_option("netBufferSize", optarg);
+ break;
+
case 'C':
tcl.add_option("conferenceName", optarg);
break;
Modified: vic/branches/mpeg4/net/net-ip.cpp
==============================================================================
--- vic/branches/mpeg4/net/net-ip.cpp (original)
+++ vic/branches/mpeg4/net/net-ip.cpp Mon Apr 12 00:57:57 2010
@@ -118,6 +118,7 @@
virtual int dorecv(u_char* buf, int len, Address &from, int fd);
int open(const char * host, int port, int ttl);
int close();
+ void bufsize(int size = 1024 * 1024);
int localname(sockaddr_in*);
int openssock(Address & addr, u_short port, int ttl);
int disconnect_sock(int fd);
@@ -190,6 +191,11 @@
return (TCL_OK);
}
} else if (argc == 3) {
+ if (strcmp(argv[1], "bufsize") == 0) {
+ int size = atoi(argv[2]);
+ bufsize(size);
+ return (TCL_OK);
+ }
if (strcmp(argv[1], "loopback") == 0) {
char c = atoi(argv[2]);
if (setsockopt(ssock_, IPPROTO_IP, IP_MULTICAST_LOOP,
@@ -212,7 +218,7 @@
if (strlen(tcl.attr("ifAddr"))>1) {
(IPAddress&)local_ = tcl.attr("ifAddr");
local_preset_=1;
- }
+ }
if (open(argv[2], port, ttl) < 0)
tcl.result("0");
else
@@ -287,6 +293,59 @@
return (0);
}
+void IPNetwork::bufsize(int bufsize)
+{
+ int min_bufsize = 32;
+ int ret;
+ int s;
+#if defined WIN32 || WIN64 || defined(__APPLE__)
+ int ss = sizeof(s);
+#else
+ u_int ss = sizeof(s);
+#endif
+
+ if (ssock_ < 0 || rsock_ < 0) {
+ return;
+ }
+
+ s = bufsize;
+ do {
+ ret = setsockopt(ssock_, SOL_SOCKET, SO_SNDBUF,
+ (char *)&s, sizeof(s));
+ s /= 2;
+ } while (ret < 0 && s >= min_bufsize);
+
+ s = bufsize;
+ do {
+ ret = setsockopt(rsock_, SOL_SOCKET, SO_RCVBUF,
+ (char *)&s, sizeof(s));
+ s /= 2;
+ } while (ret < 0 && s >= min_bufsize);
+
+ s = 0;
+ if (getsockopt(ssock_, SOL_SOCKET, SO_SNDBUF, (char*) &s, &ss) < 0) {
+ perror("getsockopt(SO_SNDBUF)");
+ } else {
+ if (s < min_bufsize) {
+ fprintf(stderr,"Socket send buffer is only %d bytes.\n", s);
+ } else {
+ debug_msg("Socket send buffer is %d bytes.\n", s);
+ }
+ }
+
+
+ if (getsockopt(rsock_, SOL_SOCKET, SO_RCVBUF, (char*) &s, &ss) < 0) {
+ perror("getsockopt(SO_RCVBUF)");
+ } else {
+ if (s < min_bufsize) {
+ fprintf(stderr, "Socket receive buffer is only %d bytes.\n", s);
+ } else {
+ debug_msg("Socket receive buffer is %d bytes.\n", s);
+ }
+ }
+
+}
+
int IPNetwork::localname(sockaddr_in* p)
{
memset((char *)p, 0, sizeof(*p));
@@ -478,16 +537,6 @@
#endif
}
- /*
- * XXX don't need this for the session socket.
- */
- for (int bufsize = 1024 * 1024; bufsize >= 32 * 1024; bufsize /= 2) {
- if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize,
- sizeof(bufsize)) >= 0)
- {
- break;
- }
- }
return (fd);
}
@@ -593,16 +642,6 @@
exit(1);
#endif
}
- /*
- * XXX don't need this for the session socket.
- */
- for (int bufsize = 1024 * 1024; bufsize >= 32 * 1024; bufsize /= 2) {
- if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize,
- sizeof(bufsize)) >= 0)
- {
- break;
- }
- }
return (fd);
}
Modified: vic/branches/mpeg4/net/net-ipv6.cpp
==============================================================================
--- vic/branches/mpeg4/net/net-ipv6.cpp (original)
+++ vic/branches/mpeg4/net/net-ipv6.cpp Mon Apr 12 00:57:57 2010
@@ -231,6 +231,11 @@
return (TCL_OK);
}
} else if (argc == 5) {
+ if (strcmp(argv[1], "bufsize") == 0) {
+ int size = atoi(argv[2]);
+ //bufsize(size);
+ return (TCL_OK);
+ }
if (strcmp(argv[1], "open") == 0) {
/* __IPV6 use v6 lookup */
const char * host = argv[2];
Modified: vic/branches/mpeg4/tcl/cf-network.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/cf-network.tcl (original)
+++ vic/branches/mpeg4/tcl/cf-network.tcl Mon Apr 12 00:57:57 2010
@@ -32,7 +32,7 @@
proc net_open_ip { sessionType session dst } {
global V numLayers IPaddrFamily
- set layer 0
+ set layer 0
set c $V(class)
set dst [split $dst /]
set n [llength $dst]
@@ -97,6 +97,14 @@
warn "Problem opening $IPaddrFamily data socket"
exit 1
}
+
+ # for the data sockets only, set the
+ # size of the send/recv buffers
+ set netBufferSize [resource netBufferSize]
+ if {$netBufferSize > 0 } {
+ $dn bufsize $netBufferSize
+ }
+
$session data-net $dn
if { $sessionType != "nv" } {
if { $sessionType == "ivs" } {
@@ -122,8 +130,8 @@
set offset [lindex $oct 3]
set separator .
}
-
- while { $numLayers > $layer } {
+
+ while { $numLayers > $layer } {
incr port
incr layer
if { [$dn ismulticast] } { incr offset }
@@ -141,7 +149,7 @@
$cn open $base$separator$offset $port $ttl
$session ctrl-net $cn $layer
}
- }
+ }
}
#
Modified: vic/branches/mpeg4/tcl/ui-resource.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/ui-resource.tcl (original)
+++ vic/branches/mpeg4/tcl/ui-resource.tcl Mon Apr 12 00:57:57 2010
@@ -162,6 +162,7 @@
option add Vic.maxbw -1 startupFile
option add Vic.bandwidth 128 startupFile
option add Vic.iconPrefix vic: startupFile
+ option add Vic.netBufferSize [expr 1024*1024] startupFile
option add Vic.priority 10 startupFile
option add Vic.confBusChannel 0 startupFile
Modified: vic/branches/mpeg4/vic.1
==============================================================================
--- vic/branches/mpeg4/vic.1 (original)
+++ vic/branches/mpeg4/vic.1 Mon Apr 12 00:57:57 2010
@@ -856,6 +856,9 @@
to maximum transmission rate
.IP "\fBVic.bandwidth\fI (128)\fP"
the default initial setting of the bandwidth slider in kb/s
+.IP "\fBVic.netBufferSize\fI (1024*1024)\fP"
+The size in bytes for the send and receive IP data buffers; 0 causes
+vic to use the default size that the operating system sets.
.IP "\fBVic.iconPrefix\fI (vic:)\fP"
a string that is prefixed to the vic icon names
.IP "\fBVic.priority\fI (10)\fP"
More information about the Sumover-dev
mailing list