开发者

How to program the OSI reference model in language

开发者 https://www.devze.com 2023-02-05 10:17 出处:网络
I am studying networking and OSI model and all 7 layers. Like how each layer puts its own header and then removes on the receiver end.

I am studying networking and OSI model and all 7 layers. Like how each layer puts its own header and then removes on the receiver end.

Is there any way that i can create the program in java or c or c++ and i manually perform each step which is done at layers so that i actually know how it actually works

Edit: ok first consider locally For example i have data word "hello" and i want to send it to another running program simulating the OSI model. That word ill go trough the all layers and 开发者_JS百科they will add their headers and stuff like OSI does and then other running program will receive it.

Basically TCP/ip protocol has to be programmed i think but may be experineced person can get it better

then i can manually change the bits to check whether error control works ok or not


Since the OSI model has 7 layers:

  1. Physical
  2. Link
  3. Network
  4. Transport
  5. Session
  6. Presentation
  7. Application

and you want to emulate it in a Java (or possibly C) environment, then you're going to need to do a moderate amount of work.

For the purposes of your simulation, you'd probably treat the normal TCP/IP sockets layer as the physical layer - in your simulation, it achieves connectivity between endpoints. It is a remarkably reliable physical layer, but you can't have everything.

You can then simulate each of the successive layers - Link, Network, Transport, Session, Presentation, Application - layers with appropriate code that puts data into packets, or splits up packets, and adds headers and check sums and so on. Each layer except the application has two interfaces: the downward interface (to the lower-numbered layer) and the upward interface (to the higher-numbered layer). You'll need to decide on appropriate operations for each layer. A minimal set is likely to be: open, close, read, write.

I'd start simple - with either the bottom or the top (either direction could work). Since you'll need an application anyway (test code if nothing else), you might start there. You'll successively refine the code adding extra layers, ensuring the previous functionality continues to work. You'll have to work out how the application layer conveys to the data link layer the information that it needs - so that the correct socket calls can be made, etc.

Have fun.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号