summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/vlc_stream_rtp
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-03-09 08:01:29 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-03-09 08:01:29 +0000
commitdf7638b302622c3df7dab67c966e6ea3498c83e6 (patch)
tree36acf623004b3cc79826be317fdfc20f214ef404 /kpov_judge/tasks/vlc_stream_rtp
parent060f54de39a45e4efbc1f82d7aef20732b5b1fc7 (diff)
finished, not tested task and task_check for vlc_stream_rtp.
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@285 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/vlc_stream_rtp')
-rw-r--r--kpov_judge/tasks/vlc_stream_rtp/task.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/kpov_judge/tasks/vlc_stream_rtp/task.py b/kpov_judge/tasks/vlc_stream_rtp/task.py
index 12c0c53..76c1589 100644
--- a/kpov_judge/tasks/vlc_stream_rtp/task.py
+++ b/kpov_judge/tasks/vlc_stream_rtp/task.py
@@ -11,7 +11,7 @@ Postavi navidezni računalnik SimpleArbiter z diska simpleArbiter. Posodobi dato
preveri za posodobitve in naloži VLC.
Posnemi ali kako drugače ustvari film ter poskrbi, da bo film dostopen na lokalnem omrežju prek RTP z imenom toka TOK na naslovu NASLOV. Računaj, da bodo film lahko videli tvoji sošolci. Kršenje avtorskih pravic je pri reševanju te naloge
strogo prepovedano.
-"""
+""",
'en':u"""
Set up a virtual computer SimpleArbiter from the simpleArbiter disk.
Read a movie title and stream name for stream TOK onto simpleArbiter. Film or
@@ -44,31 +44,45 @@ networks = { 'test-net': {'public': True} }
params_meta = {
'NASLOV': {'descriptions': {'si': 'RTP multicast IP naslov'}, 'w': False, 'public':True, 'type': 'stream_name', 'generated': True},
- 'TOK': {'descriptions': {'si': 'Naslov toka'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+ 'PORT': {'descriptions': {'si': 'RTP VRATA'}, 'w': False, 'public':True, 'type': 'port', 'generated': True},
+ 'TOK': {'descriptions': {'si': 'Naslov (ime) toka'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
}
def task(NASLOV, TOK):
import pexpect
- # sA
- # make sure NM is not handling eth0
- # sB
- # check whether NM is handling eth0
+ results = dict()
results['ps'] = pexpect.run('ps xa')
- results['tcpdump'] = pexpect.run('tcpdump')
+ results['tcpdump_hex'] = pexpect.run('sudo /usr/sbin/tcpdump -x -c 2 dst host 239.255.255.255 and port 9875'.format(NASLOV))
+ results['tcpdump'] = pexpect.run('sudo /usr/sbin/tcpdump -c 8 dst host {}'.format(NASLOV))
return results
def gen_params(user_id, params_meta):
params = dict()
r = random.Random(user_id)
net = kpov_random_helpers.IPv4_net_gen(r, min_hosts = 16,
- public=True, multicast=True)
+ local=True, multicast=True)
params['NASLOV'] = kpov_random_helpers.IPv4_addr_gen(r, net, 1)[0]
+ params['PORT'] = str(r.randint(5000, 6000))
params['TOK'] = kpov_random_helpers.hostname_gen(r)
return params
def task_check(results, params):
import re
- print results
+ packs = results['tcpdump_hex'].split('> 239.255.255.255.9875: UDP, length')
+ p1 = packs[1]
+ p1_l = p1.split('\n')
+ p1_d = p1_l[1:-1]
+ p1_s = ""
+ for i in p1_d:
+ p1_s += "".join([j for j in i.split(' ')[1:]])
+ sname = "".join([ hex(ord(i))[2:] for i in params['TOK']])
+ if p1_s.find(sname) > 2:
+ score += 5
+ s = "IP [^ ]* > {}.{}: UDP, length [0-9]+\n\r".format(
+ re.escape(params['NASLOV']),
+ params['PORT'])
+ if re.search(s, results['tcpdump']):
+ score += 5
return score
def prepare_disks(templates, params):