|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
27 NS_OBJECT_ENSURE_REGISTERED (SensorNode);
29 NS_LOG_COMPONENT_DEFINE (
"sensornode");
34 static TypeId tid = TypeId (
"ns3::SensorNode")
36 .AddConstructor<SensorNode> ()
37 .AddAttribute (
"SinkNodeAddress",
"Address to send packets.",
38 Ipv4AddressValue (Ipv4Address::GetAny ()),
40 MakeIpv4AddressChecker ());
65 Ptr<Packet> p = Create<Packet> ();
110 Ptr<Packet> np = Create<Packet> ();
112 np = Create<Packet> ();
117 InetSocketAddress remote (Ipv4Address (ip),
m_port);
128 NS_LOG_INFO (
"Ghost onion received, deleted with onion id: "
130 <<
", at time: " << std::to_string (Simulator::Now ().GetSeconds ()));
141 int outer_layer_len = onion.length ();
146 outer_layer_len += onionHead->
padding ().length ();
165 std::string padding (outer_layer_len - onion.length (),
'0');
172 delete[] serialized_onion;
227 m_socket->SetAcceptCallback (MakeNullCallback<
bool, Ptr<Socket>,
const Address &> (),
Ptr< Socket > m_socket
listening socket
::protomessage::ProtoPacket_Handshake * mutable_h_shake()
Ptr< Packet > RecvSegment(Ptr< Socket > socket)
method for receiving a segment calls ns3::Wsn_node::RecvSeg()
std::string GetPKtoString()
accessor
int o_sequenceNum
sequence number of the onion, should be same as onion_id
void SendSegment(InetSocketAddress remote, Ptr< Packet > packet, bool b_onion)
Send a packet through a TCP connection to the remote address.
void SetData(protomessage::ProtoPacket message)
Setter of the data in the protocol header.
::protomessage::ProtoPacket_OnionBody * mutable_o_body()
uint32_t getNodeDelay(Ipv4Address node_address)
compute when the node should start the handshake process from the node ip address Used to not generat...
uint8_t * nextHopIP
ip address given in the serialized form
size_t ByteSizeLong() const final
const std::string & onion_message() const
Ptr< OnionValidator > m_onionValidator
Pointer to the ns3::OnionValidator.
SensorNode()
Default constructor.
std::string UcharToString(unsigned char *seq, int len)
Convert an array of unsigned chars to a std::string.
uint32_t m_sensorValue
dummy reading of a sensor equipped on the node
void ReceivePacket(Ptr< Socket > socket)
Executed when a new onion is received.
orLayer * PeelOnion(uint8_t *onion, uint16_t onionLen, uint8_t *pk, uint8_t *sk)
unsigned char * StringToUchar(std::string in)
Convert a string to an array of unsigned chars.
Ipv4Address m_address
ns3::Ipv4Address of this node
virtual void StartApplication(void)
1.Start the application run ns3::Wsn_node::Configure() 2.Generate new encryption keys 3....
uint32_t ProcessOnionHead(protomessage::ProtoPacket_OnionHead *onionHead)
Decrypt the outer layer of the onion head, obtain the information of the next IP address,...
virtual void StopApplication(void)
Stop the application.
::protomessage::ProtoPacket_OnionHead * mutable_o_head()
structure holding details resulting from layer decryption of an onion message
void set_onion_message(ArgT0 &&arg0, ArgT... args)
unsigned char * GetPK(void)
accessor
uint8_t * innerLayer
inner content of the onion message without the next hop address
static TypeId GetTypeId(void)
Register this type.
const std::string & padding() const
void NotifyRx(Ptr< const Packet > packet)
Call to signal the receipt of a Packet at the application layer.
OnionManager m_onionManager
The ns3::OnionManager object.
void set_publickey(ArgT0 &&arg0, ArgT... args)
int32_t aggregatedvalue() const
Class for the serialization-deserialization of the messagess to send in packets.
Ptr< OutputManager > m_outputManager
Pointer to the ns3::OutputManager.
uint16_t m_port
port of the application
The wsn node base class that manages the sending and receiving of packets and basic configuration of ...
void Handshake(void)
Construct a new protobuf object containing the node publickey and send it to the sink node.
void GenerateNewKeyPair(void)
Generate a new public/private keypair using the libsodium library.
uint16_t innerLayerLen
length of the inner content of the onion message
virtual ~SensorNode()
Default destructor.
unsigned char * GetSK(void)
accessor
void NotifyTx(Ptr< const Packet > packet)
Call to signal the transmission of a Packet at the application layer.
Ipv4Address m_sinkAddress
address of the sink node
void set_aggregatedvalue(int32_t value)
void set_padding(ArgT0 &&arg0, ArgT... args)
bool has_aggregatedvalue() const
void OnionReceived(void)
Signal to the ns3::OnionValidator that the onion was corrctly received.
void Accept(Ptr< Socket > socket, const ns3::Address &from)
Accept new TCP connections.
void ProcessOnionBody(protomessage::ProtoPacket_OnionBody *onionbody)
If the onion body contains the aggregated value, then aggregate the sensor (dummy) value to the value...
void GetData(protomessage::ProtoPacket *message)
Getter of the data in the protocol header.
size_t ByteSizeLong() const final
uint32_t DeserializeIpv4ToInt(uint8_t *buff)
Convert an IPV4 address given as a buffer.