I'm working on a small web rtc framework on iOS and having difficulties with setRemoteDescription. I wrote my own SDP parser/writer and checked every aspect of it. Even thought the SDP looks fine, it always fails:
let sessionDescription = RTCSessionDescription(type: .answer, sdp: sdp)
pc.setRemoteDescription(sessionDescription) { error in
if let error = error {
// Always fails with "SessionDescription is NULL"
}
else {
...
}
}
The error is:
Error Domain=org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection) Code=-1 "SessionDescription is NULL." UserInfo={NSLocalizedDescription=SessionDescription is NULL.}
Here is the po of sessionDescription:
v=0
o=clientlib 10000 1 IN IP4 0.0.0.0
s=-
t=0 0
a=ice-lite
a=fingerprint:sha-512 C9:CE:DF:4A:9A:35:95:6F:94:BF:14:82:50:A2:73:97:54:97:5D:1D:7A:C1:B0:31:A7:44:92:4A:A5:F1:ED:22:EB:A1:D2:22:7B:6F:76:96:F1:95:97:2E:49:4E:B1:A4:61:AF:D9:9E:82:55:C8:55:EA:6E:2B:56:BE:55:C4:3C
a=msid-semantic: WMS *
a=group:BUNDLE 0
m=video 7 96 97 98 99 100 101 127 123 125 122 124 100
c=IN IP4 127.0.0.1
a=rtpmap:100 VP8/90000
a=fmtp:100 x-google-start-bitrate=1000
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:13 urn:3gpp:video-orientation
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=setup:active
a=mid:0
a=recvonly
a=ice-ufrag:jf3q436s5vhriv09
a=ice-pwd:s4sft4792k6gv49ml9psq9cantjt4hqj
a=candidate:udpcandidate 1 udp 1076558079 34.199.191.112 25738 typ host
a=candidate:tcpcandidate 1 tcp 1076302079 34.199.191.112 24688 typ host tcptype passive
a=end-of-candidates
a=ice-options:renomination
a=rtcp-mux
a=rtcp-rsize
Peer connection (pc) was created in a usual way:
let config = RTCConfiguration()
config.sdpSemantics = .unifiedPlan
let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil)
pc = peerConnectionFactory.peerConnection(with: config, constraints: constraints, delegate: self)
Is there any way to get more information about what's wrong with the sdp other than "SessionDescription is NULL"?
Any hints, ideas are appreciated.
I see a couple possible issues
Your m line contains RTP PayloadTypes that aren't defined. Change it to m=video 100
m line was the issue, see comments for discussion. candidate string isn't actually an issue
Your candidate line might be wrong. I don't believe foundation can be a string? I need to check the spec though. Instead of udpcandidate and tcpcandidate do 1 and 2. Refer to the spec for the actual algorithim to generate that value.
Related
Can some one help me with a problem.
I have an ESP32 board with GPIO pin 25 and 27 connected to a 2 relay board and with a webserver.
At boot one relay is low and one is high then the code behind the webpage is
while True:
try:
if gc.mem_free() < 102000:
gc.collect()
conn, addr = s.accept()
conn.settimeout(3.0)
print('Got a connection from %s' % str(addr))
request = conn.recv(1024)
conn.settimeout(None)
request = str(request)
print('Content = %s' % request)
relay_on = request.find('/?relay=on')
relay_off = request.find('/?relay=off')
if relay_on == 6:
print('RELAY ON')
relay_a.value(0)
relay_b.value(1)
if relay_off == 6:
print('RELAY OFF')
relay_a.value(1)
relay_b.value(0)
response = web_page()
conn.send('HTTP/1.1 200 OK\n')
conn.send('Content-Type: text/html\n')
conn.send('Connection: close\n\n')
conn.sendall(response)
conn.close()
except OSError as e:
conn.close()
print('Connection closed')
but with this cod only relay_a is getting triggered on an off.
Thanks in advance!
i'm newbie to the field of automotive, i'm trying to make a connection with can bus between CAN box and aurix board and monitor this connection using CANoe software.
i'm only trying to send a simple message one time from the kit over the can bus as a start just to test the connection and make sure it works before i proceed with the rest of the application.
but all i receive from the kit on CANoe is errors like Form errors, stuff error, CRC error, CAN overload frame.
i checked the pins of the can on the board multiple times to make sure they are correct, also tried to change the CAN channel used on the CAN box, even checked the wires and every thing seems like connected correctly.
and the software i'm using is only a demo that i found inside TASKING compiler demos in the files related the the kit i'm using so i can assume it's not wrong.
the steps i followed to get it this demo to compile are simple
use the software platform builder inside TASKING IDE to attach the files related to the kit to the project.
include the CAN driver file in it "IfxMultican_Can.h"
then i copied and pasted the code inside the documentation within that header file into my project.
i did every thing i could think of to get this to work but still same errors, so it's either the connections are wrong some how or the driver code provided with TASKING IDE contains errors, there is nothing else in the system.
the code i'm using for the project is
#include <stdio.h>
#include "SoftwarePlatform/illd_tc29xb/src/ifx/TC29xB/Multican/Can/IfxMultican_Can.h"
// CAN handle
IfxMultican_Can can;
// Nodes handles
IfxMultican_Can_Node canSrcNode;
IfxMultican_Can_Node canDstNode;
// Message Object handles
IfxMultican_Can_MsgObj canSrcMsgObj;
IfxMultican_Can_MsgObj canDstMsgObj;
const unsigned id = 0x100;
int main(){
// create configuration
IfxMultican_Can_Config canConfig;
IfxMultican_Can_initModuleConfig(&canConfig, &MODULE_CAN);
//initialize module
//IfxMultican_Can can; // defined globally
IfxMultican_Can_initModule(&can, &canConfig);
// create CAN node config
IfxMultican_Can_NodeConfig canNodeConfig;
IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);
canNodeConfig.baudrate = 1000000; // 1 MBaud
// Source Node
// IfxMultican_Can_Node canSrcNode; // defined globally
{
canNodeConfig.nodeId = IfxMultican_NodeId_0;
canNodeConfig.rxPin = &IfxMultican_RXD0B_P20_7_IN;
canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
canNodeConfig.txPin = &IfxMultican_TXD0_P20_8_OUT;
canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
// initialize the node
IfxMultican_Can_Node_init(&canSrcNode, &canNodeConfig);
}
// Destination Node
// IfxMultican_Can_Node canDstNode; // defined globally
{
canNodeConfig.nodeId = IfxMultican_NodeId_1;
canNodeConfig.rxPin = &IfxMultican_RXD1B_P14_1_IN;
canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
canNodeConfig.txPin = &IfxMultican_TXD1_P14_0_OUT;
canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;
// initialize the node
IfxMultican_Can_Node_init(&canDstNode, &canNodeConfig);
}
// IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
{
// create message object config
IfxMultican_Can_MsgObjConfig canMsgObjConfig;
IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);
// assigned message object:
canMsgObjConfig.msgObjId = 0;
canMsgObjConfig.messageId = id; // 'id' is defined globally
canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
canMsgObjConfig.frame = IfxMultican_Frame_transmit;
canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
canMsgObjConfig.control.extendedFrame = FALSE;
canMsgObjConfig.control.matchingId = TRUE;
// initialize message object
IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
}
// IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
{
// create message object config
IfxMultican_Can_MsgObjConfig canMsgObjConfig;
IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);
// assigned message object:
canMsgObjConfig.msgObjId = 2;
canMsgObjConfig.messageId = id;
canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
canMsgObjConfig.frame = IfxMultican_Frame_receive;
canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
canMsgObjConfig.control.extendedFrame = FALSE;
canMsgObjConfig.control.matchingId = TRUE;
// initialize message object
IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
}
const unsigned dataLow = 0xC0CAC01A;
const unsigned dataHigh = 0xBA5EBA11;
// Initialize the message structure
IfxMultican_Message txMsg;
IfxMultican_Message_init(&txMsg, id, dataLow, dataHigh, IfxMultican_DataLengthCode_8);
// Transmit Data
while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &txMsg) == IfxMultican_Status_notSentBusy );
return 0;
}
some examples of the errors i get in CANoe
Time Chn ID Name Event Type Dir DLC Data
[-] 18.909137 CAN 1 CAN Error RxErr ECC: 100000011xxxxx, Form Error, Bit Position = 12
| ECC 100000011xxxxx
| Code Form Error
| Position 12
| ID 0010010011001b (499)
| DLC 9
| Data 00-07 00 00 00 00 00 00 00 00
another example
Time Chn ID Name Event Type Dir DLC Data
[-] 18.907080 CAN 1 CAN Error RxErr ECC: 100001001xxxxx, CRC Error, Bit Position = 36
| ECC 100001001xxxxx
| Code CRC Error
| Position 36
| ID 0010010011001b (499)
| DLC 9
| Data 00-07 00 00 00 00 00 00 00 00
i also must point that despite i only send the message once, i keep receiving a non-ending sequence of those errors until i stop the simulation.
is there any way i can use to better understand how to fix those errors?
any information about the kit pins numbering or the correct connection for can would be very helpful.
i also must point that i'm only using the driver for the can abstractly from how it works, i only understand the CAN as bus on which i'll throw a message and receive it from the other end using some functions i don't know how it actually works and the time i have is quite limit and doesn't allow me to learn that much.
board used : KIT_AURIX_TC297_TFT
, CAN box : VN6510A
You need to change your baudrate in CANOe from 500.0 to 1000.0 Kbps (as configured in infineon iLLD canNodeConfig.baudrate = 1000000; // 1 MBaud)
Also, make sure you have 120 Ohm resistor between CANH and CANL.
Try to see your output from microcontroler (CAN TX/CAN RX) in oscilloscope or logic analyser, also the output from your CAN transceiver, since you are using TFT board you already have the transceiver resistor.
I am writing the CAPL script to Automise the Diagnostic services. I have read some DIDs which are bigger than 8 bytes in size. Till 8 bytes I can capture correctly the data in my CAPL script but when the data size exceeds the 8 bytes, then I get some garbage values 00 for remaining bytes.
The complete read data I can see in CANoe Trace but I am not able to capture it in my CAPL script. If someone has any ideas or solution, please share with me.
In Belo script, the issue is that I can capture value till this.byte(7) correctly. But for this.byte(8) and this.byte(9) I read 00 although the actual value in CANoe Trace is 0x54 and 0x66. So it means I cannot read more than 8 bytes in CAPL from CAN.
My script looks like:
variables
{
//Please insert your code below this comment
byte test_num;
message DTOOL_to_UPA msg_tester;
mstimer readTimerDID_2001;
mstimer defaultSession;
byte readBuf2001[8];
}
// read request
on key 'd'
{
test_num = 0;
msg_tester.dlc = 8;
msg_tester.dir = tx;
msg_tester.can = 1;
settimer(defaultSession, 2000);
}
on timer defaultSession // Request DID: 10 01
{
msg_tester.byte(0) = 0x02;
msg_tester.byte(1) = 0x10;
msg_tester.byte(2) = 0x01;
output(msg_tester);
settimer(readTimerDID_2001, 100);
canceltimer(defaultSession);
}
on timer readTimerDID_2001 // Read Request DID: 22 20 01
{
msg_tester.byte(0) = 0x03;
msg_tester.byte(1) = 0x22;
msg_tester.byte(2) = 0x20;
msg_tester.byte(3) = 0x01;
output(msg_tester);
canceltimer(readTimerDID_2001);
}
on message UPA_to_DTOOL
{
if (this.DIR == RX)
{
// Response Data for DID 2001
if (
(this.byte(0)== 0x04)&&(this.byte(1)== 0x62)&&(this.byte(2)==0x20)&&
(this.byte(3)== 0x01)&&(this.byte(4)== 0x23) &&(this.byte(5)== 0x00)&&
(this.byte(6)== 0x44)&&(this.byte(7)== 0x22) &&(this.byte(8)==0x54)&&
(this.byte(9)== 0x66)
)
{
readDID2001();
}
}
}
on message UPA_to_DTOOL
is reacting on the CAN message UPA_to_DTOOL, and this you can only access the 8 bytes of the CAN message.
If you want to react on diagnostic messages you should use
on diagResponse <serviceName>
inside of this handler you can then access the complete data of the diagnostic message
I had a similar problem accessing j1939 PGN with data length code (DLC) > 8 byte. These messages were transmitted as a j1939 Frame (DLC > 8 byte) instead of a CAN frame (DLC = 8 byte) in the trace window. I had to make use of the getThisMessage(pg pg_variable, int length) function in an on pg event like this.
on pg UPA_to_DTOOL {
pg UPA_to_DTOOL UPA_to_DTOOL_pg;
getThisMessage(UPA_to_DTOOL, UPA_to_DTOOL.dlc);
write("byte 9 = %X", UPA_to_DTOOL.byte(9));
}
Because messages with DLC > 8 are transmitted in a special way, the getThisMessage had to be used in my case, which let me access all the message bytes. I am not sure this solution for j1939 PGNs helps you because I do not know whether you have a license for j1939 in your canoe installation.
I am building a specific jig for performance measurement. I have a load generator, boom (https://github.com/rakyll/boom). With this I can generate a pretty decent amount of load.
I also have a Docker image containing nginx as a load balancer, and two Akka-HTTP based REST servers. These do nothing except count hits (they always just return 200).
Running one of these servers stand-alone (outside the Docker) I have been able to get 1000 hits/second. Not sure if that's good or not. In this Docker configuration that figure drops to about 220 hits/second. I was kinda expecting, well... 2000 hits/second or thereabouts. Higher would even be better. I'd be happy if I can find a way to get 3-4K hits/sec with this arrangement.
I often get an error message like this:
[9549] Get http://192.168.99.100:9090/dispatcher?reply_to=foo: dial tcp 192.168.99.100:9090: socket: too many open files
Tried running my Docker with --ulimit nofile=2048, but that didn't help. My application.conf for Akka is merely:
akka {
loglevel = "ERROR"
stdout-loglevel = "ERROR"
http.host-connection-pool.max-open-requests = 512
}
The server code:
object Main extends App {
implicit val system = ActorSystem()
implicit val mat = ActorMaterializer()
println(":: Starting Simulator on port "+args(0))
Http().bindAndHandle(route, java.net.InetAddress.getLoopbackAddress.getHostAddress, args(0).toInt)
var hits = 0
var isTiming = false
var numSec = 1
lazy val route =
get {
path("dispatcher") {
if(isTiming) hits += 1
complete(StatusCodes.OK)
} ~
path("startTiming" / IntNumber) { sec =>
isTiming = true
hits = 0
numSec = sec
val timeUnit = FiniteDuration(sec, SECONDS)
system.scheduler.scheduleOnce(timeUnit){ isTiming = false }
complete(StatusCodes.OK)
} ~
path("tps") {
val tps = hits/numSec * 2
complete(s"""${args(0)}: TPS-$tps\n""")
}
}
}
Theory of operation: Start traffic flowing then call the /startTiming/10 endpoint (for a 10-second capture on one of the 2 servers). After 10 seconds, call /tps a couple of times and the timing node will return approx. hits/second (x2).
Any idea how I can get more performance out of this?
I'm running the code example below against a remote PLC with Wireshark running. Why do I only get the query (I should get the response too)? It seems that the PLC sends the response, since the output of Scapy says Received 1 packets, got 1 answers, remaining 0 packets.
Any ideas of why is this happening?
I also performed the sniffing using the sniff() function from Scapy but the result is the same (only get the query).
#! /usr/bin/env python
import logging
logging.getLogger("scapy").setLevel(1)
from scapy import *
from modLib import *
# IP for all transmissions
ip = IP(dst="192.168.10.131")
# Sets up the session with a TCP three-way handshake
# Send the syn, receive the syn/ack
tcp = TCP( flags = 'S', window = 65535, sport = RandShort(), dport = 502, options = [('MSS', 1360 ), ('NOP', 1), ('NOP', 1), ('SAckOK', '')])
synAck = sr1 ( ip / tcp )
# Send the ack
tcp.flags = 'A'
tcp.sport = synAck[TCP].dport
tcp.seq = synAck[TCP].ack
tcp.ack = synAck[TCP].seq + 1
tcp.options = ''
send( ip / tcp )
# Creates and sends the Modbus Read Holding Registers command packet
# Send the ack/push i.e. the request, receive the data i.e. the response
tcp.flags = 'AP'
adu = ModbusADU()
pdu = ModbusPDU03()
adu = adu / pdu
tcp = tcp / adu
data = sr1(( ip / tcp ), timeout = 2)
data.show()
# Acknowledges the response
# Ack the data response
# TODO: note, the 17 below should be replaced with a read packet length method...
tcp.flags = 'A'
tcp.seq = data[TCP].ack
tcp.ack = data[TCP] + 17
tcp.payload = ''
finAck = sr1( ip / tcp )
First, you have a bug in your code (which is present in the original version http://www.digitalbond.com/scadapedia/security-controls/scapy-modbus-extensions/), you need to add .seq there: tcp.ack = data[TCP].seq + 17.
As said in the comment, you could write tcp.ack = data[TCP].seq + len(data[TCP].payload).
Anyway it's generally useless to do the TCP stack's work for the kind of things you try to do.
I would do something like that:
from scapy import *
from modLib import *
import socket
sock = socket.socket()
sock.connect(("192.168.10.131", 502))
s = StreamSocket(sock, basecls=ModbusADU)
ans, unans = s.sr(ModbusADU()/ModbusPDU03())
ans.show()
Does this work better?