Trouble with NULL characters in Alljoyn bus messages - alljoyn

I am trying to develop alljoyn applications using C as my language binding. I have understood and implemented the basic tutorial, customized it and able to build applications at both server and client. Now comes the second part of my development to program a file transfer server and client by reading the files and putting them onto alljoyn bus reply.
Since Alljoyn reply can be only of 65536 bytes I framed my own protocol between server and client where server breaks down the message and the client receives the message chunks sequentially one after another. Now I am facing a problem here which I would like to describe briefly.
(1) If I transmit text messages I receive them perfectly.
(2) If I transmit a binary data I would loose data. My understanding is that the alljoyn bus reply is a string and whenever I am receiving a NULL all the subsequent characters are read as zeros at the receiver.
What to do for mitigating this.
I want to know if there any ways where I can mask off the NULL characters in my binary data string or the approach what I am following itself is flawed.
I just started to use this alljoyn framework and I am very much newbie. Any help would be greatly helpful.

You should be using an array of bytes (signature of 'ay') to send as binary data. That should prevent alljoyn from truncating your strings when it sees a NULL. AllJoyn can handle binary data as long as you tell it that's what you're using.

Related

NiFi forward/duplicate TCP Stream

I'm supposed to duplicate a binary TCP Stream.
So I set up a NiFi 1.9.0 server, put in a ListenTCP processor and a PutTCP processor, configured the proper IPs and Ports and connected them.
So far so good, the packets were received by the ListenTCP processor and also forwareded by the PutTCP processor.
But NiFi seems to mess around with the data somehow, the sent packets aren't exactly the same as received. I expected NiFi to just forward everything 1:1 but something is happening and I cannot find out what.
I've been playing around with the Character Set, Max Batch Size and Batching Message Delemiter settings on the ListenTCP processor and also with the Outgoing Message Delemiter and Character Set on the PutTCP processor.
I also messed around with a MergeContent processor but didn't get it to work properly.
Here you can see the difference between received (red) and sent data (captured using tcpflow).
Link to picture
Another problem is that I don't really know the data I'm processing, it says in the documentation:
These log files are in the machine-readable binary format that is described by the XML file called ebm.xml.
and
The streamed events are in the TCP-based binary format.
I do have access to ebm.xml file, but not sure how I can make use of it.
Anyone an idea how I can get NiFi to simply forward everything?
I'm new to NiFi, so I might have missed some possibilites...
The ListenTCP processor reads data from the stream using a new-line character as a logical message separator. For example, if the stream had:
<chunk1><new-line><chunk2><new-line><chunk3><new-line>
It would result in reading chunk1, chunk2, and chunk3 into an internal queue.
When it writes them back out it uses the outgoing message delimiter. So the outgoing flow file would be:
<chunk1><outgoing-delim><chunk2><outgoing-delim><chunk3><outgoing-delim>
Unfortunately it is more geared towards receiving textual data such as logs which are typically line-delimited. The chunks should be passing through unaltered as byte[], but typically binary data wouldn't have these logical new-line boundaries, so I'm not sure how well it works for that.

how to emulate packets using wiresharks info?

I just wanted to write a program to show the server-list of teknomw3. I'm not familiar with wireshark or packet-sniffing. I just tried using wireshark and got information.
Below is one of information sent by the master-server to mw3,
I can clearly see the data sent by the master-server, that contains the data of a dedicated-server.
here's the packet info mw3 sent, before getting the server list,
Is there a way to create my own program to get the server list? I know C#, Java. but not an expert.
From where should I start?

Invalid data handling over TCP socket

I have a GUI application that sends/recv over tcp to a server.
Sometimes, we get junk data while doing a tcp recv from the server. While reading these nulls or invalid data, the client application crashes sometimes.
Is there a good way to validate this data? - other than catching this exception.
I dont want the GUI application to crash because of bad data sent by the server.
TCP has a checksum that it uses to validate the data received; that is done by the operating system (or sometimes the network hardware, if you have nice hardware). If the contents are not correct, with a very high probability, the data that was sent was incorrect. I just state that because I'm not totally sure that you were aware of this fact.
If you need to validate the data, you will have to validate the data. Write a function that parses your data, and returns a meaningful value only if there's meaningful data. Make your GUI aware of this.
Your question is kind of self-answering... you can't say "I want to be fault-tolerant, but I don't want to care about faults" ("other than catching this exception"), and based on the lack of description of the data you'd expect, I'd say you don't really care about the form of the data.

Determine size of object sent across the network

I am trying to figure out the size of an object that is sent to my application via TCP. Unfortunately there is a third party tool that is receiving data and then handing my application an object through a callback.
Is there a tool provided with solaris that would help me determine the bytes of these messages?
Alternatively I could do it on a test windows version of the app.
You could try using a network analyzer, such as Wireshark, to look at the TCP traffic.
Apologies if I have misunderstood your question.

WSAECONNABORTED when using recv for the second time

I am writing a 2D multiplayer game consisting of two applications, a console server and windowed client. So far, the client has a FD_SET which is filled with connected clients, a list of my game object pointers and some other things. In the main(), I initialize listening on a socket and create three threads, one for accepting incoming connections and placing them within the FD_SET, another one for processing objects' location, velocity and acceleration and flagging them (if needed) as the ones that have to be updated on the client. The third thread uses the send() function to send update info of every object (iterating through the list of object pointers). Such a packet consists of an operation code, packet size & the actual data. On the client I parse it, by reading first 5 bytes (the opcode and packet size) which are received correctly, but when I want to read the remaining part of the packet (since I now know the size of it), I get a WSAECONNABORTED (error code 10053). I've read about this error, but can't see why it occurs in my application. Any help would be appreciated.
The error means the system closed the socket. This could be because it detected that the client disconnected, or because it was sending more data than you were reading.
A parser for network protocols typcally needs a lot of work to make it robust, and you can't tell how much data you will get in a single read(), e.g. you may get more than your operation code and packet size in the first chunk you read, you might even get less (e.g. only the operation code). Double check this isn't happening in your failure case.

Resources