The defined BANDWIDTH in M3U8 and Linux tc - m3u8

I have the following m3u8 file
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-STREAM-INF:BANDWIDTH=87835,RESOLUTION=426x240,CODECS="avc1.640015"
240-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=177512,RESOLUTION=426x240,CODECS="avc1.640015"
240-28/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=267977,RESOLUTION=854x480,CODECS="avc1.640015"
480-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=499454,RESOLUTION=1280x720,CODECS="avc1.640015"
720-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=957645,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-34/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1903257,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-28/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3907896,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-22/media_0.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=8265879,RESOLUTION=1920x1080,CODECS="avc1.640015"
1080-16/media_0.m3u8
I want to run a Linux tc command to shape the bandwidth for each defined bandwidth in the previous file, but I am not sure the bandwidth value is bps or kbps.
for example, I want to run a tc command for the follows
#EXT-X-STREAM-INF:BANDWIDTH=87835,RESOLUTION=426x240,CODECS="avc1.640015"
240-34/media_0.m3u8
which command is right
tc qdisc add dev eth1 root tbf rate 87835kbit burst 16kbit latency 2ms
or
tc qdisc add dev eth1 root tbf rate 87835 burst 16kbit latency 2ms

Section 4.3.4.2. EXT-X-STREAM-INF of the HLS RFC says
BANDWIDTH
The value is a decimal-integer of bits per second. It represents
the peak segment bit rate of the Variant Stream.
So it's bps and you would just pass 87835 as a rate param for your tc command.
Depending on what you want to do, just be aware that it is defined as the peak bit rate and not the average bit rate.

Related

Tcl http POST - payload gets separated from headers when sent over wlan0 on rPi

I am using ::http::geturl -query to issue an HTTP POST request with a small json payload to an ESP8266 (a 3rd party commercial device) from a rPi. It works when sent over eth0 but fails when sent over wlan0. tcpdump shows that sent over eth0, the message is sent as a single packet but when sent over wlan0 the payload is being split from the headers and sent in a second packet. The ESP8266 most likely due to having overly simple implementation of its packet receivers and/or http server doesn't appear to handle this splitting. It issues a 200 OK response after receiving the packet containing the headers and doesn't process the payload part of the request.
Experimentally I composed the same request message text being sent by ::http::geturl and sent it over wlan0 using nc; it was sent as a single packet and was successfully processed by the ESP8266.
Does anyone happen to know why sending the request using ::http over wlan0 is ending up with this split message, and what if anything can be done to prevent it?
Code fragment:
set s [::http::geturl http://$ip/con?com=cli -query $data -type application/json]
set r [::http::ncode $s]
::http::cleanup $s
Raspbian package versions:
tcl8.6 8.6.9+dfsg-2
tcllib 1.19-dfsg-2
tcl_platform(engine) = Tcl
tcl_platform(machine) = armv7l
tcl_platform(os) = Linux
tcl_platform(osVersion) = 5.4.79-v7+
$ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.101 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::ed38:71ab:13af:ae30 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:26:bf:94 txqueuelen 1000 (Ethernet)
From /proc/cpuinfo:
Hardware : BCM2835
Revision : a020d3
Model : Raspberry Pi 3 Model B Plus Rev 1.3
$ uname -a
Linux raspberrypi 5.4.79-v7+ #1373 SMP Mon Nov 23 13:22:33 GMT 2020 armv7l GNU/Linux
Tcl's http package flushes the headers to the socket (i.e., performs an actual write()/send()) between writing the headers and the body of a query. For any correct implementation of an HTTP server this is fineā€¦ but you're not working with that. For some reason, the wlan and eth drivers in the OS kernel have different policies for what to do with that case, with the eth driver deciding to wait a bit before sending; Tcl definitely doesn't configure this aspect of sockets at all, staying with the system defaults. (I don't know how to configure the OS defaults.)
You can always take a copy of the http code and comment out the flush. It's this one:
https://core.tcl-lang.org/tcl/artifact/d9f8dc4bd7211a37?ln=1463
line 1463: flush $sock
There's a Download button/link at the top of the page for that exact version of that file (it's changed only very slightly from the one in your version of Tcl and should be compatible provided you source the file explicitly before doing any package require calls).

Changing MAC address for wifi interface in OpenWrt Chaos Calmer 15.05.1

I have configured one OpenWrt (lets call it child) to boot from sd card which has the firmware and software re-imaged from another OpenWrt (lets call it maker) as per following: http://labs.mediatek.com/forums/posts/list/3619.page#p7191.
Everything works fine except for the issue where wlan interface of child and maker are showing the same MAC address, the one of maker. Due to this I can connect to only one of them if they both are in AP mode.
I have tried giving 'macaddr' option in 'wifi-device', 'wifi-iface' but nothing works. I have also tried setting hardware address using command:
ifconfig ra0 hw ether 'XX:XX:XX:XX:XX:XX'
but this gives me error
ifconfig: SIOCSIFHWADDR: Operation not supported
I can see that the mac address is picked from
/sys/class/net/ra0/address
where ra0 is the interface name but its a read only file and is not there on sd card (atleast with the given path)
The mac address of the parent has to be on the sd card but can't find it using grep atleast.
So I would appreciate any help here, either in changing the address on sd card post imaging or override it in system startup.
Thanks
You can take a look on the calibration data in the "art" partition.If your MAC address is stored in it then you can change it.
root#OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00fc0000 00010000 "firmware"
mtd2: 00120000 00010000 "kernel"
mtd3: 00ea0000 00010000 "rootfs"
mtd4: 00c60000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "art"
So my one is /dev/mtd5 . Now I will check the calibration data inside
cat /dev/mtd5 > art.img
hexdump art.img
My wifi MAC address is 04:F0:21:07:7C:EC .After running hexdump art.img it shows
0001000 0202 04f0 2107 7cec 0020 2020 0030 6530
I need to use a software application to modify art.img ,change "04f0 2107 7cec" to new MAC address
Then the final step is :copy the edited art.img to /dev/mtd5
cat art.img > /dev/mtd5
Thanks for the help.
It seems that for mediatek linkit 7688, the MAC is stored in /dev/mtd2. Ideally this is a ROM partition and should not be affected on booting from SD card or raw flash.
But I found that upon boot it caches the same under /lib/firmware/mt7628.eeprom file which also gets copied on preparing sd card from a linkit.
So when I boot second linkit from sd card it considers the first linkit cache as its own /dev/mtd2 cache and thus the problem.
To solve this, after the sd card image is prepared, remove the file /mnt/upper/lib/firmware/mt7628.eeprom and make a symlink to /overlay-boot/upper/lib/firmware/mt7628.eeprom where /mnt is sd card mount location and overlay-boot is raw flash mount location

Network simulator - reading packets from file

I would like to ask if it is possible add some packet file like .pcap or .txt (packet statistic) to ns input. For example, if I want insert some packets to device interface.
Is it possible with ns2 / ns3?
Thank you
yes, it is possible with ns2.. not sure about ns3.. in order to do it in ns2, you need to enable 'emulation' in ns2.
to emulate ns2 --
1. in terminal.. switch to root mode
2. move to directory 'ns-2.35' in your ns2 installation.
3. run 'make nse'
4. run './configure'
and Emulation is activated in ns2.
now in you tcl file
1. create a Tap Agent like 'set tap1 [new Agent/Tap]'.
2. crate a Network Object like ' set nob [new Network/Pcap/File];
3. provide the path to Pcap file like' $nob open readonly Real/xplico_youtube_mail.pcap'
the file is located in ns-2.35 folder in given path.
4. in Tap Agent, provide network agent as network.. $tap1 network $nob
$ns attach-agent $node_(0) $tap1;
5. connect the Tap to other node.. and its done.

nmap warning: giving up on port because retransmission cap hit (2)

I am trying to scan a large set of domain names using nmap. I used the following command:
Nmap -PN -p443 -sS -T5 -oX out.xml -iL in.csv
I get the following warning:
Warning: xx.xx.xx.xx giving up on port because retransmission cap hit (2).
Why does this happen? How to resolve the issue ?
The option -T5 instructs nmap to use "insane" timing settings. Here's the relevant part of the current source code that illustrates what settings this implies:
} else if (*optarg == '5' || (strcasecmp(optarg, "Insane") == 0)) {
o.timing_level = 5;
o.setMinRttTimeout(50);
o.setMaxRttTimeout(300);
o.setInitialRttTimeout(250);
o.host_timeout = 900000;
o.setMaxTCPScanDelay(5);
o.setMaxSCTPScanDelay(5);
o.setMaxRetransmissions(2);
}
As you can see, the maximum number of retransmissions is 2. The warning you saw gets printed when there is a non-default cap on the number of retransmissions (set with -T5, -T4, or manually with --max-retries), and that cap is hit.
To avoid this problem, try scaling back your timing settings. -T4 is still very fast, and should work for nearby networks. -T3 is the default. If you are certain that your latency and bandwidth are not a problem, but that you may be dropping packets due to faulty hardware, you can manually set --max-retries to a higher value, and keep the rest of the -T5 settings.
I had the same problem and changing T parameter and --max-retries didn't changed anything.
The problem for me was my network adapter in VirtualBox was configured asNAT and notbridge.
It maybe happen because the virtual card is satured by all the packet.
This configuration solve the problem for my case.

IRCD-hybrid Connections Limited at 4026

I'm running an Ubuntu Server 12.04 instance on EC2, with an installation of IRCD-hybrid 7.2 on it. Right now, I'm trying to load test the server by making a bunch on connections and seeing how much the server can handle. I have a script that connects to the room.
My problem is that I can get 4026 connections in the server maximum. My other socket connections just don't seem to work. I have the max clients set to 100k just to be safe and 50k for max number per ip.
When i run
sysctl fs.file-nr -> fs.file-nr = 4576 0 1513750
Also, my ulimits have been set:
ulimit -S -> 65536
My ulimit -n is 1024, but since I can get 4026 connections, I don't see how that's affecting it.
ulimit -n -> 1024
Memory and CPU are also nowhere even close to maximum when I run into this.
My code is this:
import random
import sys
import socket
import string
import time
n = ''.join(random.choice(string.letters) for i in xrange(40))
HOST="<MYHOST IS HERE>"
PORT=6666
NICK=n
IDENT=n
REALNAME=n
readbuffer=""
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s %s :%s\r\n" % (IDENT, HOST, REALNAME, REALNAME))
s.send('JOIN #foobar\r\n')
while 1:
readbuffer=readbuffer+s.recv(1024)
temp=string.split(readbuffer, "\n")
readbuffer=temp.pop( )
for line in temp:
line=string.rstrip(line)
line=string.split(line)
if 'PRIVMSG' in line:
print line
if(line[0]=="PING"):
s.send("PONG %s\r\n" % line[1])
Is there a setting on ircd-hybrid that sets this? The terminal window says that "Server is full" when I try to connect with a regular client and I already have 4026 connections.
There are two types of ulimit, hard and soft. A ulimit on a particular resource may be increased up to the hard limit by the process. However it maybe listed no further.
On my box (ubuntu 12.04), the soft file descrption is 1024), but the hard limit is 4096
$ulimit -n
1024
moment#moment:~/tmp 20:26:04 0
$ulimit -n -H
4096
moment#moment:~/tmp 20:26:16 0
$ulimit -n -S
1024
It's entirely plausible that your irc server is increasing up to this hard limit.
A horrible hack to increase your ulimit temporarily works like this.
sudo su
ulimit -n 10000
su USERNAME
Long term you would need to increase the limit system wide or , preferably, increase the ulimit for just the process you are running. For daemons I normally do this using the ulimit instruction in upstart configuration files.
In general strace can be useful for debugging problems like this (this will probably show an earlier call to increase the file ulimit)

Resources