0

I'm trying to create a simple Link layer protocol for school.

I've been searching and googling and I understand that Link layer has pas the frame I create to the Physical layer, but how to do in Programming (language c) is there a function or library that I can use to send my frame directly using Physical layer ? or how should it be done ?

Mohe TheDreamy
  • 387
  • 8
  • 21

2 Answers2

2

The most common design patterns to develop communication protocols are the Protocol Stack Design Pattern and the Protocol Layer Design Pattern. Take a look at it. The links have some example code.

In summary it works as following:

  • Communication Upper Layer to Lower Layer: use function parameters
  • Communication Lower Layer to Upper Layer: use callback functions

Designing protocols is not trivial and you should keep it simple in the first approaches.

code monkey
  • 2,094
  • 3
  • 23
  • 26
  • thanks, it's a bit useful, but it doesn't answer my question. What I'm looking for a how to send packet to the lower layer or how to send packet to another Pc, is there a phyical layer based function or library that I can use to do that ? – Mohe TheDreamy Dec 01 '14 at 14:19
  • Please specify your question? So you don't want do develop your own protocol? Do you want to use TCP/IP and send a packet using a socket? – code monkey Dec 01 '14 at 17:26
  • not my own protocol, just the layer. What I'm trying to do is to program the link layer, but in the link layer I have to pass the packet to the lower layer which is the physical layer, but I don't want to program that too. I'm trying to figure out to to pass my packet to the network adapter to do its work or dunno what I should do in order to send the packet to the other PC I'm trying to communicate with. – Mohe TheDreamy Dec 01 '14 at 21:57
  • I don't think I should use UDP here. – Mohe TheDreamy Dec 05 '14 at 09:52
0

you need to use a sockets code ,A socket is one end-point of a two-way communication link between two programs running on the network link. Socket classes are used to represent the connection between a client program and a server program. you do not need to program the physical layer, the OS care with . http://www.tutorialspoint.com/java/java_networking.htm

k.ratty
  • 1
  • 1