How do I get started writing my own IP-Like Protocol? [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So my question is, would it be possible to write a protocol which does the same as the Internet Protocol, and if so, how do I get started? And don't say, "isn't the Internet Protocol good enough?", yes it is, it is just to see if it is possible:P
I would like to know a bit more about how,
just for learning how protocols are done. I have some experience in programming, but not anything like networking protocols.

The short answer is yes -- it has been done, and could be done again.
Examples of what have been done include DECnet, NetBIOS, Appletalk, and ATM. Although I'm not sure it was ever fully implemented as intended (though DECNet came pretty close), the standard OSI 7-layer model for networking was originally intended as a model of actual implementation (i.e., the intent was that people would implement those layers, and you'd be able to build a fully network stack by plugging together the implementation of your choice of each layer).
Of course, what most of us think of as IP today is really IPv4 -- as you can probably guess from the version number, it had predecessors (and a successor, IPv6).
Edit: as to how you do it: pretty much like anything else. I'd start by writing up something about your motivation -- what you want to accomplish, what sorts of operations it should support, etc. Then start working on the simplest design you can figure out that can possibly do what you want. Then, as you use it and encounter problems, figure out whether they stem from poor implementation, or shortcomings in the design itself. Modify one or both as needed, trying to keep its evolution as coherent and understandable as possible.

In short: Yes, it would be possible. On a higher level (i.e. OSI layer 7) it is done daily. If you want to implement the next IP, all you need are:
Special hardware (for the actual physical implementation, assuming that your protocol greatly differs from IP)
Device drivers for your favourite operating system that support your protocol
Maybe a high-level API to facilitate implementation
Edit: Saw that two others beat me to it ;)

would it be possible to write a protocol which does the same as the
Internet Protocol?
Yes it is possible to write your own IP stack, but it is extremely difficult to actually go ahead and do it (and actually do it right) unless you are an expert level both in programming and in networking

Related

Writing drivers for Windows [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I recently asked the question if I could limit bandwidth via a C# WinForms applications much like NetLimiter and NetBalancer. I was told that there's two ways to do this. Either via proper QoS or writing something along the lines of an "NDIS Network Filter Driver". Using QoS isn't the way I want to take. So I've looked up some of the stuff required to write drivers and found some interesting points. Points such as a good understanding of C/C++, because the executed code being very prone to BSODs since it could be run in something called "Kernel mode". I also found a GitHub "dump" which looks interesting and tempts me to investigate and look around in.
As you can see I'm no where near advanced enough to delve into this on a professional level. Ignoring that, what would be a good start to start my adventures into writing drivers to monitor - and further down the line manipulate the network to introduce throttling.
Any help, guides or information that might be of help is always appreciated.
PS: I am unsure as to whether this is (as afore mentioned in a comment to my previous question) too broad a question to be answered on Stack Overflow. If so, where would I go to ask this?
Indeed, this would be too broad. Driver writing is a complicated thing which requires a good understanding of how a computer and the OS works. Also, C# (and .NET itself) indeed isn't available in Kernel Mode, so C/C++ is the preferred way. Although theoretically any unmanaged language (like Pascal) could do, I haven't heard of anyone writing drivers in them. Microsoft's own developer resources are also written with C/C++ in mind.
Which brings us to the question of why you want to do it.
If you need it for work and there's a deadline - forget it. Get someone else who already knows this stuff. Or there might be a library out there that fills the need. Any of these options will be cheaper than your time spent learning all this stuff.
If it's for your own curiosity however - go for it! I'd advise by starting to learn C first. Not C++, that's more complicated and for drivers it will be easier with C anyway. But you can pick up C++ later too, it's good stuff. C++ is mostly compatible with C, so you can start with C and then continue with C++.
In parallel, get a good book about OS design. Not because you want to design an OS, but to understand the basic concepts that it is built upon. You should get a good understanding of things such as Kernel Mode/User Mode, virtual memory, interrupts, process scheduling, etc.
Learning a bit of assembly might be useful too (albeit not required).
Finally, when you feel like you've got a good grasp of the above, head over to MSDN and start reading about driver development. There will be long articles and example programs to get you started. Tweak them and play around in a virtual machine until you get what you need.
And also... read this.

Audio output C language (novice) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm sorry if this is long. I feel I need to be very thorough as to where I am actually at.
Right so first off I do have experience with JavaScript.
Which is not the same thing, But it sure looks familiar to me.
I want to make music with C.
I got his big book called "The audio programming book".
It was like $60.
It dose have an introduction to C in it. It all makes good sense to me so far.
nothing really new.
So here's my problem...
And its very simple. So simple in-fact that it doesn't seem to be covered in the book.
I don't understand the relationship between my program and the speakers.
my computer's audio device.
I thought to myself "Alright lets start with the very basics. Let's see if we can just make a noise."
And so...
I have something that will make a beep.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
printf("\a\n");
return 0;
}
So that's cute.
But that's seemingly all that function is capable of.
And honestly That would be rather confusing if... the thing that is meant for printing text to your screen... was also the thing you use to talk to your speakers....
I've been looking through the book. I've been looking online. I've been looking for hours.
And clearly searching in all the wrong places... because literally all I can find is more of how to make your computer beep...
where is the "send to speaker"??
where do I put in the frequency?
Heaven forbid the part were I tell the thing what device I would like to talk to.
Dose C simply not have any built-in functionality for sending signals to the speakers?
Do I need a Library? Do need C++? What am I missing.
I don't know anything about desktop applications.
All my experiences is with Internet technologies.
Dose C simply not have any built-in functionality for sending signals to the speakers?
Indeed, C does not have any built-in functionality for sending signals to the speakers.
Do I need a Library?
No, but I would highly recommend to use one.
Do need C++?
No. You don't need C++ for doing anything in C. Besides, C++ also has no built-in audio functionality.
where is the "send to speaker"?? where do I put in the frequency? Heaven forbid the part were I tell the thing what device I would like to talk to.
All these and other things related to audio are platform (operating system) specific. In order to interact with a sound card (which is the device that sends signals to the speakers), you must use platform specific API. Some operating systems may have multiple different APIs for audio. You can, as I already recommended, use a (cross-platform) library that abstracts the platform specific API.
You say you want to "make music with C". This seems to imply that you want to be able to feed data into the sound buffer in real-time through something like an ASIO driver, with low-lantency, and that you want to write your own audio synthesis. This is all quite complicated stuff, but you should start by getting some library/API that gives you that kind of access. Sadly, most of them do not tend to be free, but there probably are some free options, if you look around.
Since all of this depends so much on what library/API you use, I sadly cannot say anything more precise.
Another option is to study up and learn how to program VST-instruments (plug-ins for DAWs), which will probabably be even more useful for what it sounds like you're trying to do.
And no, you don't need C++, unless the library/API you want to use only supports C++, for some reason. That doesn't tend to be the case.

Getting started with network programming in Qt [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I just started a summer job at my university doing work in a lab, and I've been given a rather large, vague problem to tackle without much guidance so I was hoping someone could help point me in the right direction.
Essentially it's a 3-d world built in Qt using VTK (Visualization ToolKit) for use in therapy and rehab, and my task is to find a way to network two or more instances of the program so that users can share the same 3-d environment (essentially a networked video game).
The professor wants it to be secure, for latency to be as low as possible, and for the program to record data after a session is complete.
So far I was thinking (without much experience) of doing a client/server model built in Qt, but I'm not sure where to start.
Q1:
Should I use Boost.asio, or Qt library for networking?
Q2:
Are there any concepts I should be mindful of from the get-go for security, and network programming in general? (I've heard good things about Beej's Guide, and books by W. Richard Stevens)
Trying to answer your first question, it depends on which platforms are you targeting (Windows, Linux, OSX...). You could use native OS socket api (bsd sockets or winsock) but Qt provides very good abstractions for these so for the sake of simplicity I would stick with it. I'm unfamiliar with boost.asio but I'm pretty sure that Qt could provide you with all you need disregarding the platform you intent to target.
As for the second question, you have to carefully analyze what kind of information you want to transmit and what will characterize the exchange.
If you intend to make it like a video game where players interact in real time, you are bound to use UDP sockets (although some data can go missing, it allows for "real time" communication). Control messages can circulate through TCP as the impact of latency won't be so critical and you want them to be reliably sent, so consider having two sockets (TCP and UDP) if that's the case, and use them for their purposes.
Those resources that you link are quite informative but assuming you have knowledge of TCP and UDP and their features, I would suggest you to brush up your multithreading skills. Qt offers you good infrastructure for this, but topics like Asynchronous I/O (how to implement selectable sockets) may help you to create a better design that will remove a lot of overhead from additional threads (specially for reading).
These are my 2 cents.
Good luck for your project, I'm sure it will be a good chance for you to learn and put some theory into practice.

Learning to write low level drivers (Linux). [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
So I was fiddling around with the Raspberry Pi, and it just kinda came to me that "Where do all these drivers come from". Like specifically for the SNES controllers im using on them....how on earth did someone figure out how to write that.
I know C decently, and C++...ok. But this has always been something I kinda thought about. It's cool because it's low level enough to understand possibly whats going on hardware wise....but also great to learn about the OS.
Where do I start with something like this? Im guessing doing this for windows would be WAYYYY different.
Thanks
It seems to me that there are really two questions here that don't really have a lot to do with each other.
The first is "what does Linux require of device drivers?" That's almost always going to be answered by reading the documentation. Although the device driver documentation may (arguably) be a little less thorough, complete, easy to read, etc., than docs for writing normal programs, it's still pretty decent. Probably the biggest difference from normal code is debugging, which is most often done via simply printing things out with printk.
The other question is something like: "How do you figure out what protocol is (or "protocols are") used by specific hardware like the SNES controller. When you're developing for something like a normal hard drive or keyboard, you can pretty much just follow the documentation. You may (often do, at least in my experience) find that you need to compensate for some bugs in the hardware, but beyond that it's (again) fairly normal programming. The biggest challenge in quite a few of these cases is simply deciding how you want to present the particular device in question to the rest of the system. For something like a hard drive that's generally pretty easy, but for something like a human interface device, it can be a little more challenging (e.g., do you want to present it as itself, or do you want to emulate some existing type of device like a keyboard or mouse?)
For hardware that's not really documented, things can get a little more difficult. The really general purpose tool for looking at logic signals is a logic analyzer. If you have something that uses a well-known hardware interface (e.g., PS/2 keyboard/mouse, USB, SATA) you can find more specialized tools (and/or add-ons for a logic analyzer) that make life quite a bit easier. Something like an NES or SNES controller almost certainly uses a proprietary interface, so for these you probably end up using a logic analyzer. Fortunately, they're also likely to be a pretty narrow, slow interface, so the logic analyzer doesn't need to be terribly fast or support a huge number of channels.
With the logic analyzer you can see all the individual signals, but for a proprietary interface, it's pretty much up to you to figure out which signals do what. In a typical case, you'll have at least a few that are fairly obvious: power, ground, quite possibly a clock, and so on. In quite a few cases, you quickly find that even if it's not publicly documented, it may follow some well-known protocol like I2C, SPI, etc.
Linux Device Drivers is the book you want.
While you wait for the book to arrive, I can tell you that knowing how the hardware works and how the Linux kernel works is only half the battle. You also need to know the hardware level interface for your specific device. Hopefully you can find documentation for this, but that can be difficult.
See this related question for an example of how someone came up with a driver for Linux by watching the commands that came out of the Windows driver:
How are low level device drivers written for Linux?
For Windows, the process is not actually terribly different. All the concepts are still the same, since it is the same hardware. The differences are in the details, of course.

What to look for in a candidate with over 8 years of experience in C, C++, Linux Application Development? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I need to interview a candidate with over 8 years of experience in Linux using C/C++.
What would be the best way to judge such a candidate?
Do I need to test his understanding of algorithms?
Do I need to test his programming skills by asking to write a program?
How should I test his understanding of Linux?
It depends entirely on what you want him to do. You haven't said anything about the position that you are hiring for but if, say, you want him to write C# then you need him to prove his adaptibility.
Do you need him to write (or modify or bugfix) algorithms? If not, then it is pointless determining how good at them he is.
On the other hand, in order to understand his abilities, you may be better off talking to him about a domain that he is familiar with. You should certainly get him to describe a recent project that he has been involved in, what his contribution was, what the challenges were, what went well, what lessons he learnt.
"Over 8 years of experience in Linux using C/C++" is a fairly vague requirement without reasons for the time length. What are the specific reasons for that time length? Would you prefer more C/C++ experience if some of it were BSD or Solaris or other Unix? Would you prefer less time or a wider experience with different distributions; would you prefer 5 years experience with Red Hat or 7 years experience spanning Red Hat, Debian, SUSE, Gentoo, and others. What are you trying to get from the person you hire, that relates to the amount of time?
The best way to judge a candidate, any candidate, is on how well he can do the job, not how good the qualifications are. You mentioned Lead Developer, owning a product feature and eventually new features. What sort of feature? A highly responsive and adaptive UI? A UI-free recursive data mining calculation? Offline document scanning/indexing code? Custom device drivers?
Basic understanding of algorithms is important, but that can be tested easily in a phone interview. The ability to map out an algorithm for problem solving, and clearly state the reasons for preferring one over another is much more useful, and harder to test.
Test his programming skills by asking to write a program is a fairly useful BS indicator test; there are quite a few people who are adept at slinging manure who can't actually write a line of code. Another useful test is to give him some code with a defect and ask him what's wrong with it, and how he would fix it.
To test his understanding of Linux, I would look at a basic BS test; fire up a Linux box and ask him to perform some basic tasks, including maybe write and compile "Hello world". This will identify the BS artists. Then I would just go with some stock test, showing that he understands the basics of the Linux design; some file system knowledge, some knowledge of tools, ask about how he would add removable device permissions for a user using SE Linux, how he'd configure access to an application that needs elevated privileges so users without those privileges can use the application.
But ultimately, these are all pretty generic ideas; IMHO, it's much more useful to think in terms of "what do we want the candidate to accomplish", than "how do we test basic skills".
Maybe you should focus on what you need. Can he help you? Has he solved problems similar to yours? What are his expectations, what are yours?
I interview people like this all the time. The answer is that no matter how much experience he has, you must prove to yourself that he is capable of the job.
Joel Spolsky is right, hiring badly is destructive to a team and organization. It should be avoided at all costs.
The more I think about it, the more I begin to think good professional developers must be good communicators - in their code and with people. Think of the old saying - the more you know, the more you realise you don't know.
That's not to say you want somebody who isn't confident: but neither do you want someone that is cocky and unwilling to interact with others.
Recently someone asked about whether they should become a programmer in this posting. No matter how a programmer starts out they will likely learn from many mistakes they've made and as a result have an element of humility about themselves and development in general.
A good programmer continues to learn and keeps a relatively open mind.